mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Add script to set Neo4j in offline (maintenance) mode and back online
This commit is contained in:
parent
ee6a7dab48
commit
fd7e39e959
45
deployment/scripts/cluster.neo4j.sh
Executable file
45
deployment/scripts/cluster.neo4j.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/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
|
||||
offline-mode)
|
||||
# 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
|
||||
;;
|
||||
online-mode)
|
||||
# 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 'offline-mode' or 'online-mode'"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
Loading…
x
Reference in New Issue
Block a user