OCP ETCD Plugin

The plugin helps the user to perform ETCD backup and restore of OCP clusters.

Introduction to ETCD

ETCD is the persistent data store for Kubernetes. It is a distributed key-value store that records the state of all resources in a Kubernetes cluster and it is simple, fast and secure. It acts like a backend service discovery and database. It runs on different servers in Kubernetes clusters at the same time, which enables it to monitor changes in clusters and store state/configuration data that are to be accessed by a Kubernetes master or clusters.

OCP Cluster Backup & Disaster Recovery (DR)

ETCD data must be backed up before shutting down a cluster. ETCD is the key-value store for OpenShift Container Platform, which persists the state of all resource objects. Subsequently, ETCD backup plays a crucial role in disaster recovery. There are several situations where OpenShift Container Platform does not work as expected, such as:

  • You have a cluster that is not functional following a restart because of unexpected conditions, such as node failure, or network connectivity issues.

  • You have deleted something critical in the cluster by mistake.

  • You have lost the majority of your control plane hosts, leading to ETCD quorum loss.

In disaster situations like above, you can always recover by restoring your cluster to its previous state using the saved ETCD snapshots. Some important considerations to keep in mind about OCP Cluster Backups and DR:

  • Disaster recovery/Restore requires you to have at least one healthy control plane host (also known as the master host). User should run this plugin on bastion node if user wants to perform restore.[Bastion host is the host which is created using same network as the cluster and can ping the nodes of cluster.] More information around bastion node - https://docs.openshift.com/container-platform/4.7/networking/accessing-hosts.html

  • User has to only create bastion node which should be accessed using ssh. This plugin will itself create ssh connectivity from bastion to cluster nodes.

Source of information - https://access.redhat.com/documentation/en-us/openshift_container_platform/4.6/html-single/backup_and_restore/index

ETCD Backup and Restore Using ocp-etcd-backup-restore Plugin

The plugin helps the user to perform ETCD backup and restore of OCP clusters. If a user has lost some crucial cluster information, then they can restore from the snapshot saved using this plugin. If the user has lost nodes, they must recreate all the non-recovery control plane machines and then run '-p' option from this plugin to redeploy ETCD. Some important considerations to keep in mind about the plugin:

  • The plugin supports s3 as backup target

  • Restore functionality will only work on same cluster from where the backup was taken

  • Please do not switch of any node in cluster while restore is in progress and do not abort restore task in between, else you may loose cluster accessibility

Plugin Prerequisites

Prerequisites
  1. krew - kubectl-plugin manager. Install from here.

  2. kubectl - Kubernetes command-line tool. Install from here.

  3. Trilio for Kubernetes and a backup target. Install from here.

  4. oc - Install from here.

  5. Linux or macOS are supported. Windows is not supported at this time.

Installation, Upgrade, Removal of Plugins :

Usage

ETCD Backup and restore on OCP. Available flags: -backup -restore.
   [-h] [-backup] [-restore] [--target-name TARGET_NAME]
   [--target-namespace TARGET_NAMESPACE] --api-server-url API_SERVER_URL
   --ocp-cluster-user OCP_CLUSTER_USER --ocp-cluster-pass OCP_CLUSTER_PASS
   [-p] [--log-location LOG_LOC]

Flags:

Examples:

A user may specify more than one option with each command execution. For example, to create a backup with a configured target name and associated namespace, and to set the cluster API URL with the associated username and password, execute the following single command:

kubectl ocp-etcd-backup-restore -backup --target-name <target_ns> --target-namespace <target_ns> --api-server-url "https://api.<clustername>.<domain>:6443" --ocp-cluster-user <user> --ocp-cluster-pass "<password>"

Then, to restore from the same cluster API URL with the associated username and password, execute the following single command:

kubectl ocp-etcd-backup-restore -restore --api-server-url "https://api.<clustername>.<domain>:6443" --ocp-cluster-user <user> --ocp-cluster-pass "<passwd>"

Restoring to a previous cluster state is a destructive and destabilizing action to take on a running cluster. This procedure should only be used as a last resort.

Important Additional Information

  1. If restoring the backup which is a different T4K version than the one you are currently using, the operation fails and cluster accessibility is lost. The workaround is to delete the current T4K and then re-try restoring.

  2. As per official Red Hat documentation, "Restoring to a previous cluster state is a destructive and destabilizing action to take on a running cluster. This should only be used as a last resort." If you are able to retrieve data using the Kubernetes API server, then ETCD is available and you should not restore using an ETCD backup.

  3. Supported GLIBC version: 2.27 Plugin is tested on OCP versions: 4.8 and 4.9

  4. Please refer to Red Hat's Backing up and restoring your OpenShift Container Platform Cluster for more information.

Last updated