From 2e05df62379418fc1b2d21ac912daa2c7a517c7c Mon Sep 17 00:00:00 2001 From: Xiwen Cheng Date: Thu, 20 Jun 2019 13:35:39 +0200 Subject: [PATCH] Restarting pods in an etcd cluster with PVC is safe. This is a simple fix that addresses Case C from https://github.com/coreos/etcd-operator/blob/master/doc/design/persistent_volumes_etcd_data.md It makes the etcd cluster with PVC able to recover from full k8s cluster outage. This fixes #1323 inspired by https://github.com/coreos/etcd-operator/issues/1323#issuecomment-359206459 --- pkg/util/k8sutil/k8sutil.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/util/k8sutil/k8sutil.go b/pkg/util/k8sutil/k8sutil.go index 8db36f18a..277a674a3 100644 --- a/pkg/util/k8sutil/k8sutil.go +++ b/pkg/util/k8sutil/k8sutil.go @@ -253,6 +253,8 @@ func AddEtcdVolumeToPod(pod *v1.Pod, pvc *v1.PersistentVolumeClaim) { vol.VolumeSource = v1.VolumeSource{ PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name}, } + // When PVC is used, make the pod auto recover in case of failure + pod.Spec.RestartPolicy = v1.RestartPolicyAlways } else { vol.VolumeSource = v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}} }