Chapter 6. Control plane backup and restore
6.1. Backing up and restoring etcd data Copy linkLink copied to clipboard!
You can back up etcd data for your OpenShift Container Platform cluster by manually creating an etcd snapshot and saving static pod resources on a control plane host, or by configuring automated single or recurring backups.
etcd is the key-value store for OpenShift Container Platform, which persists the state of all resource objects.
Back up etcd data for your cluster regularly. Store backups in a secure location, ideally outside the OpenShift Container Platform environment.
Do not take an etcd backup before the first certificate rotation completes. Certificate rotation occurs 24 hours after installation. A backup taken before rotation completes contains expired certificates.
Take etcd backups during non-peak usage hours when possible. The etcd snapshot has a high I/O cost.
Be sure to take an etcd backup before you update your cluster. Taking a backup before you update is important because when you restore your cluster, you must use an etcd backup that was taken from the same z-stream release. For example, an OpenShift Container Platform 4.17.5 cluster must use an etcd backup that was taken from 4.17.5.
Back up etcd data for your cluster by performing a single invocation of the backup script on a control plane host. Do not take a backup for each control plane host.
6.1.1. Backing up etcd data Copy linkLink copied to clipboard!
You can back up etcd data by creating an etcd snapshot and saving the static pod resources on a control plane host. This backup preserves the cluster state and provides the resources required to restore etcd at a later time.
Only save a backup from a single control plane host. Do not take a backup from each control plane host in the cluster.
For a Two-Node with Fencing (TNF) setup, follow the steps to back up etcd data on only one node in the cluster. The cluster restore process is driven by data from a single node, so you can perform the etcd backup steps on only one node.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole. You have verified whether the cluster-wide proxy is enabled.
TipYou can check whether the proxy is enabled by reviewing the output of
oc get proxy cluster -o yaml. The proxy is enabled if thehttpProxy,httpsProxy, andnoProxyfields have values set.
Procedure
Start a debug session as root for a control plane node:
$ oc debug --as-root node/<node_name>Change your root directory to
/hostin the debug shell:sh-4.4# chroot /hostIf the cluster-wide proxy is enabled, export the
NO_PROXY,HTTP_PROXY, andHTTPS_PROXYenvironment variables by running the following commands:$ export HTTP_PROXY=http://<your_proxy.example.com>:8080$ export HTTPS_PROXY=https://<your_proxy.example.com>:8080$ export NO_PROXY=<example.com>Run the
cluster-backup.shscript with the path to the directory where you want to save the backup:TipThe
cluster-backup.shscript is maintained as a component of the etcd Cluster Operator and is a wrapper around theetcdctl snapshot savecommand.sh-4.4# /usr/local/bin/cluster-backup.sh /home/core/assets/backupExample script output
found latest kube-apiserver: /etc/kubernetes/static-pod-resources/kube-apiserver-pod-6 found latest kube-controller-manager: /etc/kubernetes/static-pod-resources/kube-controller-manager-pod-7 found latest kube-scheduler: /etc/kubernetes/static-pod-resources/kube-scheduler-pod-6 found latest etcd: /etc/kubernetes/static-pod-resources/etcd-pod-3 ede95fe6b88b87ba86a03c15e669fb4aa5bf0991c180d3c6895ce72eaade54a1 etcdctl version: 3.4.14 API version: 3.4 {"level":"info","ts":1624647639.0188997,"caller":"snapshot/v3_snapshot.go:119","msg":"created temporary db file","path":"/home/core/assets/backup/snapshot_2021-06-25_190035.db.part"} {"level":"info","ts":"2021-06-25T19:00:39.030Z","caller":"clientv3/maintenance.go:200","msg":"opened snapshot stream; downloading"} {"level":"info","ts":1624647639.0301006,"caller":"snapshot/v3_snapshot.go:127","msg":"fetching snapshot","endpoint":"https://10.0.0.5:2379"} {"level":"info","ts":"2021-06-25T19:00:40.215Z","caller":"clientv3/maintenance.go:208","msg":"completed snapshot read; closing"} {"level":"info","ts":1624647640.6032252,"caller":"snapshot/v3_snapshot.go:142","msg":"fetched snapshot","endpoint":"https://10.0.0.5:2379","size":"114 MB","took":1.584090459} {"level":"info","ts":1624647640.6047094,"caller":"snapshot/v3_snapshot.go:152","msg":"saved","path":"/home/core/assets/backup/snapshot_2021-06-25_190035.db"} Snapshot saved at /home/core/assets/backup/snapshot_2021-06-25_190035.db {"hash":3866667823,"revision":31407,"totalKey":12828,"totalSize":114446336} snapshot db and kube resources are successfully saved to /home/core/assets/backupIn this example, two files are created in the
/home/core/assets/backup/directory on the control plane host:-
snapshot_<datetimestamp>.db: This file is the etcd snapshot. Thecluster-backup.shscript confirms the validity of the snapshot. static_kuberesources_<datetimestamp>.tar.gz: This file contains the resources for the static pods. If etcd encryption is enabled, it also contains the encryption keys for the etcd snapshot.NoteIf etcd encryption is enabled, store this second file separately from the etcd snapshot for security reasons. However, this file is required to restore from the etcd snapshot.
The etcd encryption only encrypts values, not keys. This means that resource types, namespaces, and object names are not encrypted.
-
6.1.3. Creating automated etcd backups Copy linkLink copied to clipboard!
You can enable automated etcd backups for your cluster by applying a FeatureGate and backup custom resources (CRs).
Automating etcd backups is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
Enabling the TechPreviewNoUpgrade feature set on your cluster prevents minor version updates. The TechPreviewNoUpgrade feature set cannot be disabled. Do not enable this feature set on production clusters.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have access to the OpenShift CLI (
oc).
Procedure
Create a
FeatureGatecustom resource (CR) file namedenable-tech-preview-no-upgrade.yamlwith the following contents:apiVersion: config.openshift.io/v1 kind: FeatureGate metadata: name: cluster spec: featureSet: TechPreviewNoUpgradeApply the CR by running the following command:
$ oc apply -f enable-tech-preview-no-upgrade.yamlApplying the
FeatureGateenables the automated backup APIs. It takes time for the related APIs to become available.Verify that the custom resource definition (CRD) was created by running the following command:
$ oc get crd | grep backupExample output
backups.config.openshift.io 2023-10-25T13:32:43Z etcdbackups.operator.openshift.io 2023-10-25T13:32:04Z
6.1.3.1. Creating a single automated etcd backup Copy linkLink copied to clipboard!
You can create a single automated etcd backup by applying an EtcdBackup custom resource (CR). Backup data is stored on either dynamically-provisioned or local storage.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have access to the OpenShift CLI (
oc).
Procedure
If dynamically-provisioned storage is available, complete the following steps to create a single automated etcd backup:
Create a persistent volume claim (PVC) named
etcd-backup-pvc.yamlwith contents such as the following example:kind: PersistentVolumeClaim apiVersion: v1 metadata: name: etcd-backup-pvc namespace: openshift-etcd spec: accessModes: - ReadWriteOnce resources: requests: storage: <storage_amount> volumeMode: Filesystemwhere:
<storage_amount>-
Specifies the amount of storage available to the PVC. Adjust this value for your requirements, such as
200Gi.
Apply the PVC by running the following command:
$ oc apply -f etcd-backup-pvc.yamlVerify that the PVC was created by running the following command:
$ oc get pvcExample output
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE etcd-backup-pvc Bound 51sNoteDynamic PVCs stay in the
Pendingstate until they are mounted.Create a CR file named
etcd-single-backup.yamlwith contents such as the following example:apiVersion: operator.openshift.io/v1alpha1 kind: EtcdBackup metadata: name: etcd-single-backup namespace: openshift-etcd spec: pvcName: <pvc_name>where:
<pvc_name>-
Specifies the name of the PVC to save the backup to. Adjust this value according to your environment, such as
etcd-backup-pvc.
Apply the CR to start a single backup by running the following command:
$ oc apply -f etcd-single-backup.yaml
If dynamically-provisioned storage is not available, complete the following steps to create a single automated etcd backup:
Create a
StorageClassCR file namedetcd-backup-local-storage.yamlwith the following contents:apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: etcd-backup-local-storage provisioner: kubernetes.io/no-provisioner volumeBindingMode: ImmediateApply the
StorageClassCR by running the following command:$ oc apply -f etcd-backup-local-storage.yamlCreate a PV named
etcd-backup-pv-fs.yamlwith contents such as the following example:apiVersion: v1 kind: PersistentVolume metadata: name: etcd-backup-pv-fs spec: capacity: storage: <storage_amount> volumeMode: Filesystem accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Retain storageClassName: etcd-backup-local-storage local: path: /mnt nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - <node_name>where:
<storage_amount>-
Specifies the amount of storage available to the PV. Adjust this value for your requirements, such as
100Gi. <node_name>- Specifies the control plane node to attach this PV to. Replace with the actual node name.
Verify that the PV was created by running the following command:
$ oc get pvExample output
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE etcd-backup-pv-fs 100Gi RWO Retain Available etcd-backup-local-storage 10sCreate a PVC named
etcd-backup-pvc.yamlwith contents such as the following example:kind: PersistentVolumeClaim apiVersion: v1 metadata: name: etcd-backup-pvc namespace: openshift-etcd spec: accessModes: - ReadWriteOnce volumeMode: Filesystem resources: requests: storage: <storage_amount>where:
<storage_amount>-
Specifies the amount of storage available to the PVC. Adjust this value for your requirements, such as
10Gi.
Apply the PVC by running the following command:
$ oc apply -f etcd-backup-pvc.yamlCreate a CR file named
etcd-single-backup.yamlwith contents such as the following example:apiVersion: operator.openshift.io/v1alpha1 kind: EtcdBackup metadata: name: etcd-single-backup namespace: openshift-etcd spec: pvcName: <pvc_name>where:
<pvc_name>-
Specifies the name of the PVC to save the backup to. Adjust this value according to your environment, such as
etcd-backup-pvc.
Apply the CR to start a single backup by running the following command:
$ oc apply -f etcd-single-backup.yaml
6.1.3.2. Creating recurring automated etcd backups Copy linkLink copied to clipboard!
You can create recurring automated etcd backups by applying a custom resource (CR) that defines a backup schedule and retention policy. Backup data is stored on either dynamically-provisioned or local storage.
Use dynamically-provisioned storage to keep the created etcd backup data in a safe, external location if possible. If dynamically-provisioned storage is not available, consider storing the backup data on an NFS share to make backup recovery more accessible.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have access to the OpenShift CLI (
oc).
Procedure
If dynamically-provisioned storage is available, complete the following steps to create automated recurring backups:
Create a persistent volume claim (PVC) named
etcd-backup-pvc.yamlwith contents such as the following example:kind: PersistentVolumeClaim apiVersion: v1 metadata: name: etcd-backup-pvc namespace: openshift-etcd spec: accessModes: - ReadWriteOnce resources: requests: storage: 200Gi volumeMode: Filesystem storageClassName: etcd-backup-local-storagewhere:
spec.resources.requests.storageSpecifies the amount of storage available to the PVC. Adjust this value for your requirements.
NoteEach of the following providers requires changes to the
accessModesandstorageClassNamekeys:Provider accessModesvaluestorageClassNamevalueAWS with the
versioned-installer-efc_operator-ciprofile- ReadWriteManyefs-scGoogle Cloud
- ReadWriteManyfilestore-csiMicrosoft Azure
- ReadWriteManyazurefile-csi
Apply the PVC by running the following command:
$ oc apply -f etcd-backup-pvc.yamlVerify that the PVC was created by running the following command:
$ oc get pvcExample output
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE etcd-backup-pvc Bound 51sNoteDynamic PVCs stay in the
Pendingstate until they are mounted.
If dynamically-provisioned storage is unavailable, create a local storage PVC by completing the following steps:
WarningIf you delete or otherwise lose access to the node that contains the stored backup data, you can lose data.
Create a
StorageClassCR file namedetcd-backup-local-storage.yamlwith the following contents:apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: etcd-backup-local-storage provisioner: kubernetes.io/no-provisioner volumeBindingMode: ImmediateApply the
StorageClassCR by running the following command:$ oc apply -f etcd-backup-local-storage.yamlCreate a PV named
etcd-backup-pv-fs.yamlfrom the appliedStorageClasswith contents such as the following example:apiVersion: v1 kind: PersistentVolume metadata: name: etcd-backup-pv-fs spec: capacity: storage: 100Gi volumeMode: Filesystem accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Delete storageClassName: etcd-backup-local-storage local: path: /mnt/ nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - <example_control_plane_node>where:
spec.capacity.storage- Specifies the amount of storage available to the PV. Adjust this value for your requirements.
spec.nodeAffinity.required.nodeSelectorTerms.matchExpressions.valuesSpecifies the control plane node to attach this PV to. Replace with the actual node name.
TipList the available nodes by running the following command:
$ oc get nodes
Verify that the PV was created by running the following command:
$ oc get pvExample output
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE etcd-backup-pv-fs 100Gi RWX Delete Available etcd-backup-local-storage 10sCreate a PVC named
etcd-backup-pvc.yamlwith contents such as the following example:kind: PersistentVolumeClaim apiVersion: v1 metadata: name: etcd-backup-pvc spec: accessModes: - ReadWriteMany volumeMode: Filesystem resources: requests: storage: 10Gi storageClassName: etcd-backup-local-storagewhere:
spec.resources.requests.storage- Specifies the amount of storage available to the PVC. Adjust this value for your requirements.
Apply the PVC by running the following command:
$ oc apply -f etcd-backup-pvc.yaml
Create a CR file named
etcd-recurring-backups.yaml. The contents of the CR define the schedule and retention type of automated backups.For the default retention type of
RetentionNumberwith 15 retained backups, use contents such as the following example:apiVersion: config.openshift.io/v1alpha1 kind: Backup metadata: name: etcd-recurring-backup spec: etcd: schedule: "20 4 * * *" timeZone: "UTC" pvcName: etcd-backup-pvcwhere:
spec.etcd.scheduleSpecifies the
CronTabschedule for recurring backups. Adjust this value for your needs.To use retention based on the maximum number of backups, add the following key-value pairs to the
etcdkey:spec: etcd: retentionPolicy: retentionType: RetentionNumber retentionNumber: maxNumberOfBackups: 5where:
spec.etcd.retentionPolicy.retentionType-
Specifies the retention type. Defaults to
RetentionNumberif unspecified. spec.etcd.retentionPolicy.retentionNumber.maxNumberOfBackupsSpecifies the maximum number of backups to retain. Adjust this value for your needs. Defaults to 15 backups if unspecified.
WarningA known issue causes the number of retained backups to be one greater than the configured value.
For retention based on the file size of backups, use the following:
spec: etcd: retentionPolicy: retentionType: RetentionSize retentionSize: maxSizeOfBackupsGb: 20where:
spec.etcd.retentionPolicy.retentionSize.maxSizeOfBackupsGbSpecifies the maximum file size of the retained backups in gigabytes. Adjust this value for your needs. Defaults to 10 GB if unspecified.
WarningA known issue causes the maximum size of retained backups to be up to 10 GB greater than the configured value.
Create the cron job defined by the CRD by running the following command:
$ oc create -f etcd-recurring-backup.yamlTo find the created cron job, run the following command:
$ oc get cronjob -n openshift-etcd
6.2. Replacing a healthy etcd member Copy linkLink copied to clipboard!
You might need to replace a healthy etcd member for planned hardware maintenance, hardware upgrades, or migration to new infrastructure.
6.2.1. About replacing a healthy etcd member Copy linkLink copied to clipboard!
To replace a control plane node without disrupting etcd, remove a healthy member and add a replacement while the cluster remains operational. The procedure you follow depends on how your cluster was installed and whether it uses the Machine API and a control plane machine set.
If the etcd member is unhealthy because the machine is not running, the node is not ready, or the etcd pod is crashlooping, see "Replacing an unhealthy etcd member".
If you have lost the majority of your control plane hosts, see "Restoring to an earlier cluster state".
6.2.2. Replacing a healthy etcd member Copy linkLink copied to clipboard!
To replace a healthy etcd member without disrupting cluster operations, choose the procedure that matches your control plane configuration. You can use a control plane machine set, the Machine API, or scale up and scale down control plane nodes.
Take an etcd backup before you replace a healthy etcd member so that you can restore your cluster if any issues occur. For more information, see "Backing up etcd data".
Depending on your cluster configuration, use one of the following procedures:
- Replacing a healthy etcd member with a control plane machine set
- Replacing a healthy etcd member with the Machine API
- Replacing a healthy etcd member by scaling up and scaling down
For clusters that were installed by using the Assisted Installer, see "Replacing a control plane node in a healthy cluster" in the Assisted Installer documentation.
6.2.3. Determining how to replace a healthy etcd member Copy linkLink copied to clipboard!
To choose the correct procedure for replacing a healthy etcd member, check whether your cluster uses the Assisted Installer, a control plane machine set, or the Machine API. Use the OpenShift CLI (oc) to identify your cluster configuration and follow the matching replacement procedure.
Prerequisites
-
You installed the OpenShift CLI (
oc). -
You logged in to
ocas a user with thecluster-adminrole.
Procedure
Check whether the cluster was installed by using the Assisted Installer by running the following command:
$ oc get agentclusterinstall -A-
If the command returns one or more
AgentClusterInstallresources, follow the procedure in "Replacing a control plane node in a healthy cluster" in the Assisted Installer documentation. - If the command returns no resources, continue with the following steps.
-
If the command returns one or more
Check whether the cluster has a control plane machine set by running the following command:
$ oc -n openshift-machine-api get controlplanemachineset-
If the command returns a
ControlPlaneMachineSetresource, follow the procedure in "Replacing a healthy etcd member with a control plane machine set". - If the command returns no resources, continue to the next step.
-
If the command returns a
Check whether the cluster has control plane
Machineobjects by running the following command:$ oc get machines -l machine.openshift.io/cluster-api-machine-role=master -n openshift-machine-api-
If
Machineobjects exist, follow the procedure in "Replacing a healthy etcd member with the Machine API". -
If there are no
Machineobjects, follow the procedure in "Replacing a healthy etcd member by scaling up and scaling down".
-
If
6.2.4. Replacing a healthy etcd member with a control plane machine set Copy linkLink copied to clipboard!
On clusters that use a control plane machine set, you can replace a healthy control plane machine by deleting the corresponding Machine object.
The control plane machine set creates a replacement machine, and the etcd Operator uses machine lifecycle hooks to protect etcd quorum during the replacement.
For more information about how quorum protection works during control plane machine deletion, see "Quorum protection with machine lifecycle hooks".
Prerequisites
-
The cluster has a
ControlPlaneMachineSetresource. -
You have access to the cluster as a user with the
cluster-adminrole. You have taken an etcd backup. For more information, see "Backing up etcd data".
ImportantTake an etcd backup before you replace a healthy etcd member so that you can restore your cluster if any issues occur.
Procedure
List the control plane machines in your cluster by running the following command:
$ oc get machines \ -l machine.openshift.io/cluster-api-machine-role=master \ -n openshift-machine-api- Identify the control plane machine that corresponds to the node that you want to replace.
Optional. If you are performing planned maintenance, cordon the node by running the following command:
$ oc adm cordon <node_name>Replace
<node_name>with the name of the node that you are replacing.ImportantDelete only one control plane machine at a time. Deleting multiple control plane machines at the same time can cause etcd quorum loss.
Delete the control plane machine by running the following command:
$ oc delete machine <control_plane_machine_name> -n openshift-machine-apiReplace
<control_plane_machine_name>with the name of the control plane machine to delete.NoteIf you delete multiple control plane machines, the control plane machine set replaces them according to the configured update strategy:
-
For clusters that use the default
RollingUpdateupdate strategy, the Operator replaces one machine at a time until each machine is replaced. -
For clusters that are configured to use the
OnDeleteupdate strategy, the Operator creates all of the required replacement machines simultaneously.
Both strategies maintain etcd health during control plane machine replacement.
-
For clusters that use the default
Monitor the replacement by running the following commands:
Verify that a new control plane machine is created:
$ oc get machines \ -l machine.openshift.io/cluster-api-machine-role=master \ -n openshift-machine-api -o wideVerify that the etcd cluster Operator reports
Available=TrueandDegraded=False:$ oc get clusteroperator etcdNoteDuring the replacement
Progressing=Trueis expected and transitions toFalseonce the new member is fully reconciled.Verify that all control plane nodes are in the
Readystate:$ oc get nodes -l node-role.kubernetes.io/control-plane
Verification
Verify etcd health by running the following commands:
Open a remote shell session to a control plane etcd pod:
$ oc rsh -n openshift-etcd <etcd_pod_name>Replace
<etcd_pod_name>with the name of a running etcd pod.Check endpoint health:
sh-4.2# etcdctl endpoint healthExpected output shows
is healthyfor each endpoint.List etcd members and verify that the cluster has three members:
sh-4.2# etcdctl member list -w table
Verify that all cluster Operators are available by running the following command:
$ oc get clusteroperators
6.2.5. Replacing a healthy etcd member with the Machine API Copy linkLink copied to clipboard!
On clusters that access the Machine API but do not use a control plane machine set, you can replace a healthy control plane machine by deleting the corresponding Machine object. The Machine API provisions a replacement machine, and the etcd cluster Operator adds the new node as an etcd member.
Prerequisites
- The cluster has access to the Machine API.
-
The cluster does not have a
ControlPlaneMachineSetresource. -
You have access to the cluster as a user with the
cluster-adminrole. You have taken an etcd backup. For more information, see "Backing up etcd data".
ImportantTake an etcd backup before you replace a healthy etcd member so that you can restore your cluster if any issues occur.
Procedure
List the control plane machines in your cluster by running the following command:
$ oc get machines \ -l machine.openshift.io/cluster-api-machine-role=master \ -n openshift-machine-api -o wide- Identify the control plane machine that corresponds to the node that you want to replace.
Optional. If you are performing planned maintenance, cordon the node by running the following command:
$ oc adm cordon <node_name>Replace
<node_name>with the name of the node that you are replacing.Delete the control plane machine by running the following command:
$ oc delete machine <control_plane_machine_name> -n openshift-machine-apiReplace
<control_plane_machine_name>with the name of the control plane machine to delete.ImportantDelete only one control plane machine at a time. Deleting multiple control plane machines at the same time can cause etcd quorum loss.
A new machine is automatically provisioned after you delete the control plane machine.
Monitor the replacement by running the following commands until the new machine reaches the
Runningphase:$ oc get machines \ -l machine.openshift.io/cluster-api-machine-role=master \ -n openshift-machine-api -o wide$ oc get clusteroperator etcd$ oc get nodes -l node-role.kubernetes.io/control-plane
Verification
Verify etcd health by running the following commands:
Open a remote shell session to a control plane etcd pod:
$ oc rsh -n openshift-etcd <etcd_pod_name>Replace
<etcd_pod_name>with the name of a running etcd pod.Check endpoint health:
sh-4.2# etcdctl endpoint healthExpected output shows
is healthyfor each endpoint.List etcd members and verify that the cluster has three members:
sh-4.2# etcdctl member list -w table
Verify that all cluster Operators are available by running the following command:
$ oc get clusteroperators
6.2.6. Replacing a healthy etcd member by scaling up and scaling down Copy linkLink copied to clipboard!
On bare-metal clusters that do not use a control plane machine set, replace a healthy control plane node by temporarily scaling the control plane to four nodes, and then removing the node that you want to replace.
Red Hat supports a cluster that has 4 or 5 control plane nodes only on bare-metal infrastructure.
Prerequisites
-
The cluster does not have a
ControlPlaneMachineSetresource. - The cluster is installed on bare-metal infrastructure.
-
You have access to the cluster as a user with the
cluster-adminrole. - You have taken an etcd backup. For more information, see "Backing up etcd data".
You have created a single control plane node that you intend to add to your cluster as a postinstallation task.
ImportantTake an etcd backup before you replace a healthy etcd member so that you can restore your cluster if any issues occur.
Procedure
- Add the new control plane node to your cluster by following the steps in "Adding a control plane node to your cluster".
Verify that the new control plane node is in the
Readystate and that etcd has four members by running the following commands:$ oc get nodes -l node-role.kubernetes.io/control-plane$ oc rsh -n openshift-etcd <etcd_pod_name>Replace
<etcd_pod_name>with the name of a running etcd pod.sh-4.2# etcdctl member list -w tablesh-4.2# etcdctl endpoint healthExpected output shows four etcd members and
is healthyfor each endpoint.Remove the control plane node that you want to replace.
Optional. If you are performing planned maintenance, cordon the node by running the following command:
$ oc adm cordon <node_name>Replace
<node_name>with the name of the node that you are replacing.Delete the
BareMetalHostobject for the control plane node that you want to replace by running the following command:$ oc delete bmh <node_name> -n openshift-machine-apiReplace
<node_name>with the name of the node that you are replacing.Delete the
Machineobject for the control plane node that you want to replace by running the following command:$ oc delete machine <machine_name> -n openshift-machine-apiReplace
<machine_name>with the name of the machine that is associated with the node that you are replacing.NoteAfter you remove the
BareMetalHostandMachineobjects, the machine controller automatically deletes theNodeobject.
Monitor the cluster until the control plane returns to three nodes and etcd is healthy by running the following commands:
$ oc get nodes -l node-role.kubernetes.io/control-plane$ oc get clusteroperator etcd
Verification
Verify etcd health by running the following commands:
Open a remote shell session to a control plane etcd pod:
$ oc rsh -n openshift-etcd <etcd_pod_name>Check endpoint health:
sh-4.2# etcdctl endpoint healthExpected output shows
is healthyfor each endpoint.List etcd members and verify that the cluster has three members:
sh-4.2# etcdctl member list -w table
Verify that all cluster Operators are available by running the following command:
$ oc get clusteroperators
6.3. Replacing an unhealthy etcd member Copy linkLink copied to clipboard!
To restore etcd quorum when a single member is unhealthy, identify the member and determine whether its machine is stopped, its node is not ready, or its pod is crashlooping. You can then follow the replacement procedure that matches that state.
If you have lost the majority of your control plane hosts, follow the steps in "Restoring to an earlier cluster state" instead of this procedure.
If the control plane certificates are not valid on the member being replaced, then you must follow the steps in "Recovering from expired control plane certificates" instead of this procedure.
If a control plane node is lost and a new one is created, the etcd cluster Operator handles generating the new TLS certificates and adding the node as an etcd member.
Take an etcd backup before replacing an unhealthy etcd member. For more information see, "Backing up etcd data".
6.3.1. Identifying an unhealthy etcd member Copy linkLink copied to clipboard!
You can identify an unhealthy etcd member by checking the EtcdMembersAvailable status condition to see how many members are available and which member is unhealthy.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole. - You created an etcd backup.
Procedure
Check the status of the
EtcdMembersAvailablestatus condition by running the following command:$ oc get etcd -o=jsonpath='{range .items[0].status.conditions[?(@.type=="EtcdMembersAvailable")]}{.message}{"\n"}{end}'Example output
2 of 3 members are available, ip-10-0-131-183.ec2.internal is unhealthy
6.3.2. Determining the state of the unhealthy etcd member Copy linkLink copied to clipboard!
Determine whether the unhealthy etcd member has a stopped machine, an unready node, or a crashlooping etcd pod. Knowing the failure state enables you to follow the correct replacement procedure.
Depending on the state of your unhealthy etcd member, use one of the following procedures:
- Machine not running or node not ready. For more information, see "Replacing an unhealthy etcd member whose machine is not running or whose node is not ready".
- Bare-metal machine not running or node not ready on installer-provisioned bare metal. For more information, see "Replacing an unhealthy bare metal etcd member whose machine is not running or whose node is not ready".
- Crashlooping etcd pod. For more information, see "Replacing an unhealthy etcd member whose etcd pod is crashlooping".
If the machine is not running or the node is not ready, you might expect either to recover soon. In that case, you do not need to replace the etcd member. The etcd cluster Operator automatically syncs when the machine or node returns to a healthy state.
Prerequisites
-
You confirmed access to the cluster as a user with the
cluster-adminrole. - You identified an unhealthy etcd member.
Procedure
Determine if the machine is not running by running the following command:
$ oc get machines -A -ojsonpath='{range .items[*]}{@.status.nodeRef.name}{"\t"}{@.status.providerStatus.instanceState}{"\n"}' | grep -v runningExample output
ip-10-0-131-183.ec2.internal stoppedThis output lists the node and the status of the machine of the node. If the status is anything other than
running, then the machine is not running.Determine if the status of the node is
NotReady.If either of the following scenarios are true, then the node is not ready.
If the machine is running, then check whether the node has an
unreachabletaint by running the following command:$ oc get nodes -o jsonpath='{range .items[*]}{"\n"}{.metadata.name}{"\t"}{range .spec.taints[*]}{.key}{" "}' | grep unreachableExample output
ip-10-0-131-183.ec2.internal node-role.kubernetes.io/master node.kubernetes.io/unreachable node.kubernetes.io/unreachableIf the node is listed with an
unreachabletaint, then the node is not ready.If the node is still reachable, then check whether the node is listed as
NotReadyby running the following command:$ oc get nodes -l node-role.kubernetes.io/master | grep "NotReady"Example output
ip-10-0-131-183.ec2.internal NotReady master 122m v1.35.4If the node is listed as
NotReady, then the node is not ready.If the node is not ready, then follow the "Replacing an unhealthy etcd member whose machine is not running or whose node is not ready" procedure.
Determine if the etcd pod is crashlooping.
If the machine is running and the node status is
Ready, check the status of the etcd pod.Verify that all control plane nodes are listed as
Readyby running the following command:$ oc get nodes -l node-role.kubernetes.io/masterExample output
NAME STATUS ROLES AGE VERSION ip-10-0-131-183.ec2.internal Ready master 6h13m v1.35.4 ip-10-0-164-97.ec2.internal Ready master 6h13m v1.35.4 ip-10-0-154-204.ec2.internal Ready master 6h13m v1.35.4Check whether the status of an etcd pod is either
ErrororCrashloopBackoffby running the following command:$ oc -n openshift-etcd get pods -l k8s-app=etcdExample output
etcd-ip-10-0-131-183.ec2.internal 2/3 Error 7 6h9m etcd-ip-10-0-164-97.ec2.internal 3/3 Running 0 6h6m etcd-ip-10-0-154-204.ec2.internal 3/3 Running 0 6h6mThe etcd pod crashloops because the
etcd-ip-10-0-131-183.ec2.internalisError.If the etcd pod is crashlooping, then follow the steps in "Replacing an unhealthy etcd member whose etcd pod is crashlooping".
6.3.3. Replacing the unhealthy etcd member Copy linkLink copied to clipboard!
You can replace an unhealthy etcd member by following one of several procedures, depending on whether the machine is not running, the node is not ready, the etcd pod is crashlooping, or the member is a stopped bare-metal instance.
Use one of the following procedures, based on the state of your unhealthy etcd member:
6.3.3.1. Replacing an unhealthy etcd member whose machine is not running or whose node is not ready Copy linkLink copied to clipboard!
Replace an unhealthy etcd member when the member machine is stopped or the node is not ready. Restoring the member returns the control plane to a healthy state.
If your cluster uses a control plane machine set, see "Recovering a degraded etcd Operator" in "Troubleshooting the control plane machine set" for an etcd recovery procedure.
Prerequisites
- You identified the unhealthy etcd member.
- You verified that either the machine is not running or the node is not ready.
- Do not power on other control plane nodes until the unhealthy etcd member replacement is complete.
-
You confirmed access to the cluster as a user with the
cluster-adminrole. You created an etcd backup before replacing the unhealthy etcd member.
ImportantWithout a recent etcd backup, you might not be able to restore the cluster if replacement fails.
Procedure
Remove the unhealthy member.
List etcd pods and choose one that is not on the affected node by running the following command:
$ oc -n openshift-etcd get pods -l k8s-app=etcdExample output
etcd-ip-10-0-131-183.ec2.internal 3/3 Running 0 123m etcd-ip-10-0-164-97.ec2.internal 3/3 Running 0 123m etcd-ip-10-0-154-204.ec2.internal 3/3 Running 0 124mFrom the output, note a pod that is not on the affected node. In this example, the unhealthy member is
ip-10-0-131-183.ec2.internal, so you could useetcd-ip-10-0-154-204.ec2.internal.Connect to the running etcd container on the pod you chose by running the following command:
$ oc rsh -n openshift-etcd etcd-ip-10-0-154-204.ec2.internalView the member list by running the following command:
sh-4.2# etcdctl member list -w tableExample output
+------------------+---------+------------------------------+---------------------------+---------------------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | +------------------+---------+------------------------------+---------------------------+---------------------------+ | 6fc1e7c9db35841d | started | ip-10-0-131-183.ec2.internal | https://10.0.131.183:2380 | https://10.0.131.183:2379 | | 757b6793e2408b6c | started | ip-10-0-164-97.ec2.internal | https://10.0.164.97:2380 | https://10.0.164.97:2379 | | ca8c2990a0aa29d1 | started | ip-10-0-154-204.ec2.internal | https://10.0.154.204:2380 | https://10.0.154.204:2379 | +------------------+---------+------------------------------+---------------------------+---------------------------+Take note of the ID and the name of the unhealthy etcd member because you need these values later in the procedure. The
etcdctl endpoint healthcommand continues to list the removed member until replacement is complete and a new member is added.Remove the unhealthy etcd member by providing the ID to the
etcdctl member removecommand by running the following command:sh-4.2# etcdctl member remove <etcd_member_id>Example output
Member 6fc1e7c9db35841d removed from cluster ead669ce1fbfb346View the member list again and verify that the member was removed by running the following command:
sh-4.2# etcdctl member list -w tableExample output
+------------------+---------+------------------------------+---------------------------+---------------------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | +------------------+---------+------------------------------+---------------------------+---------------------------+ | 757b6793e2408b6c | started | ip-10-0-164-97.ec2.internal | https://10.0.164.97:2380 | https://10.0.164.97:2379 | | ca8c2990a0aa29d1 | started | ip-10-0-154-204.ec2.internal | https://10.0.154.204:2380 | https://10.0.154.204:2379 | +------------------+---------+------------------------------+---------------------------+---------------------------+You can now exit the node shell.
Turn off the quorum guard by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": {"useUnsupportedUnsafeNonHANonProductionUnstableEtcd": true}}}'This command ensures that you can successfully re-create secrets and roll out the static pods.
ImportantAfter you turn off the quorum guard, the cluster might be unreachable for a short period of time while the remaining etcd instances reboot to reflect the configuration change.
Noteetcd cannot tolerate any additional member failure when running with two members. Restarting either remaining member breaks the quorum and causes downtime in your cluster. The quorum guard protects etcd from restarts due to configuration changes that could cause downtime, so it must be disabled to complete this procedure.
Delete the affected node by running the following command:
$ oc delete node <node_name>Example command
$ oc delete node ip-10-0-131-183.ec2.internalRemove the old secrets for the unhealthy etcd member that was removed.
List the secrets for the unhealthy etcd member that was removed by running the following command:
$ oc get secrets -n openshift-etcd | grep ip-10-0-131-183.ec2.internalReplace
ip-10-0-131-183.ec2.internalin the command with the name of the unhealthy etcd member that you noted earlier in this procedure.There is a peer, serving, and metrics secret as shown in the following output:
Example output
etcd-peer-ip-10-0-131-183.ec2.internal kubernetes.io/tls 2 47m etcd-serving-ip-10-0-131-183.ec2.internal kubernetes.io/tls 2 47m etcd-serving-metrics-ip-10-0-131-183.ec2.internal kubernetes.io/tls 2 47mDelete the peer secret by running the following command:
$ oc delete secret -n openshift-etcd etcd-peer-ip-10-0-131-183.ec2.internalDelete the serving secret by running the following command:
$ oc delete secret -n openshift-etcd etcd-serving-ip-10-0-131-183.ec2.internalDelete the metrics secret by running the following command:
$ oc delete secret -n openshift-etcd etcd-serving-metrics-ip-10-0-131-183.ec2.internal
Check whether a control plane machine set exists by running the following command:
$ oc -n openshift-machine-api get controlplanemachinesetIf the control plane machine set exists, delete and re-create the control plane machine. After this machine is re-created, a new revision is forced and etcd scales up automatically. For more information, see "Replacing an unhealthy etcd member whose machine is not running or whose node is not ready".
If you are running installer-provisioned infrastructure, or you used the Machine API to create your machines, follow these steps. Otherwise, you must create the new control plane by using the same method that was used to originally create it.
Obtain the machine for the unhealthy member by running the following command.
$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE clustername-8qw5l-master-0 Running m4.xlarge us-east-1 us-east-1a 3h37m ip-10-0-131-183.ec2.internal aws:///us-east-1a/i-0ec2782f8287dfb7e stopped clustername-8qw5l-master-1 Running m4.xlarge us-east-1 us-east-1b 3h37m ip-10-0-154-204.ec2.internal aws:///us-east-1b/i-096c349b700a19631 running clustername-8qw5l-master-2 Running m4.xlarge us-east-1 us-east-1c 3h37m ip-10-0-164-97.ec2.internal aws:///us-east-1c/i-02626f1dba9ed5bba running clustername-8qw5l-worker-us-east-1a-wbtgd Running m4.large us-east-1 us-east-1a 3h28m ip-10-0-129-226.ec2.internal aws:///us-east-1a/i-010ef6279b4662ced running clustername-8qw5l-worker-us-east-1b-lrdxb Running m4.large us-east-1 us-east-1b 3h28m ip-10-0-144-248.ec2.internal aws:///us-east-1b/i-0cb45ac45a166173b running clustername-8qw5l-worker-us-east-1c-pkg26 Running m4.large us-east-1 us-east-1c 3h28m ip-10-0-170-181.ec2.internal aws:///us-east-1c/i-06861c00007751b0a runningIn the example output,
clustername-8qw5l-master-0is the control plane machine for the unhealthy nodeip-10-0-131-183.ec2.internal. ItsSTATEisstopped.Delete the machine of the unhealthy member by running the following command:
$ oc delete machine -n openshift-machine-api clustername-8qw5l-master-0Replace
clustername-8qw5l-master-0with the name of the control plane machine for the unhealthy node.A new machine is automatically provisioned after deleting the machine of the unhealthy member.
Verify that a new machine was created by running the following command:
$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE clustername-8qw5l-master-1 Running m4.xlarge us-east-1 us-east-1b 3h37m ip-10-0-154-204.ec2.internal aws:///us-east-1b/i-096c349b700a19631 running clustername-8qw5l-master-2 Running m4.xlarge us-east-1 us-east-1c 3h37m ip-10-0-164-97.ec2.internal aws:///us-east-1c/i-02626f1dba9ed5bba running clustername-8qw5l-master-3 Provisioning m4.xlarge us-east-1 us-east-1a 85s ip-10-0-133-53.ec2.internal aws:///us-east-1a/i-015b0888fe17bc2c8 running clustername-8qw5l-worker-us-east-1a-wbtgd Running m4.large us-east-1 us-east-1a 3h28m ip-10-0-129-226.ec2.internal aws:///us-east-1a/i-010ef6279b4662ced running clustername-8qw5l-worker-us-east-1b-lrdxb Running m4.large us-east-1 us-east-1b 3h28m ip-10-0-144-248.ec2.internal aws:///us-east-1b/i-0cb45ac45a166173b running clustername-8qw5l-worker-us-east-1c-pkg26 Running m4.large us-east-1 us-east-1c 3h28m ip-10-0-170-181.ec2.internal aws:///us-east-1c/i-06861c00007751b0a runningIn the example output,
clustername-8qw5l-master-3is the new control plane machine. The machine is ready when thePHASEchanges fromProvisioningtoRunning.It might take a few minutes for the new machine to be created. The etcd cluster Operator automatically syncs when the machine or node returns to a healthy state.
NoteVerify the subnet IDs that you are using for your machine sets to ensure that they end up in the correct availability zone.
If the control plane machine set does not exist, delete and re-create the control plane machine. After this machine is re-created, a new revision is forced and etcd scales up automatically.
If you are running installer-provisioned infrastructure, or you used the Machine API to create your machines, follow these steps. Otherwise, you must create the new control plane by using the same method that was used to originally create it.
Obtain the machine for the unhealthy member by running the following command:
$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE clustername-8qw5l-master-0 Running m4.xlarge us-east-1 us-east-1a 3h37m ip-10-0-131-183.ec2.internal aws:///us-east-1a/i-0ec2782f8287dfb7e stopped clustername-8qw5l-master-1 Running m4.xlarge us-east-1 us-east-1b 3h37m ip-10-0-154-204.ec2.internal aws:///us-east-1b/i-096c349b700a19631 running clustername-8qw5l-master-2 Running m4.xlarge us-east-1 us-east-1c 3h37m ip-10-0-164-97.ec2.internal aws:///us-east-1c/i-02626f1dba9ed5bba running clustername-8qw5l-worker-us-east-1a-wbtgd Running m4.large us-east-1 us-east-1a 3h28m ip-10-0-129-226.ec2.internal aws:///us-east-1a/i-010ef6279b4662ced running clustername-8qw5l-worker-us-east-1b-lrdxb Running m4.large us-east-1 us-east-1b 3h28m ip-10-0-144-248.ec2.internal aws:///us-east-1b/i-0cb45ac45a166173b running clustername-8qw5l-worker-us-east-1c-pkg26 Running m4.large us-east-1 us-east-1c 3h28m ip-10-0-170-181.ec2.internal aws:///us-east-1c/i-06861c00007751b0a runningIn the example output,
clustername-8qw5l-master-0is the control plane machine for the unhealthy nodeip-10-0-131-183.ec2.internal. ItsSTATEisstopped.Save the machine configuration to a file on your file system by running the following command:
$ oc get machine clustername-8qw5l-master-0 \ -n openshift-machine-api \ -o yaml \ > new-master-machine.yamlReplace
clustername-8qw5l-master-0with the name of the control plane machine for the unhealthy node.
Edit the
new-master-machine.yamlfile that was created in the previous step to assign a new name and remove unnecessary fields:Remove the entire
statussection:status: addresses: - address: 10.0.131.183 type: InternalIP - address: ip-10-0-131-183.ec2.internal type: InternalDNS - address: ip-10-0-131-183.ec2.internal type: Hostname lastUpdated: "2020-04-20T17:44:29Z" nodeRef: kind: Node name: ip-10-0-131-183.ec2.internal uid: acca4411-af0d-4387-b73e-52b2484295ad phase: Running providerStatus: apiVersion: awsproviderconfig.openshift.io/v1beta1 conditions: - lastProbeTime: "2020-04-20T16:53:50Z" lastTransitionTime: "2020-04-20T16:53:50Z" message: machine successfully created reason: MachineCreationSucceeded status: "True" type: MachineCreation instanceId: i-0fdb85790d76d0c3f instanceState: stopped kind: AWSMachineProviderStatusChange the
metadata.namefield to a new name.For example:
apiVersion: machine.openshift.io/v1beta1 kind: Machine metadata: ... name: clustername-8qw5l-master-3 ...Keep the same base name as the old machine and change the ending number to the next available number. In this example,
clustername-8qw5l-master-0is changed toclustername-8qw5l-master-3Remove the
spec.providerIDfield:providerID: aws:///us-east-1a/i-0fdb85790d76d0c3f
Delete the machine of the unhealthy member by running the following command:
$ oc delete machine -n openshift-machine-api clustername-8qw5l-master-0In the command, replace
clustername-8qw5l-master-0with the control plane machine name for the unhealthy node that you identified in the example output above.Verify that the machine was deleted by running the following command:
$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE clustername-8qw5l-master-1 Running m4.xlarge us-east-1 us-east-1b 3h37m ip-10-0-154-204.ec2.internal aws:///us-east-1b/i-096c349b700a19631 running clustername-8qw5l-master-2 Running m4.xlarge us-east-1 us-east-1c 3h37m ip-10-0-164-97.ec2.internal aws:///us-east-1c/i-02626f1dba9ed5bba running clustername-8qw5l-worker-us-east-1a-wbtgd Running m4.large us-east-1 us-east-1a 3h28m ip-10-0-129-226.ec2.internal aws:///us-east-1a/i-010ef6279b4662ced running clustername-8qw5l-worker-us-east-1b-lrdxb Running m4.large us-east-1 us-east-1b 3h28m ip-10-0-144-248.ec2.internal aws:///us-east-1b/i-0cb45ac45a166173b running clustername-8qw5l-worker-us-east-1c-pkg26 Running m4.large us-east-1 us-east-1c 3h28m ip-10-0-170-181.ec2.internal aws:///us-east-1c/i-06861c00007751b0a runningCreate the new machine by using the
new-master-machine.yamlfile by running the following command:$ oc apply -f new-master-machine.yamlVerify that the new machine was created by running the following command:
$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE clustername-8qw5l-master-1 Running m4.xlarge us-east-1 us-east-1b 3h37m ip-10-0-154-204.ec2.internal aws:///us-east-1b/i-096c349b700a19631 running clustername-8qw5l-master-2 Running m4.xlarge us-east-1 us-east-1c 3h37m ip-10-0-164-97.ec2.internal aws:///us-east-1c/i-02626f1dba9ed5bba running clustername-8qw5l-master-3 Provisioning m4.xlarge us-east-1 us-east-1a 85s ip-10-0-133-53.ec2.internal aws:///us-east-1a/i-015b0888fe17bc2c8 running clustername-8qw5l-worker-us-east-1a-wbtgd Running m4.large us-east-1 us-east-1a 3h28m ip-10-0-129-226.ec2.internal aws:///us-east-1a/i-010ef6279b4662ced running clustername-8qw5l-worker-us-east-1b-lrdxb Running m4.large us-east-1 us-east-1b 3h28m ip-10-0-144-248.ec2.internal aws:///us-east-1b/i-0cb45ac45a166173b running clustername-8qw5l-worker-us-east-1c-pkg26 Running m4.large us-east-1 us-east-1c 3h28m ip-10-0-170-181.ec2.internal aws:///us-east-1c/i-06861c00007751b0a runningIn the example output,
clustername-8qw5l-master-3is the new control plane machine. The machine is ready when thePHASEchanges fromProvisioningtoRunning.It might take a few minutes for the new machine to be created. The etcd cluster Operator automatically syncs when the machine or node returns to a healthy state.
Turn the quorum guard back on by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": null}}'You can verify that the
unsupportedConfigOverridessection is removed from the object by running the following command:$ oc get etcd/cluster -oyamlIf you are using single-node OpenShift, restart the node. Otherwise, you might experience the following error in the etcd cluster Operator:
Example output
EtcdCertSignerControllerDegraded: [Operation cannot be fulfilled on secrets "etcd-peer-sno-0": the object has been modified; please apply your changes to the latest version and try again, Operation cannot be fulfilled on secrets "etcd-serving-sno-0": the object has been modified; please apply your changes to the latest version and try again, Operation cannot be fulfilled on secrets "etcd-serving-metrics-sno-0": the object has been modified; please apply your changes to the latest version and try again]
Verification
Verify that all etcd pods are running properly by running the following command:
$ oc -n openshift-etcd get pods -l k8s-app=etcdExample output
etcd-ip-10-0-133-53.ec2.internal 3/3 Running 0 7m49s etcd-ip-10-0-164-97.ec2.internal 3/3 Running 0 123m etcd-ip-10-0-154-204.ec2.internal 3/3 Running 0 124mIf the output from the previous command lists only two pods, force an etcd redeployment by running the following command:
$ oc patch etcd cluster -p='{"spec": {"forceRedeploymentReason": "recovery-'"$( date --rfc-3339=ns )"'"}}' --type=mergeThe
forceRedeploymentReasonvalue must be unique, which is why a timestamp is appended in the example.Verify that there are exactly three etcd members.
Connect to the running etcd container, passing in the name of a pod that was not on the affected node by running the following command:
$ oc rsh -n openshift-etcd etcd-ip-10-0-154-204.ec2.internalView the member list by running the following command:
sh-4.2# etcdctl member list -w tableExample output
+------------------+---------+------------------------------+---------------------------+---------------------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | +------------------+---------+------------------------------+---------------------------+---------------------------+ | 5eb0d6b8ca24730c | started | ip-10-0-133-53.ec2.internal | https://10.0.133.53:2380 | https://10.0.133.53:2379 | | 757b6793e2408b6c | started | ip-10-0-164-97.ec2.internal | https://10.0.164.97:2380 | https://10.0.164.97:2379 | | ca8c2990a0aa29d1 | started | ip-10-0-154-204.ec2.internal | https://10.0.154.204:2380 | https://10.0.154.204:2379 | +------------------+---------+------------------------------+---------------------------+---------------------------+If the output from the previous command lists more than three etcd members, you must carefully remove the unwanted member.
WarningBe sure to remove the correct etcd member; removing a good etcd member might lead to quorum loss.
6.3.3.2. Replacing an unhealthy etcd member whose etcd pod is crashlooping Copy linkLink copied to clipboard!
Replace an unhealthy etcd member when the etcd pod is crashlooping. Restoring the member returns the control plane to a healthy state.
Prerequisites
- You identified the unhealthy etcd member.
- You verified that the etcd pod is crashlooping.
-
You confirmed access to the cluster as a user with the
cluster-adminrole. You created an etcd backup before replacing the unhealthy etcd member.
ImportantIt is important to take an etcd backup before performing this procedure so that your cluster can be restored if you encounter any issues.
Procedure
Stop the crashlooping etcd pod.
Debug the node that is crashlooping by running the following command:
$ oc debug node/<unhealthy_node>Replace
<unhealthy_node>with the name of the unhealthy etcd member.Change your root directory to
/hostby running the following command:sh-4.2# chroot /hostCreate a backup directory by running the following command:
sh-4.2# mkdir /var/lib/etcd-backup
Move the existing etcd pod file out of the kubelet manifest directory by running the following commands:
sh-4.2# mv /etc/kubernetes/manifests/etcd-pod.yaml /var/lib/etcd-backup/Move the etcd data directory to a different location by running the following command:
sh-4.2# mv /var/lib/etcd/ /tmpYou can now exit the node shell.
Remove the unhealthy member.
Choose a pod that is not on the affected node by running the following command:
$ oc -n openshift-etcd get pods -l k8s-app=etcdExample output
etcd-ip-10-0-131-183.ec2.internal 2/3 Error 7 6h9m etcd-ip-10-0-164-97.ec2.internal 3/3 Running 0 6h6m etcd-ip-10-0-154-204.ec2.internal 3/3 Running 0 6h6mConnect to the running etcd container, passing in the name of a pod that is not on the affected node by running the following command:
$ oc rsh -n openshift-etcd etcd-ip-10-0-154-204.ec2.internalView the member list by running the following command:
sh-4.2# etcdctl member list -w tableExample output
+------------------+---------+------------------------------+---------------------------+---------------------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | +------------------+---------+------------------------------+---------------------------+---------------------------+ | 62bcf33650a7170a | started | ip-10-0-131-183.ec2.internal | https://10.0.131.183:2380 | https://10.0.131.183:2379 | | b78e2856655bc2eb | started | ip-10-0-164-97.ec2.internal | https://10.0.164.97:2380 | https://10.0.164.97:2379 | | d022e10b498760d5 | started | ip-10-0-154-204.ec2.internal | https://10.0.154.204:2380 | https://10.0.154.204:2379 | +------------------+---------+------------------------------+---------------------------+---------------------------+Take note of the ID and the name of the unhealthy etcd member, because these values are needed later in the procedure.
Remove the unhealthy etcd member by providing the ID to the
etcdctl member removecommand:sh-4.2# etcdctl member remove 62bcf33650a7170aExample output
Member 62bcf33650a7170a removed from cluster ead669ce1fbfb346View the member list again and verify that the member was removed by running the following command:
sh-4.2# etcdctl member list -w tableExample output
+------------------+---------+------------------------------+---------------------------+---------------------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | +------------------+---------+------------------------------+---------------------------+---------------------------+ | b78e2856655bc2eb | started | ip-10-0-164-97.ec2.internal | https://10.0.164.97:2380 | https://10.0.164.97:2379 | | d022e10b498760d5 | started | ip-10-0-154-204.ec2.internal | https://10.0.154.204:2380 | https://10.0.154.204:2379 | +------------------+---------+------------------------------+---------------------------+---------------------------+You can now exit the node shell.
Turn off the quorum guard by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": {"useUnsupportedUnsafeNonHANonProductionUnstableEtcd": true}}}'This command ensures that you can successfully re-create secrets and roll out the static pods.
Remove the old secrets for the unhealthy etcd member that was removed.
List the secrets for the unhealthy etcd member that was removed by running the following command:
$ oc get secrets -n openshift-etcd | grep <unhealthy_node>Replace
<unhealthy_node>in the command with the name of the unhealthy etcd member that you noted earlier in this procedure.There is a peer, serving, and metrics secret as shown in the following output:
Example output
etcd-peer-ip-10-0-131-183.ec2.internal kubernetes.io/tls 2 47m etcd-serving-ip-10-0-131-183.ec2.internal kubernetes.io/tls 2 47m etcd-serving-metrics-ip-10-0-131-183.ec2.internal kubernetes.io/tls 2 47mDelete the peer secret for the unhealthy etcd member that was removed by running the following command:
$ oc delete secret -n openshift-etcd etcd-peer-ip-10-0-131-183.ec2.internalDelete the serving secret by running the following command:
$ oc delete secret -n openshift-etcd etcd-serving-ip-10-0-131-183.ec2.internalDelete the metrics secret by running the following command:
$ oc delete secret -n openshift-etcd etcd-serving-metrics-ip-10-0-131-183.ec2.internal
Force etcd redeployment by running the following command:
$ oc patch etcd cluster -p='{"spec": {"forceRedeploymentReason": "single-master-recovery-'"$( date --rfc-3339=ns )"'"}}' --type=mergeThe
forceRedeploymentReasonvalue must be unique, which is why a timestamp is appended.When the etcd cluster Operator performs a redeployment, it ensures that all control plane nodes have a functioning etcd pod.
Turn the quorum guard back on by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": null}}'Verify that the
unsupportedConfigOverridessection is removed from the object by running the following command:$ oc get etcd/cluster -oyamlIf you are using single-node OpenShift, restart the node. Otherwise, you might encounter the following error in the etcd cluster Operator:
Example output
EtcdCertSignerControllerDegraded: [Operation cannot be fulfilled on secrets "etcd-peer-sno-0": the object has been modified; please apply your changes to the latest version and try again, Operation cannot be fulfilled on secrets "etcd-serving-sno-0": the object has been modified; please apply your changes to the latest version and try again, Operation cannot be fulfilled on secrets "etcd-serving-metrics-sno-0": the object has been modified; please apply your changes to the latest version and try again]
Verification
Verify that the new member is available and healthy.
Connect to the running etcd container by running the following command:
$ oc rsh -n openshift-etcd etcd-ip-10-0-154-204.ec2.internalVerify that all members are healthy by running the following command:
sh-4.2# etcdctl endpoint healthExample output
https://10.0.131.183:2379 is healthy: successfully committed proposal: took = 16.671434ms https://10.0.154.204:2379 is healthy: successfully committed proposal: took = 16.698331ms https://10.0.164.97:2379 is healthy: successfully committed proposal: took = 16.621645ms
6.3.3.3. Replacing an unhealthy bare metal etcd member whose machine is not running or whose node is not ready Copy linkLink copied to clipboard!
Replace an unhealthy bare metal etcd member when the machine is not running or the node is not ready. Restoring the member returns the control plane to a healthy state.
If you are running installer-provisioned infrastructure or you used the Machine API to create your machines, follow these steps. Otherwise you must create the new control plane node using the same method that was used to originally create it.
Prerequisites
- You identified the unhealthy bare metal etcd member.
- You verified that either the machine is not running or the node is not ready.
-
You confirmed access to the cluster as a user with the
cluster-adminrole. You created an etcd backup.
ImportantYou must take an etcd backup before performing this procedure so that your cluster can be restored if you encounter any issues.
Procedure
Verify and remove the unhealthy member.
Choose a pod that is not on the affected node by running the following command:
$ oc -n openshift-etcd get pods -l k8s-app=etcd -o wideExample output
etcd-openshift-control-plane-0 5/5 Running 11 3h56m 192.168.10.9 openshift-control-plane-0 <none> <none> etcd-openshift-control-plane-1 5/5 Running 0 3h54m 192.168.10.10 openshift-control-plane-1 <none> <none> etcd-openshift-control-plane-2 5/5 Running 0 3h58m 192.168.10.11 openshift-control-plane-2 <none> <none>Connect to the running etcd container, passing in the name of a pod that is not on the affected node by running the following command:
$ oc rsh -n openshift-etcd etcd-openshift-control-plane-0View the member list by running the following command:
sh-4.2# etcdctl member list -w tableExample output
+------------------+---------+--------------------+---------------------------+---------------------------+---------------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | +------------------+---------+--------------------+---------------------------+---------------------------+---------------------+ | 7a8197040a5126c8 | started | openshift-control-plane-2 | https://192.168.10.11:2380/ | https://192.168.10.11:2379/ | false | | 8d5abe9669a39192 | started | openshift-control-plane-1 | https://192.168.10.10:2380/ | https://192.168.10.10:2379/ | false | | cc3830a72fc357f9 | started | openshift-control-plane-0 | https://192.168.10.9:2380/ | https://192.168.10.9:2379/ | false | +------------------+---------+--------------------+---------------------------+---------------------------+---------------------+Take note of the ID and the name of the unhealthy etcd member, because these values are required later in the procedure. The
etcdctl endpoint healthcommand lists the removed member until the replacement procedure is completed and the new member is added.WarningBe sure to remove the correct etcd member. Removing a good etcd member might lead to quorum loss.
Remove the unhealthy etcd member by providing the ID to the
etcdctl member removecommand:sh-4.2# etcdctl member remove 7a8197040a5126c8Example output
Member 7a8197040a5126c8 removed from cluster b23536c33f2cdd1bView the member list again and verify that the member was removed by running the following command:
sh-4.2# etcdctl member list -w tableExample output
+------------------+---------+--------------------+---------------------------+---------------------------+-------------------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | +------------------+---------+--------------------+---------------------------+---------------------------+-------------------------+ | cc3830a72fc357f9 | started | openshift-control-plane-2 | https://192.168.10.11:2380/ | https://192.168.10.11:2379/ | false | | 8d5abe9669a39192 | started | openshift-control-plane-1 | https://192.168.10.10:2380/ | https://192.168.10.10:2379/ | false | +------------------+---------+--------------------+---------------------------+---------------------------+-------------------------+You can now exit the node shell.
ImportantAfter you remove the member, the cluster might be unreachable for a short time while the remaining etcd instances reboot.
Turn off the quorum guard by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": {"useUnsupportedUnsafeNonHANonProductionUnstableEtcd": true}}}'This command ensures that you can successfully re-create secrets and roll out the static pods.
Remove the old secrets for the unhealthy etcd member that was removed.
List the secrets for the unhealthy etcd member that was removed by running the following command:
$ oc get secrets -n openshift-etcd | grep openshift-control-plane-2Pass in the name of the unhealthy etcd member that you took note of earlier in this procedure.
There is a peer, serving, and metrics secret as shown in the following output:
etcd-peer-openshift-control-plane-2 kubernetes.io/tls 2 134m etcd-serving-metrics-openshift-control-plane-2 kubernetes.io/tls 2 134m etcd-serving-openshift-control-plane-2 kubernetes.io/tls 2 134mDelete the secrets for the unhealthy etcd member by running the following command:
$ oc delete secret etcd-peer-openshift-control-plane-2 -n openshift-etcdExample output
secret "etcd-peer-openshift-control-plane-2" deletedDelete the serving secret by running the following command:
$ oc delete secret etcd-serving-metrics-openshift-control-plane-2 -n openshift-etcdExample output
secret "etcd-serving-metrics-openshift-control-plane-2" deletedDelete the metrics secret by running the following command:
$ oc delete secret etcd-serving-openshift-control-plane-2 -n openshift-etcdExample output
secret "etcd-serving-openshift-control-plane-2" deleted
Obtain the machine for the unhealthy member by running the following command:
$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE examplecluster-control-plane-0 Running 3h11m openshift-control-plane-0 baremetalhost:///openshift-machine-api/openshift-control-plane-0/da1ebe11-3ff2-41c5-b099-0aa41222964e externally provisioned examplecluster-control-plane-1 Running 3h11m openshift-control-plane-1 baremetalhost:///openshift-machine-api/openshift-control-plane-1/d9f9acbc-329c-475e-8d81-03b20280a3e1 externally provisioned examplecluster-control-plane-2 Running 3h11m openshift-control-plane-2 baremetalhost:///openshift-machine-api/openshift-control-plane-2/3354bdac-61d8-410f-be5b-6a395b056135 externally provisioned examplecluster-compute-0 Running 165m openshift-compute-0 baremetalhost:///openshift-machine-api/openshift-compute-0/3d685b81-7410-4bb3-80ec-13a31858241f provisioned examplecluster-compute-1 Running 165m openshift-compute-1 baremetalhost:///openshift-machine-api/openshift-compute-1/0fdae6eb-2066-4241-91dc-e7ea72ab13b9 provisionedexamplecluster-control-plane-2is the control plane machine for the unhealthy nodeopenshift-control-plane-2.Ensure that the Bare Metal Operator is available by running the following command:
$ oc get clusteroperator baremetalExample output
NAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE MESSAGE baremetal 4.22.0 True False False 3d15hRemove the old
BareMetalHostobject by running the following command:$ oc delete bmh openshift-control-plane-2 -n openshift-machine-apiExample output
baremetalhost.metal3.io "openshift-control-plane-2" deletedDelete the machine of the unhealthy member by running the following command:
$ oc delete machine -n openshift-machine-api examplecluster-control-plane-2After you remove the
BareMetalHostandMachineobjects, then theMachinecontroller automatically deletes theNodeobject.If deletion of the machine is delayed for any reason or the command is obstructed and delayed, you can force deletion by removing the machine object finalizer field.
ImportantDo not interrupt machine deletion by pressing
Ctrl+c. You must allow the command to proceed to completion. Open a new terminal window to edit and delete the finalizer fields.A new machine is automatically provisioned after deleting the machine of the unhealthy member.
Edit the machine configuration by running the following command:
$ oc edit machine -n openshift-machine-api examplecluster-control-plane-2Delete the following fields in the
Machinecustom resource, and then save the updated file:finalizers: - machine.machine.openshift.ioExample output
machine.machine.openshift.io/examplecluster-control-plane-2 edited
Verify that the machine was deleted by running the following command:
$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE examplecluster-control-plane-0 Running 3h11m openshift-control-plane-0 baremetalhost:///openshift-machine-api/openshift-control-plane-0/da1ebe11-3ff2-41c5-b099-0aa41222964e externally provisioned examplecluster-control-plane-1 Running 3h11m openshift-control-plane-1 baremetalhost:///openshift-machine-api/openshift-control-plane-1/d9f9acbc-329c-475e-8d81-03b20280a3e1 externally provisioned examplecluster-compute-0 Running 165m openshift-compute-0 baremetalhost:///openshift-machine-api/openshift-compute-0/3d685b81-7410-4bb3-80ec-13a31858241f provisioned examplecluster-compute-1 Running 165m openshift-compute-1 baremetalhost:///openshift-machine-api/openshift-compute-1/0fdae6eb-2066-4241-91dc-e7ea72ab13b9 provisionedVerify that the node has been deleted by running the following command:
$ oc get nodesExample output
NAME STATUS ROLES AGE VERSION openshift-control-plane-0 Ready master 3h24m v1.35.4 openshift-control-plane-1 Ready master 3h24m v1.35.4 openshift-compute-0 Ready worker 176m v1.35.4 openshift-compute-1 Ready worker 176m v1.35.4Create the new
BareMetalHostobject and the secret to store the Baseboard Management Controller (BMC) credentials by running the following command:$ cat <<EOF | oc apply -f - apiVersion: v1 kind: Secret metadata: name: openshift-control-plane-2-bmc-secret namespace: openshift-machine-api data: password: <password> username: <username> type: Opaque --- apiVersion: metal3.io/v1alpha1 kind: BareMetalHost metadata: name: openshift-control-plane-2 namespace: openshift-machine-api spec: automatedCleaningMode: disabled bmc: address: redfish://10.46.61.18:443/redfish/v1/Systems/1 credentialsName: openshift-control-plane-2-bmc-secret disableCertificateVerification: true bootMACAddress: 48:df:37:b0:8a:a0 bootMode: UEFI externallyProvisioned: false online: true rootDeviceHints: deviceName: /dev/disk/by-id/scsi-<serial_number> userData: name: master-user-data-managed namespace: openshift-machine-api EOFNoteThe username and password can be found from the secrets of the other bare-metal host. The protocol to use in
bmc:addresscan be taken from other bmh objects.ImportantIf you reuse the
BareMetalHostobject definition from an existing control plane host, do not leave theexternallyProvisionedfield set totrue.Existing control plane
BareMetalHostobjects may have theexternallyProvisionedflag set totrueif they were provisioned by the OpenShift Container Platform installation program.After the inspection is complete, the
BareMetalHostobject is created and available to be provisioned.Verify the creation process using available
BareMetalHostobjects by completing the following steps:Verify that a new machine has been created by running the following command:
$ oc get machines -n openshift-machine-api -o wideThe new machine is ready when the phase changes from
ProvisioningtoRunning.It should take a few minutes for the new machine to be created. The etcd cluster Operator automatically syncs when the machine or node returns to a healthy state.
Example output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE examplecluster-control-plane-0 Running 3h11m openshift-control-plane-0 baremetalhost:///openshift-machine-api/openshift-control-plane-0/da1ebe11-3ff2-41c5-b099-0aa41222964e externally provisioned examplecluster-control-plane-1 Running 3h11m openshift-control-plane-1 baremetalhost:///openshift-machine-api/openshift-control-plane-1/d9f9acbc-329c-475e-8d81-03b20280a3e1 externally provisioned examplecluster-control-plane-3 Running 11m openshift-control-plane-2 baremetalhost:///openshift-machine-api/openshift-control-plane-2/dac4335b-5c81-a641-395b-5631f0a9a545 externally provisioned examplecluster-compute-0 Running 165m openshift-compute-0 baremetalhost:///openshift-machine-api/openshift-compute-0/3d685b81-7410-4bb3-80ec-13a31858241f provisioned examplecluster-compute-1 Running 165m openshift-compute-1 baremetalhost:///openshift-machine-api/openshift-compute-1/0fdae6eb-2066-4241-91dc-e7ea72ab13b9 provisionedVerify that the bare metal host becomes provisioned and no error reported by running the following command:
$ oc get bmh -n openshift-machine-apiExample output
NAME STATE CONSUMER ONLINE ERROR AGE openshift-control-plane-0 externally provisioned examplecluster-control-plane-0 true 4h48m openshift-control-plane-1 externally provisioned examplecluster-control-plane-1 true 4h48m openshift-control-plane-2 provisioned examplecluster-control-plane-3 true 47m openshift-compute-0 provisioned examplecluster-compute-0 true 4h48m openshift-compute-1 provisioned examplecluster-compute-1 true 4h48mVerify that the new node is added and in a ready state by running the following command:
$ oc get nodesExample output
NAME STATUS ROLES AGE VERSION openshift-control-plane-0 Ready master 4h26m v1.35.4 openshift-control-plane-1 Ready master 4h26m v1.35.4 openshift-control-plane-2 Ready master 12m v1.35.4 openshift-compute-0 Ready worker 3h58m v1.35.4 openshift-compute-1 Ready worker 3h58m v1.35.4
Turn the quorum guard back on by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": null}}'You can verify that the
unsupportedConfigOverridessection is removed from the object by running the following command:$ oc get etcd/cluster -oyamlIf you are using single-node OpenShift, restart the node. Otherwise, you might encounter the following error in the etcd cluster Operator:
Example output
EtcdCertSignerControllerDegraded: [Operation cannot be fulfilled on secrets "etcd-peer-sno-0": the object has been modified; please apply your changes to the latest version and try again, Operation cannot be fulfilled on secrets "etcd-serving-sno-0": the object has been modified; please apply your changes to the latest version and try again, Operation cannot be fulfilled on secrets "etcd-serving-metrics-sno-0": the object has been modified; please apply your changes to the latest version and try again]
Verification
Verify that all etcd pods are running properly by running the following command:
$ oc -n openshift-etcd get pods -l k8s-app=etcdExample output
etcd-openshift-control-plane-0 5/5 Running 0 105m etcd-openshift-control-plane-1 5/5 Running 0 107m etcd-openshift-control-plane-2 5/5 Running 0 103mIf the output from the previous command only lists two pods, you can manually force an etcd redeployment. In a terminal that has access to the cluster as a
cluster-adminuser, run the following command:$ oc patch etcd cluster -p='{"spec": {"forceRedeploymentReason": "recovery-'"$( date --rfc-3339=ns )"'"}}' --type=mergeThe
forceRedeploymentReasonvalue must be unique, which is why a timestamp is appended.To verify there are exactly three etcd members, connect to the running etcd container, passing in the name of a pod that was not on the affected node. In a terminal that has access to the cluster as a
cluster-adminuser, run the following command:$ oc rsh -n openshift-etcd etcd-openshift-control-plane-0View the member list by running the following command:
sh-4.2# etcdctl member list -w tableExample output
+------------------+---------+--------------------+---------------------------+---------------------------+-----------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | +------------------+---------+--------------------+---------------------------+---------------------------+-----------------+ | 7a8197040a5126c8 | started | openshift-control-plane-2 | https://192.168.10.11:2380 | https://192.168.10.11:2379 | false | | 8d5abe9669a39192 | started | openshift-control-plane-1 | https://192.168.10.10:2380 | https://192.168.10.10:2379 | false | | cc3830a72fc357f9 | started | openshift-control-plane-0 | https://192.168.10.9:2380 | https://192.168.10.9:2379 | false | +------------------+---------+--------------------+---------------------------+---------------------------+-----------------+NoteIf the output from the previous command lists more than three etcd members, you must carefully remove the unwanted member.
Verify that all etcd members are healthy by running the following command:
# etcdctl endpoint health --clusterExample output
https://192.168.10.10:2379 is healthy: successfully committed proposal: took = 8.973065ms https://192.168.10.9:2379 is healthy: successfully committed proposal: took = 11.559829ms https://192.168.10.11:2379 is healthy: successfully committed proposal: took = 11.665203msValidate that all nodes are at the latest revision by running the following command:
$ oc get etcd -o=jsonpath='{range.items[0].status.conditions[?(@.type=="NodeInstallerProgressing")]}{.reason}{"\n"}{.message}{"\n"}'AllNodesAtLatestRevision
6.4. Disaster recovery Copy linkLink copied to clipboard!
6.4.1. About disaster recovery Copy linkLink copied to clipboard!
To return your cluster to a working state after quorum loss, control plane failure, or expired certificates, follow the disaster recovery procedures for your situation. You can restore etcd quorum, restore the cluster from an etcd snapshot, or recover from expired control plane certificates.
Disaster recovery requires you to have at least one healthy control plane host.
6.4.1.1. Restoring etcd quorum for high availability clusters Copy linkLink copied to clipboard!
You can restore etcd quorum on high availability (HA) clusters by running the quorum-restore.sh script on a recovery host. Restored quorum returns the OpenShift Container Platform API to read/write mode when quorum loss takes the cluster offline.
The quorum-restore.sh script creates a new single-member etcd cluster from the local data directory on the recovery host. No prior backup is required.
For high availability (HA) clusters, a three-node HA cluster requires you to shut down etcd on two hosts to avoid a cluster split. On four-node and five-node HA clusters, you must shut down three hosts. Quorum requires a majority of nodes. The minimum number of nodes required for quorum on a three-node HA cluster is two. On four-node and five-node HA clusters, the minimum number of nodes required for quorum is three. If you start a new cluster from backup on your recovery host, the other etcd members might still be able to form quorum and continue service.
You might experience data loss if the host that runs the restoration does not have all data replicated to it.
Quorum restoration should not be used to decrease the number of nodes outside of the restoration process. Decreasing the number of nodes results in an unsupported cluster configuration.
Prerequisites
- You have SSH access to the node used to restore quorum.
Procedure
- Select a control plane host to use as the recovery host. You run the restore operation on this host.
Using SSH, connect to the chosen recovery node and run the following command to restore etcd quorum:
$ sudo -E /usr/local/bin/quorum-restore.shAfter a few minutes, the nodes that went down are automatically synchronized with the node that the recovery script was run on. Any remaining online nodes automatically rejoin the new etcd cluster created by the
quorum-restore.shscript. This process takes a few minutes.Verify that the local etcd container is running on the host by using the container runtime CLI:
$ sudo crictl ps --name '^etcd$'- Exit the SSH session.
Return to a three-node configuration if any nodes are offline. Repeat the following steps for each node that is offline to delete and re-create them. After the machines are re-created, a new revision is forced and etcd automatically scales up.
WarningFor installer-provisioned infrastructure and user-provisioned infrastructure, do not delete and re-create the machine for the recovery host.
If you use a user-provisioned bare-metal installation, you can re-create a control plane machine by using the same method that you used to originally create it.
ImportantBefore starting the newly provisioned node, you must delete the existing node object from the cluster by running the
oc delete node <node_name>command. Failing to delete the node object before reinstallating the node can cause conflicts and issues during the reinstallation process.For more information, see "Installing a user-provisioned cluster on bare metal".
If you are running installer-provisioned infrastructure, or you used the Machine API to create your machines, follow these steps:
ImportantFor bare-metal installations on installer-provisioned infrastructure, control plane machines are not re-created. For more information, see "Replacing a bare-metal control plane node".
In a terminal that has access to the cluster as a
cluster-adminuser, obtain the machine for one of the offline nodes by running the following command:$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE clustername-8qw5l-master-0 Running m4.xlarge us-east-1 us-east-1a 3h37m ip-10-0-131-183.ec2.internal aws:///us-east-1a/i-0ec2782f8287dfb7e stopped clustername-8qw5l-master-1 Running m4.xlarge us-east-1 us-east-1b 3h37m ip-10-0-143-125.ec2.internal aws:///us-east-1b/i-096c349b700a19631 running clustername-8qw5l-master-2 Running m4.xlarge us-east-1 us-east-1c 3h37m ip-10-0-154-194.ec2.internal aws:///us-east-1c/i-02626f1dba9ed5bba running clustername-8qw5l-worker-us-east-1a-wbtgd Running m4.large us-east-1 us-east-1a 3h28m ip-10-0-129-226.ec2.internal aws:///us-east-1a/i-010ef6279b4662ced running clustername-8qw5l-worker-us-east-1b-lrdxb Running m4.large us-east-1 us-east-1b 3h28m ip-10-0-144-248.ec2.internal aws:///us-east-1b/i-0cb45ac45a166173b running clustername-8qw5l-worker-us-east-1c-pkg26 Running m4.large us-east-1 us-east-1c 3h28m ip-10-0-170-181.ec2.internal aws:///us-east-1c/i-06861c00007751b0a runningIn the example output,
clustername-8qw5l-master-0is the control plane machine for the offline node,ip-10-0-131-183.ec2.internal.Delete the machine of the offline node by running the following command:
$ oc delete machine -n openshift-machine-api clustername-8qw5l-master-0Specify the name of the control plane machine for the offline node.
A new machine is automatically provisioned after deleting the machine of the offline node.
Verify that a new machine has been created by running the following command:
$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE clustername-8qw5l-master-1 Running m4.xlarge us-east-1 us-east-1b 3h37m ip-10-0-143-125.ec2.internal aws:///us-east-1b/i-096c349b700a19631 running clustername-8qw5l-master-2 Running m4.xlarge us-east-1 us-east-1c 3h37m ip-10-0-154-194.ec2.internal aws:///us-east-1c/i-02626f1dba9ed5bba running clustername-8qw5l-master-3 Provisioning m4.xlarge us-east-1 us-east-1a 85s ip-10-0-173-171.ec2.internal aws:///us-east-1a/i-015b0888fe17bc2c8 running clustername-8qw5l-worker-us-east-1a-wbtgd Running m4.large us-east-1 us-east-1a 3h28m ip-10-0-129-226.ec2.internal aws:///us-east-1a/i-010ef6279b4662ced running clustername-8qw5l-worker-us-east-1b-lrdxb Running m4.large us-east-1 us-east-1b 3h28m ip-10-0-144-248.ec2.internal aws:///us-east-1b/i-0cb45ac45a166173b running clustername-8qw5l-worker-us-east-1c-pkg26 Running m4.large us-east-1 us-east-1c 3h28m ip-10-0-170-181.ec2.internal aws:///us-east-1c/i-06861c00007751b0a runningIn the example output,
clustername-8qw5l-master-3is being created and is ready after the phase changes fromProvisioningtoRunning.It might take a few minutes for the new machine to be created. The etcd cluster Operator automatically synchronizes when the machine or node returns to a healthy state.
- For each node that is offline, repeat the previous steps to delete and re-create the node.
Wait until the control plane recovers by running the following command:
$ oc adm wait-for-stable-clusterNoteIt can take up to 15 minutes for the control plane to recover.
Troubleshooting
If you see no progress rolling out the etcd static pods, you can force redeployment from the etcd cluster Operator by running the following command:
$ oc patch etcd cluster -p='{"spec": {"forceRedeploymentReason": "recovery-'"$(date --rfc-3339=ns )"'"}}' --type=merge
6.4.1.2. About restoring to an earlier cluster state Copy linkLink copied to clipboard!
To assess restore risks before you choose rollback as a last resort, review how an etcd snapshot restore affects your OpenShift Container Platform cluster, including Operators, workloads, and persistent storage.
You can use an etcd backup to restore your cluster to an earlier state. This can be used to recover from the following situations:
- The cluster has lost the majority of control plane hosts and quorum.
- An administrator has deleted something critical and must restore to recover the cluster.
If applicable, you might also need to recover from expired control plane certificates.
Restoring to an earlier 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 cannot retrieve data using the Kubernetes API server, then etcd is available and you should not restore using an etcd backup.
Restoring etcd effectively takes a cluster back in time and all clients experience a conflicting, parallel history. This can impact the behavior of watching components like kubelets, Kubernetes controller managers, persistent volume controllers, and OpenShift Container Platform Operators, including the network Operator.
It can cause Operator churn when the content in etcd does not match the actual content on disk, causing Operators for the Kubernetes API server, Kubernetes controller manager, Kubernetes scheduler, and etcd to get stuck when files on disk conflict with content in etcd. This can require manual actions to resolve the issues.
In extreme cases, the cluster can lose track of persistent volumes, delete critical workloads that no longer exist, reimage machines, and rewrite CA bundles with expired certificates.
6.4.1.3. Restoring to an earlier cluster state for a single node Copy linkLink copied to clipboard!
To restore your OpenShift Container Platform cluster on a single node, use a saved etcd snapshot to roll back to an earlier state after quorum loss or critical data deletion.
When you restore your cluster, you must use an etcd backup that was taken from the same z-stream release. For example, an OpenShift Container Platform 4.22.2 cluster must use an etcd backup that was taken from 4.22.2.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole through a certificate-basedkubeconfigfile. - You have SSH access to control plane hosts.
-
You have a backup directory containing both the
etcdsnapshot and the resources for the static pods, which were from the same backup. The file names in the directory must be in the following formats:snapshot_<datetimestamp>.dbandstatic_kuberesources_<datetimestamp>.tar.gz.
Procedure
Use SSH to connect to the single node and copy the etcd backup to the
/home/coredirectory by running the following command:$ cp <etcd_backup_directory> /home/coreTo restore the cluster from an earlier backup on the single node, run the following command:
$ sudo -E /usr/local/bin/cluster-restore.sh /home/core/<etcd_backup_directory>- Exit the SSH session.
Monitor the recovery progress of the control plane by running the following command:
$ oc adm wait-for-stable-clusterNoteIt can take up to 15 minutes for the control plane to recover.
6.4.1.4. Restoring to an earlier cluster state for more than one node Copy linkLink copied to clipboard!
To restore your OpenShift Container Platform cluster with more than one control plane node to an earlier state, use a saved etcd snapshot after quorum loss or critical data deletion.
For a Two-Node with Fencing (TNF) setup, a single surviving node can continue to operate in degraded mode. Use a saved etcd backup to restore an earlier cluster state if only one node is operational, or when both nodes have failed and you need to restart the cluster from a known safe state. In both cases, perform the restore procedure on a single node. The peer node automatically synchronizes data with the restored node when it rejoins the cluster.
Before you restore from backup on the recovery host, shut down etcd on enough control plane nodes so the remaining members cannot form a quorum:
- Shut down etcd on 2 hosts in a 3-node cluster.
- Shut down etcd on 3 hosts in a 4-node or 5-node cluster.
If too few hosts are shut down, the other etcd members might still form a quorum and continue service while you restore.
If your cluster uses a control plane machine set, see "Recovering a degraded etcd Operator" in the control plane machine set troubleshooting topic for an etcd recovery procedure. For OpenShift Container Platform on a single node, follow the procedure to restore to an earlier cluster state for a single node.
When you restore your cluster, you must use an etcd backup that was taken from the same z-stream release. For example, an OpenShift Container Platform 4.22.2 cluster must use an etcd backup that was taken from 4.22.2.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole through a certificate-basedkubeconfigfile, like the one that was used during installation. - You have a healthy control plane host to use as the recovery host.
- You have SSH access to control plane hosts.
-
You have a backup directory containing both the
etcdsnapshot and the resources for the static pods, which were from the same backup. The file names in the directory must be in the following formats:snapshot_<datetimestamp>.dbandstatic_kuberesources_<datetimestamp>.tar.gz. - Control plane nodes are accessible or bootable.
For non-recovery control plane nodes, it is not required to establish SSH connectivity or to stop the static pods. You can delete and re-create other non-recovery, control plane machines, one by one.
Procedure
- Select a control plane host to use as the recovery host. This is the host that you run the restore operation on.
Establish SSH connectivity to each of the control plane nodes, including the recovery host.
kube-apiserverbecomes inaccessible after the restore process starts, so you cannot access the control plane nodes. Establish SSH connectivity to each control plane host in a separate terminal.ImportantIf you do not complete this step, you cannot access the control plane hosts to complete the restore procedure, and you cannot recover your cluster from this state.
Using SSH, connect to each control plane node to disable etcd by running the following command:
$ sudo -E /usr/local/bin/disable-etcd.shCopy the etcd backup directory to the recovery control plane host.
This procedure assumes that you copied the
backupdirectory containing the etcd snapshot and the resources for the static pods to the/home/core/directory of your recovery control plane host.Use SSH to connect to the recovery host. Restore the cluster from an earlier backup by running the following command:
$ sudo -E /usr/local/bin/cluster-restore.sh /home/core/<etcd-backup-directory>- Exit the SSH session.
When the API responds, turn off the etcd Operator quorum guard by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": {"useUnsupportedUnsafeNonHANonProductionUnstableEtcd": true}}}'ImportantFor a TNF setup, do not:
- Change the etcd Operator quorum setting.
- Turn the etcd Operator quorum off.
- Turn the etcd Operator quorum back on.
Monitor the recovery progress of the control plane by running the following command:
$ oc adm wait-for-stable-clusterNoteIt can take up to 15 minutes for the control plane to recover. Wait for the control plane to recover before using the next step.
Enable the quorum guard by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": null}}'
Troubleshooting
If the etcd static pods do not roll out, you can manually force an etcd redeployment from the cluster-etcd-operator by running the following command:
$ oc patch etcd cluster -p='{"spec": {"forceRedeploymentReason": "recovery-'"$(date --rfc-3339=ns )"'"}}' --type=merge
6.4.1.5. Issues and workarounds for restoring a persistent storage state Copy linkLink copied to clipboard!
To restore workloads safely after an etcd snapshot restore, identify and resolve outdated persistent storage references, including volumes, credentials, attachments, and devices on your OpenShift Container Platform cluster.
If your OpenShift Container Platform cluster uses persistent storage of any form, a state of the cluster is typically stored outside etcd. When you restore from an etcd backup, the status of the workloads in OpenShift Container Platform is also restored. However, if the etcd snapshot is old, the status might be invalid or outdated.
The contents of persistent volumes (PVs) are never part of the etcd snapshot. When you restore an OpenShift Container Platform cluster from an etcd snapshot, non-critical workloads might gain access to critical data, or vice-versa.
The following are some example scenarios that produce an out-of-date status:
- MySQL database is running in a pod backed up by a PV object. Restoring OpenShift Container Platform from an etcd snapshot does not bring back the volume on the storage provider, and does not produce a running MySQL pod, despite the pod repeatedly attempting to start. You must manually restore this pod by restoring the volume on the storage provider, and then editing the PV to point to the new volume.
- Pod P1 is using volume A, which is attached to node X. If the etcd snapshot is taken while another pod uses the same volume on node Y, then when the etcd restore is performed, pod P1 might not be able to start correctly due to the volume still being attached to node Y. OpenShift Container Platform is not aware of the attachment, and does not automatically detach it. When this occurs, the volume must be manually detached from node Y so that the volume can attach on node X, and then pod P1 can start.
- Cloud provider or storage provider credentials were updated after the etcd snapshot was taken. This causes any CSI drivers or Operators that depend on those credentials to not work. You might have to manually update the credentials required by those drivers or Operators.
A device is removed or renamed from OpenShift Container Platform nodes after the etcd snapshot is taken. The Local Storage Operator creates symlinks for each PV that it manages from
/dev/disk/by-idor/devdirectories. This situation might cause the local PVs to refer to devices that no longer exist.To fix this problem, an administrator must:
- Manually remove the PVs with invalid devices.
- Remove symlinks from respective nodes.
-
Delete
LocalVolumeorLocalVolumeSetobjects. For more information, see "Deleting the Local Storage Operator resources".
6.4.1.6. Recovering from expired control plane certificates Copy linkLink copied to clipboard!
You can restore kubelet certificates by manually approving pending node-bootstrapper certificate signing requests (CSRs) and, on user-provisioned installations, kubelet serving CSRs. Approved CSRs return nodes to a healthy state after control plane certificates expire.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have access to the OpenShift CLI (
oc).
Procedure
Get the list of current CSRs by running the following command:
$ oc get csrExample output
NAME AGE SIGNERNAME REQUESTOR CONDITION csr-2s94x 8m3s kubernetes.io/kubelet-serving system:node:<node_name> Pending csr-4bd6t 8m3s kubernetes.io/kubelet-serving system:node:<node_name> Pending csr-4hl85 13m kubernetes.io/kube-apiserver-client-kubelet system:serviceaccount:openshift-machine-config-operator:node-bootstrapper Pending csr-zhhhp 3m8s kubernetes.io/kube-apiserver-client-kubelet system:serviceaccount:openshift-machine-config-operator:node-bootstrapper Pending ...In the example output, CSRs with a
SIGNERNAMEofkubernetes.io/kubelet-servingare kubelet serving CSRs. You see this CSR type on user-provisioned installations. CSRs with aSIGNERNAMEofkubernetes.io/kube-apiserver-client-kubeletand anode-bootstrapperrequestor arenode-bootstrapperCSRs that you must approve to restore kubelet certificates.Review the details of a CSR to verify that it is valid by running the following command:
$ oc describe csr <csr_name><csr_name>is the name of a CSR from the list of current CSRs.Approve each valid
node-bootstrapperCSR by running the following command:$ oc adm certificate approve <csr_name>For user-provisioned installations, approve each valid kubelet serving CSR by running the following command:
$ oc adm certificate approve <csr_name>
6.4.1.7. Testing restore procedures Copy linkLink copied to clipboard!
You can test your cluster restore workflow by simulating etcd failure on nonrecovery nodes and restoring from backup. Use this test to confirm that your etcd backup and restore process works as expected.
You must have SSH access to the cluster. Without SSH access, you cannot disable etcd or manage the kubelet service on nonrecovery nodes.
Prerequisites
- You have SSH access to control plane hosts.
-
You have installed the OpenShift CLI (
oc).
Procedure
Use SSH to connect to each of your nonrecovery nodes to disable etcd and the
kubeletservice:Disable etcd by running the following command:
$ sudo /usr/local/bin/disable-etcd.shDelete variable data for etcd by running the following command:
$ sudo rm -rf /var/lib/etcdDisable the
kubeletservice by running the following command:$ sudo systemctl disable kubelet.service --now
- Exit every SSH session.
Ensure that your nonrecovery nodes are in a
NOT READYstate by running the following command:$ oc get nodes- Restore your cluster to an earlier cluster state by using an etcd backup. For more information, see "Restoring to an earlier cluster state".
After you restore the cluster and the API responds, use SSH to connect to each nonrecovery node and enable the
kubeletservice by running the following command:$ sudo systemctl enable kubelet.service --now- Exit every SSH session.
Verify that your nodes return to the
READYstate by running the following command:$ oc get nodesVerify that etcd is available by running the following command:
$ oc get pods -n openshift-etcd
6.4.2. Quorum restoration Copy linkLink copied to clipboard!
You can restore etcd quorum on your OpenShift Container Platform cluster by running the quorum-restore.sh script on a recovery host when quorum loss leaves the API read-only. After quorum is restored, the API returns to read/write mode.
6.4.2.1. Restoring etcd quorum for high availability clusters Copy linkLink copied to clipboard!
You can restore etcd quorum on high availability (HA) clusters by running the quorum-restore.sh script on a recovery host. Restored quorum returns the OpenShift Container Platform API to read/write mode when quorum loss takes the cluster offline.
The quorum-restore.sh script creates a new single-member etcd cluster from the local data directory on the recovery host. No prior backup is required.
For high availability (HA) clusters, a three-node HA cluster requires you to shut down etcd on two hosts to avoid a cluster split. On four-node and five-node HA clusters, you must shut down three hosts. Quorum requires a majority of nodes. The minimum number of nodes required for quorum on a three-node HA cluster is two. On four-node and five-node HA clusters, the minimum number of nodes required for quorum is three. If you start a new cluster from backup on your recovery host, the other etcd members might still be able to form quorum and continue service.
You might experience data loss if the host that runs the restoration does not have all data replicated to it.
Quorum restoration should not be used to decrease the number of nodes outside of the restoration process. Decreasing the number of nodes results in an unsupported cluster configuration.
Prerequisites
- You have SSH access to the node used to restore quorum.
Procedure
- Select a control plane host to use as the recovery host. You run the restore operation on this host.
Using SSH, connect to the chosen recovery node and run the following command to restore etcd quorum:
$ sudo -E /usr/local/bin/quorum-restore.shAfter a few minutes, the nodes that went down are automatically synchronized with the node that the recovery script was run on. Any remaining online nodes automatically rejoin the new etcd cluster created by the
quorum-restore.shscript. This process takes a few minutes.Verify that the local etcd container is running on the host by using the container runtime CLI:
$ sudo crictl ps --name '^etcd$'- Exit the SSH session.
Return to a three-node configuration if any nodes are offline. Repeat the following steps for each node that is offline to delete and re-create them. After the machines are re-created, a new revision is forced and etcd automatically scales up.
WarningFor installer-provisioned infrastructure and user-provisioned infrastructure, do not delete and re-create the machine for the recovery host.
If you use a user-provisioned bare-metal installation, you can re-create a control plane machine by using the same method that you used to originally create it.
ImportantBefore starting the newly provisioned node, you must delete the existing node object from the cluster by running the
oc delete node <node_name>command. Failing to delete the node object before reinstallating the node can cause conflicts and issues during the reinstallation process.For more information, see "Installing a user-provisioned cluster on bare metal".
If you are running installer-provisioned infrastructure, or you used the Machine API to create your machines, follow these steps:
ImportantFor bare-metal installations on installer-provisioned infrastructure, control plane machines are not re-created. For more information, see "Replacing a bare-metal control plane node".
In a terminal that has access to the cluster as a
cluster-adminuser, obtain the machine for one of the offline nodes by running the following command:$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE clustername-8qw5l-master-0 Running m4.xlarge us-east-1 us-east-1a 3h37m ip-10-0-131-183.ec2.internal aws:///us-east-1a/i-0ec2782f8287dfb7e stopped clustername-8qw5l-master-1 Running m4.xlarge us-east-1 us-east-1b 3h37m ip-10-0-143-125.ec2.internal aws:///us-east-1b/i-096c349b700a19631 running clustername-8qw5l-master-2 Running m4.xlarge us-east-1 us-east-1c 3h37m ip-10-0-154-194.ec2.internal aws:///us-east-1c/i-02626f1dba9ed5bba running clustername-8qw5l-worker-us-east-1a-wbtgd Running m4.large us-east-1 us-east-1a 3h28m ip-10-0-129-226.ec2.internal aws:///us-east-1a/i-010ef6279b4662ced running clustername-8qw5l-worker-us-east-1b-lrdxb Running m4.large us-east-1 us-east-1b 3h28m ip-10-0-144-248.ec2.internal aws:///us-east-1b/i-0cb45ac45a166173b running clustername-8qw5l-worker-us-east-1c-pkg26 Running m4.large us-east-1 us-east-1c 3h28m ip-10-0-170-181.ec2.internal aws:///us-east-1c/i-06861c00007751b0a runningIn the example output,
clustername-8qw5l-master-0is the control plane machine for the offline node,ip-10-0-131-183.ec2.internal.Delete the machine of the offline node by running the following command:
$ oc delete machine -n openshift-machine-api clustername-8qw5l-master-0Specify the name of the control plane machine for the offline node.
A new machine is automatically provisioned after deleting the machine of the offline node.
Verify that a new machine has been created by running the following command:
$ oc get machines -n openshift-machine-api -o wideExample output
NAME PHASE TYPE REGION ZONE AGE NODE PROVIDERID STATE clustername-8qw5l-master-1 Running m4.xlarge us-east-1 us-east-1b 3h37m ip-10-0-143-125.ec2.internal aws:///us-east-1b/i-096c349b700a19631 running clustername-8qw5l-master-2 Running m4.xlarge us-east-1 us-east-1c 3h37m ip-10-0-154-194.ec2.internal aws:///us-east-1c/i-02626f1dba9ed5bba running clustername-8qw5l-master-3 Provisioning m4.xlarge us-east-1 us-east-1a 85s ip-10-0-173-171.ec2.internal aws:///us-east-1a/i-015b0888fe17bc2c8 running clustername-8qw5l-worker-us-east-1a-wbtgd Running m4.large us-east-1 us-east-1a 3h28m ip-10-0-129-226.ec2.internal aws:///us-east-1a/i-010ef6279b4662ced running clustername-8qw5l-worker-us-east-1b-lrdxb Running m4.large us-east-1 us-east-1b 3h28m ip-10-0-144-248.ec2.internal aws:///us-east-1b/i-0cb45ac45a166173b running clustername-8qw5l-worker-us-east-1c-pkg26 Running m4.large us-east-1 us-east-1c 3h28m ip-10-0-170-181.ec2.internal aws:///us-east-1c/i-06861c00007751b0a runningIn the example output,
clustername-8qw5l-master-3is being created and is ready after the phase changes fromProvisioningtoRunning.It might take a few minutes for the new machine to be created. The etcd cluster Operator automatically synchronizes when the machine or node returns to a healthy state.
- For each node that is offline, repeat the previous steps to delete and re-create the node.
Wait until the control plane recovers by running the following command:
$ oc adm wait-for-stable-clusterNoteIt can take up to 15 minutes for the control plane to recover.
Troubleshooting
If you see no progress rolling out the etcd static pods, you can force redeployment from the etcd cluster Operator by running the following command:
$ oc patch etcd cluster -p='{"spec": {"forceRedeploymentReason": "recovery-'"$(date --rfc-3339=ns )"'"}}' --type=merge
6.4.3. Restoring to an earlier cluster state Copy linkLink copied to clipboard!
To return your OpenShift Container Platform cluster to a known good state, restore from a saved etcd snapshot after quorum loss or critical resource deletion. Understanding restore impact helps you decide whether rollback is appropriate before you begin.
6.4.3.1. About restoring to an earlier cluster state Copy linkLink copied to clipboard!
To assess restore risks before you choose rollback as a last resort, review how an etcd snapshot restore affects your OpenShift Container Platform cluster, including Operators, workloads, and persistent storage.
You can use an etcd backup to restore your cluster to an earlier state. This can be used to recover from the following situations:
- The cluster has lost the majority of control plane hosts and quorum.
- An administrator has deleted something critical and must restore to recover the cluster.
If applicable, you might also need to recover from expired control plane certificates.
Restoring to an earlier 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 cannot retrieve data using the Kubernetes API server, then etcd is available and you should not restore using an etcd backup.
Restoring etcd effectively takes a cluster back in time and all clients experience a conflicting, parallel history. This can impact the behavior of watching components like kubelets, Kubernetes controller managers, persistent volume controllers, and OpenShift Container Platform Operators, including the network Operator.
It can cause Operator churn when the content in etcd does not match the actual content on disk, causing Operators for the Kubernetes API server, Kubernetes controller manager, Kubernetes scheduler, and etcd to get stuck when files on disk conflict with content in etcd. This can require manual actions to resolve the issues.
In extreme cases, the cluster can lose track of persistent volumes, delete critical workloads that no longer exist, reimage machines, and rewrite CA bundles with expired certificates.
6.4.3.2. Restoring to an earlier cluster state for a single node Copy linkLink copied to clipboard!
To restore your OpenShift Container Platform cluster on a single node, use a saved etcd snapshot to roll back to an earlier state after quorum loss or critical data deletion.
When you restore your cluster, you must use an etcd backup that was taken from the same z-stream release. For example, an OpenShift Container Platform 4.22.2 cluster must use an etcd backup that was taken from 4.22.2.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole through a certificate-basedkubeconfigfile. - You have SSH access to control plane hosts.
-
You have a backup directory containing both the
etcdsnapshot and the resources for the static pods, which were from the same backup. The file names in the directory must be in the following formats:snapshot_<datetimestamp>.dbandstatic_kuberesources_<datetimestamp>.tar.gz.
Procedure
Use SSH to connect to the single node and copy the etcd backup to the
/home/coredirectory by running the following command:$ cp <etcd_backup_directory> /home/coreTo restore the cluster from an earlier backup on the single node, run the following command:
$ sudo -E /usr/local/bin/cluster-restore.sh /home/core/<etcd_backup_directory>- Exit the SSH session.
Monitor the recovery progress of the control plane by running the following command:
$ oc adm wait-for-stable-clusterNoteIt can take up to 15 minutes for the control plane to recover.
6.4.3.3. Restoring to an earlier cluster state for more than one node Copy linkLink copied to clipboard!
To restore your OpenShift Container Platform cluster with more than one control plane node to an earlier state, use a saved etcd snapshot after quorum loss or critical data deletion.
For a Two-Node with Fencing (TNF) setup, a single surviving node can continue to operate in degraded mode. Use a saved etcd backup to restore an earlier cluster state if only one node is operational, or when both nodes have failed and you need to restart the cluster from a known safe state. In both cases, perform the restore procedure on a single node. The peer node automatically synchronizes data with the restored node when it rejoins the cluster.
Before you restore from backup on the recovery host, shut down etcd on enough control plane nodes so the remaining members cannot form a quorum:
- Shut down etcd on 2 hosts in a 3-node cluster.
- Shut down etcd on 3 hosts in a 4-node or 5-node cluster.
If too few hosts are shut down, the other etcd members might still form a quorum and continue service while you restore.
If your cluster uses a control plane machine set, see "Recovering a degraded etcd Operator" in the control plane machine set troubleshooting topic for an etcd recovery procedure. For OpenShift Container Platform on a single node, follow the procedure to restore to an earlier cluster state for a single node.
When you restore your cluster, you must use an etcd backup that was taken from the same z-stream release. For example, an OpenShift Container Platform 4.22.2 cluster must use an etcd backup that was taken from 4.22.2.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole through a certificate-basedkubeconfigfile, like the one that was used during installation. - You have a healthy control plane host to use as the recovery host.
- You have SSH access to control plane hosts.
-
You have a backup directory containing both the
etcdsnapshot and the resources for the static pods, which were from the same backup. The file names in the directory must be in the following formats:snapshot_<datetimestamp>.dbandstatic_kuberesources_<datetimestamp>.tar.gz. - Control plane nodes are accessible or bootable.
For non-recovery control plane nodes, it is not required to establish SSH connectivity or to stop the static pods. You can delete and re-create other non-recovery, control plane machines, one by one.
Procedure
- Select a control plane host to use as the recovery host. This is the host that you run the restore operation on.
Establish SSH connectivity to each of the control plane nodes, including the recovery host.
kube-apiserverbecomes inaccessible after the restore process starts, so you cannot access the control plane nodes. Establish SSH connectivity to each control plane host in a separate terminal.ImportantIf you do not complete this step, you cannot access the control plane hosts to complete the restore procedure, and you cannot recover your cluster from this state.
Using SSH, connect to each control plane node to disable etcd by running the following command:
$ sudo -E /usr/local/bin/disable-etcd.shCopy the etcd backup directory to the recovery control plane host.
This procedure assumes that you copied the
backupdirectory containing the etcd snapshot and the resources for the static pods to the/home/core/directory of your recovery control plane host.Use SSH to connect to the recovery host. Restore the cluster from an earlier backup by running the following command:
$ sudo -E /usr/local/bin/cluster-restore.sh /home/core/<etcd-backup-directory>- Exit the SSH session.
When the API responds, turn off the etcd Operator quorum guard by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": {"useUnsupportedUnsafeNonHANonProductionUnstableEtcd": true}}}'ImportantFor a TNF setup, do not:
- Change the etcd Operator quorum setting.
- Turn the etcd Operator quorum off.
- Turn the etcd Operator quorum back on.
Monitor the recovery progress of the control plane by running the following command:
$ oc adm wait-for-stable-clusterNoteIt can take up to 15 minutes for the control plane to recover. Wait for the control plane to recover before using the next step.
Enable the quorum guard by running the following command:
$ oc patch etcd/cluster --type=merge -p '{"spec": {"unsupportedConfigOverrides": null}}'
Troubleshooting
If the etcd static pods do not roll out, you can manually force an etcd redeployment from the cluster-etcd-operator by running the following command:
$ oc patch etcd cluster -p='{"spec": {"forceRedeploymentReason": "recovery-'"$(date --rfc-3339=ns )"'"}}' --type=merge
6.4.3.4. Issues and workarounds for restoring a persistent storage state Copy linkLink copied to clipboard!
To restore workloads safely after an etcd snapshot restore, identify and resolve outdated persistent storage references, including volumes, credentials, attachments, and devices on your OpenShift Container Platform cluster.
If your OpenShift Container Platform cluster uses persistent storage of any form, a state of the cluster is typically stored outside etcd. When you restore from an etcd backup, the status of the workloads in OpenShift Container Platform is also restored. However, if the etcd snapshot is old, the status might be invalid or outdated.
The contents of persistent volumes (PVs) are never part of the etcd snapshot. When you restore an OpenShift Container Platform cluster from an etcd snapshot, non-critical workloads might gain access to critical data, or vice-versa.
The following are some example scenarios that produce an out-of-date status:
- MySQL database is running in a pod backed up by a PV object. Restoring OpenShift Container Platform from an etcd snapshot does not bring back the volume on the storage provider, and does not produce a running MySQL pod, despite the pod repeatedly attempting to start. You must manually restore this pod by restoring the volume on the storage provider, and then editing the PV to point to the new volume.
- Pod P1 is using volume A, which is attached to node X. If the etcd snapshot is taken while another pod uses the same volume on node Y, then when the etcd restore is performed, pod P1 might not be able to start correctly due to the volume still being attached to node Y. OpenShift Container Platform is not aware of the attachment, and does not automatically detach it. When this occurs, the volume must be manually detached from node Y so that the volume can attach on node X, and then pod P1 can start.
- Cloud provider or storage provider credentials were updated after the etcd snapshot was taken. This causes any CSI drivers or Operators that depend on those credentials to not work. You might have to manually update the credentials required by those drivers or Operators.
A device is removed or renamed from OpenShift Container Platform nodes after the etcd snapshot is taken. The Local Storage Operator creates symlinks for each PV that it manages from
/dev/disk/by-idor/devdirectories. This situation might cause the local PVs to refer to devices that no longer exist.To fix this problem, an administrator must:
- Manually remove the PVs with invalid devices.
- Remove symlinks from respective nodes.
-
Delete
LocalVolumeorLocalVolumeSetobjects. For more information, see "Deleting the Local Storage Operator resources".
6.4.4. Recovering from expired control plane certificates Copy linkLink copied to clipboard!
You can restore kubelet certificates on your OpenShift Container Platform cluster by approving pending certificate signing requests (CSRs) after control plane certificates expire. Approved CSRs return nodes to a healthy state.
6.4.4.1. Recovering from expired control plane certificates Copy linkLink copied to clipboard!
You can restore kubelet certificates by manually approving pending node-bootstrapper certificate signing requests (CSRs) and, on user-provisioned installations, kubelet serving CSRs. Approved CSRs return nodes to a healthy state after control plane certificates expire.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have access to the OpenShift CLI (
oc).
Procedure
Get the list of current CSRs by running the following command:
$ oc get csrExample output
NAME AGE SIGNERNAME REQUESTOR CONDITION csr-2s94x 8m3s kubernetes.io/kubelet-serving system:node:<node_name> Pending csr-4bd6t 8m3s kubernetes.io/kubelet-serving system:node:<node_name> Pending csr-4hl85 13m kubernetes.io/kube-apiserver-client-kubelet system:serviceaccount:openshift-machine-config-operator:node-bootstrapper Pending csr-zhhhp 3m8s kubernetes.io/kube-apiserver-client-kubelet system:serviceaccount:openshift-machine-config-operator:node-bootstrapper Pending ...In the example output, CSRs with a
SIGNERNAMEofkubernetes.io/kubelet-servingare kubelet serving CSRs. You see this CSR type on user-provisioned installations. CSRs with aSIGNERNAMEofkubernetes.io/kube-apiserver-client-kubeletand anode-bootstrapperrequestor arenode-bootstrapperCSRs that you must approve to restore kubelet certificates.Review the details of a CSR to verify that it is valid by running the following command:
$ oc describe csr <csr_name><csr_name>is the name of a CSR from the list of current CSRs.Approve each valid
node-bootstrapperCSR by running the following command:$ oc adm certificate approve <csr_name>For user-provisioned installations, approve each valid kubelet serving CSR by running the following command:
$ oc adm certificate approve <csr_name>