mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #6182 from Ocelot-Social-Community/6179-add-script-to-set-neo4j-in-offline-mode-and-back
chore(other): add script to set neo4j in offline-mode and back in online-mode
This commit is contained in:
commit
6e545ab8a3
@ -18,16 +18,8 @@ BACKUP_FOLDER=${BACKUP_FOLDER:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/
|
|||||||
# create backup fodler
|
# create backup fodler
|
||||||
mkdir -p ${BACKUP_FOLDER}
|
mkdir -p ${BACKUP_FOLDER}
|
||||||
|
|
||||||
# maintenance mode on
|
# cluster maintenance mode on && Neo4j maintenance mode on
|
||||||
${SCRIPT_DIR}/cluster.maintenance.sh on
|
${SCRIPT_DIR}/cluster.neo4j.sh maintenance on
|
||||||
|
|
||||||
# shutdown database
|
|
||||||
kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \
|
|
||||||
| jq '.spec.template.spec.containers[] += {"command": ["tail", "-f", "/dev/null"]}' \
|
|
||||||
| kubectl --kubeconfig=${KUBECONFIG} apply -f -
|
|
||||||
|
|
||||||
# wait for the container to restart
|
|
||||||
sleep 60
|
|
||||||
|
|
||||||
# database backup
|
# database backup
|
||||||
kubectl --kubeconfig=${KUBECONFIG} -n default exec -it \
|
kubectl --kubeconfig=${KUBECONFIG} -n default exec -it \
|
||||||
@ -40,13 +32,5 @@ kubectl --kubeconfig=${KUBECONFIG} cp \
|
|||||||
kubectl --kubeconfig=${KUBECONFIG} cp \
|
kubectl --kubeconfig=${KUBECONFIG} cp \
|
||||||
default/$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend |awk '{ print $1 }'):/app/public/uploads $BACKUP_FOLDER/public-uploads
|
default/$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend |awk '{ print $1 }'):/app/public/uploads $BACKUP_FOLDER/public-uploads
|
||||||
|
|
||||||
# restart database
|
# Neo4j maintenance mode off && cluster maintenance mode off
|
||||||
kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \
|
${SCRIPT_DIR}/cluster.neo4j.sh maintenance off
|
||||||
| jq 'del(.spec.template.spec.containers[].command)' \
|
|
||||||
| kubectl --kubeconfig=${KUBECONFIG} apply -f -
|
|
||||||
|
|
||||||
# wait for the container to restart
|
|
||||||
sleep 60
|
|
||||||
|
|
||||||
# maintenance mode off
|
|
||||||
${SCRIPT_DIR}/cluster.maintenance.sh off
|
|
||||||
53
deployment/scripts/cluster.neo4j.sh
Executable file
53
deployment/scripts/cluster.neo4j.sh
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# base setup
|
||||||
|
SCRIPT_PATH=$(realpath $0)
|
||||||
|
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
|
||||||
|
|
||||||
|
# check CONFIGURATION
|
||||||
|
if [ -z ${CONFIGURATION} ]; then
|
||||||
|
echo "You must provide a `CONFIGURATION` via environment variable"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# configuration
|
||||||
|
KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
maintenance)
|
||||||
|
case $2 in
|
||||||
|
on)
|
||||||
|
# maintenance mode on
|
||||||
|
${SCRIPT_DIR}/cluster.maintenance.sh on
|
||||||
|
|
||||||
|
# set Neo4j in offline mode (maintenance)
|
||||||
|
kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \
|
||||||
|
| jq '.spec.template.spec.containers[] += {"command": ["tail", "-f", "/dev/null"]}' \
|
||||||
|
| kubectl --kubeconfig=${KUBECONFIG} apply -f -
|
||||||
|
|
||||||
|
# wait for the container to restart
|
||||||
|
sleep 60
|
||||||
|
;;
|
||||||
|
off)
|
||||||
|
# set Neo4j in online mode
|
||||||
|
kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \
|
||||||
|
| jq 'del(.spec.template.spec.containers[].command)' \
|
||||||
|
| kubectl --kubeconfig=${KUBECONFIG} apply -f -
|
||||||
|
|
||||||
|
# wait for the container to restart
|
||||||
|
sleep 60
|
||||||
|
|
||||||
|
# maintenance mode off
|
||||||
|
${SCRIPT_DIR}/cluster.maintenance.sh off
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e "Run this script with first argument either 'off' or 'on'"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e "Run this script with first argument 'maintenance'"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Loading…
x
Reference in New Issue
Block a user