This script is a simple way to restore a kamaji-etcd
datastore from a previou taken snapshot.
It performs the following steps:
- Downloads the
etcd
snapshot specified during script launch. - Populates the
ETCD_INITIAL_CLUSTER
variable with a list of thekamaji-etcd
pods. - Uploads the
etcd
snapshot to everykamaji-etcd
pod. - Restores the snapshot to every
kamaji-etcd
pod using theetcdctl
command.
WARNING: during the operation, the tenant control plane won't be reachable for a solid minute
bash
jq
wget
kubectl
Once you set proper env variables according to your specific setup
# kamaji-etcd namespace
export ETCD_NAMESPACE=solar-energy-lab
# kamaji-etcd sts name
export ETCD_NAME=solar-energy-etcd
# tenant control plane namespace
export TENANT_NAMESPACE=solar-energy-lab
# tenant control plane name
export TENANT_NAME=solar-energy
scale down to zero the tenant control plane pods:
kubectl scale tcp -n ${TENANT_NAMESPACE} ${TENANT_NAME} --replicas=0
run:
./scripts/snapshot-recovery.sh 'https://mys3publicurl.io/tcp-snapshot.db'
The script will provide the health status of the etcd cluster: in case of a positive outcome, scale up the tenant control plane pods to the previous number of replicas:
kubectl scale tcp -n ${TENANT_NAMESPACE} ${TENANT_NAME} --replicas=X
At the beginning of the script, the following line sets the script to run in debug mode if the environment variable DEBUG
is set to 1
:
if [ "${DEBUG}" = 1 ]; then
set -x
fi