Red Hat OpenShift backing up etcd

etcd is a consistent, open-source and distributed key-value store used in Kubernetes to backing all cluster resources like: configuration data, state data or metadata.
Regular backups of etcd database are crucial habit for Kubernetes clusters. Red Hat OpenShift has build-in mechanism to achieve that.
it’s a good practice to make etcd backup before upgrades or major changes in the cluster.

In this article, I will show you how to manually backup etcd database in Red Hat OpenShift 4.16.10 SNO cluster. The procedure is the same for non-SNO clusters.

If you’re looking how to deploy RH OpenShift on a single bare metal server look HERE

Backing up etcd data

At first, you need to access to the OpenShift cluster, than log in to the desired node.

! IMPORTANT ! Create a backup only from a single control plane host. Do not take a backup from each control plane host in the cluster.

1. Log in to the OpenShift cluster, click in the up right corner kube:admin and Copy login command

2. Click Display Token

3. Copy command from “Log in with this token” and paste to your terminal. You’re logged into the cluster.

4. Type a command oc get nodes to list all running nodes. In my case, single (one) node is available, because this cluster is created in a Single Node configuration.

oc get nodes 

5. Now, start a debug session as root for a control plane node using a command oc debug –as-root node/<node_name>
My node name is rho-sno-01

oc debug --as-root node/rho-sno-01

6. Change your root directory to /host in the debug shell with a command:

chroot /host

7. To start backup etcd task, run cluster-backup.sh script.

/usr/local/bin/cluster-backup.sh /home/core/assets/backup

8. Backup completed!
In the /home/core/assets/backup was created two files:
snapshot_[time_stamp] .db-> this is etcd snapshot;
static_kuberesources_[time_stamp].tar.gz-> this file contains the resources for the static pods.

ls -l /home/core/assets/backup

Creating automated etcd backups

At the moment of writing this post in Red Hat OpenShift 4.16.10 creating automated etcd backups is a Technology Preview feature. It’s not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. And for now, it’s not recommended to use it in a production environment.

In the upcoming posts, I have some plans to test this feature in my lab and map external storage. Store etcd backup data outside the cluster, should be a mandatory in the production environments.

More about Technology Preview Features you can find here: https://access.redhat.com/support/offerings/techpreview/?extIdCarryOver=true&sc_cid=701f2000001OH74AAG

Summary

This is simply how-to create manually etcd backup in the OpenShift. I hope it’s helpful for you.

Keep looking at my blog, new posts are coming! There is so much more great features to explore 😉

Leave a Reply

Your email address will not be published. Required fields are marked *