This guide provides instructions on how to use the restore.sh script to restore a kamaji-etcd datastore from a snapshot.
The script performs the following steps:
- Scales down the
etcdStatefulSet to zero replicas. - Waits for the
etcdpods to be deleted. - Creates a restore job for each
etcdmember (assumes three members) to restore the data from the snapshot. - Waits for each restore job to complete.
- Scales the
etcdStatefulSet back to three replicas.
- Ensure you have
kubectlinstalled and configured to interact with the management cluster. - The snapshot should be taken previously with the
backup.shscript. It is assumed that the snapshot file is stored on an S3-like storage. - A kubernetes secret called
backup-storage-secretcontaining the parameters and credentials to access the storage must be created in the same namespace wherekamaji-etcdis running.
To create the secret, use the following command:
kubectl create secret generic backup-storage-secret \
--from-literal=storage-url=<storage_url> \
--from-literal=storage-access-key=<access_key> \
--from-literal=storage-secret-key=<access_secret> \
--from-literal=storage-bucket-name=<bucket_name> \
--from-literal=storage-bucket-folder=<bucket_folder> \
-n <etcd_namespace>To run the script, use the following command:
./restore.sh [-e etcd_name] [-s etcd_service] [-n etcd_namespace] [-f snapshot]-e etcd_name: Name of the etcd StatefulSet (default:kamaji-etcd)-s etcd_service: Name of the etcd service (default:kamaji-etcd)-n etcd_namespace: Namespace of the etcd StatefulSet (default:kamaji-system)-f snapshot: Snapshot file to restore from (required)
For example:
./restore.sh -e my-etcd -s my-etcd-service -n my-namespace -f snapshot.db- Ensure that the snapshot file is accessible and the necessary secret for accessing the storage is configured in the same namespace.
- The script uses
kubectlcommands, so ensure you have the necessary permissions to perform these operations.
To run the script in debug mode set the environment variable DEBUG:
export DEBUG=1