From 3ca664f1f8a9bb465b71c262c14c8861de12a01a Mon Sep 17 00:00:00 2001 From: Jedri Visser Date: Wed, 13 Oct 2021 18:00:31 +0200 Subject: [PATCH] Fix etcd operator to work with k8s 1.21 Annotation `service.alpha.kubernetes.io/tolerate-unready-endpoints` stopped working in k8s 1.21 It has been deprecated for a long time, see: https://github.com/kubernetes/kubernetes/blob/v1.21.5/pkg/controller/endpoint/endpoints_controller.go#L80 Now using the new way --- doc/alpha-features.md | 19 ------------------- pkg/util/k8sutil/k8sutil.go | 13 ++++--------- 2 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 doc/alpha-features.md diff --git a/doc/alpha-features.md b/doc/alpha-features.md deleted file mode 100644 index 83c301367..000000000 --- a/doc/alpha-features.md +++ /dev/null @@ -1,19 +0,0 @@ -# Alpha Features - -Tracking document for alpha features of Kubernetes that etcd operator makes use of. - -We track these alpha features as their behavior may change or be deprecated between Kubernetes versions. -Therefore clusters that use these features need to keep track of any potential changes in upstream releases. -See the upstream [api versioning documentation](https://github.com/kubernetes/community/blob/master/contributors/devel/api_changes.md#alpha-beta-and-stable-versions) for more information. - - -### TolerateUnreadyEndpointsAnnotation - -Used by the etcd client and peer service object. - -This alpha annotation will retain the endpoints even if the etcd pod isn't ready. -This feature is always enabled in endpoint controller in k8s even it is alpha. - -References: -- https://github.com/coreos/etcd-operator/issues/622 -- https://github.com/coreos/etcd-operator/issues/1257 diff --git a/pkg/util/k8sutil/k8sutil.go b/pkg/util/k8sutil/k8sutil.go index 357912453..738bc14f8 100644 --- a/pkg/util/k8sutil/k8sutil.go +++ b/pkg/util/k8sutil/k8sutil.go @@ -21,7 +21,6 @@ import ( "net" "net/url" "os" - "strconv" "strings" "time" @@ -75,7 +74,6 @@ const ( defaultDNSTimeout = int64(0) ) -const TolerateUnreadyEndpointsAnnotation = "service.alpha.kubernetes.io/tolerate-unready-endpoints" func GetEtcdVersion(pod *v1.Pod) string { return pod.Annotations[etcdVersionAnnotationKey] @@ -254,15 +252,12 @@ func newEtcdServiceManifest(svcName, clusterName, clusterIP string, ports []v1.S ObjectMeta: metav1.ObjectMeta{ Name: svcName, Labels: labels, - Annotations: map[string]string{ - TolerateUnreadyEndpointsAnnotation: strconv.FormatBool(publishNotReadyAddresses), - }, }, Spec: v1.ServiceSpec{ - Ports: ports, - Selector: labels, - ClusterIP: clusterIP, - // PublishNotReadyAddresses: publishNotReadyAddresses, // TODO(ckoehn): Activate once TolerateUnreadyEndpointsAnnotation is deprecated. + Ports: ports, + Selector: labels, + ClusterIP: clusterIP, + PublishNotReadyAddresses: publishNotReadyAddresses, }, } return svc