Change 'cluster.neo4j.sh' commands to 'maintenance on' and 'maintenance off'

This commit is contained in:
Wolfgang Huß 2023-10-25 13:56:14 +02:00
parent 16ce5673a3
commit 85e6b5fc48
2 changed files with 32 additions and 26 deletions

View File

@ -18,9 +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
# set Neo4j in offline mode (maintenance) ${SCRIPT_DIR}/cluster.neo4j.sh maintenance on
${SCRIPT_DIR}/cluster.neo4j.sh off
# database backup # database backup
kubectl --kubeconfig=${KUBECONFIG} -n default exec -it \ kubectl --kubeconfig=${KUBECONFIG} -n default exec -it \
@ -33,6 +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
# set Neo4j in online mode # Neo4j maintenance mode off && cluster maintenance mode off
# maintenance mode off ${SCRIPT_DIR}/cluster.neo4j.sh maintenance off
${SCRIPT_DIR}/cluster.neo4j.sh on

View File

@ -14,32 +14,40 @@ fi
KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml} KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml}
case $1 in case $1 in
off) maintenance)
# maintenance mode on case $2 in
${SCRIPT_DIR}/cluster.maintenance.sh on on)
# maintenance mode on
${SCRIPT_DIR}/cluster.maintenance.sh on
# set Neo4j in offline mode (maintenance) # set Neo4j in offline mode (maintenance)
kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \
| jq '.spec.template.spec.containers[] += {"command": ["tail", "-f", "/dev/null"]}' \ | jq '.spec.template.spec.containers[] += {"command": ["tail", "-f", "/dev/null"]}' \
| kubectl --kubeconfig=${KUBECONFIG} apply -f - | kubectl --kubeconfig=${KUBECONFIG} apply -f -
# wait for the container to restart # wait for the container to restart
sleep 60 sleep 60
;; ;;
on) off)
# set Neo4j in online mode # set Neo4j in online mode
kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \
| jq 'del(.spec.template.spec.containers[].command)' \ | jq 'del(.spec.template.spec.containers[].command)' \
| kubectl --kubeconfig=${KUBECONFIG} apply -f - | kubectl --kubeconfig=${KUBECONFIG} apply -f -
# wait for the container to restart # wait for the container to restart
sleep 60 sleep 60
# maintenance mode off # maintenance mode off
${SCRIPT_DIR}/cluster.maintenance.sh 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 either 'off' or 'on'" echo -e "Run this script with first argument 'maintenance'"
exit exit
;; ;;
esac esac