From dbd5b6f0d1dbc6981363c1345fa217629de97709 Mon Sep 17 00:00:00 2001 From: exdx Date: Fri, 29 Apr 2022 11:57:39 -0400 Subject: [PATCH] fix: add autoscaling eviction annotation to catalog pods to enable proper draining of nodes (#2669) Signed-off-by: Daniel Sover --- pkg/controller/registry/reconciler/reconciler.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/controller/registry/reconciler/reconciler.go b/pkg/controller/registry/reconciler/reconciler.go index 37aec2fa0c..4c76f93b62 100644 --- a/pkg/controller/registry/reconciler/reconciler.go +++ b/pkg/controller/registry/reconciler/reconciler.go @@ -27,6 +27,8 @@ const ( CatalogPriorityClassKey string = "operatorframework.io/priorityclass" // PodHashLabelKey is the key of a label for podspec hash information PodHashLabelKey = "olm.pod-spec-hash" + //ClusterAutoscalingAnnotation is the annotation that enables the cluster autoscaler to evict catalog pods + ClusterAutoscalingAnnotationKey string = "cluster-autoscaler.kubernetes.io/safe-to-evict" ) // RegistryEnsurer describes methods for ensuring a registry exists. @@ -207,6 +209,15 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN } labels[PodHashLabelKey] = hashPodSpec(pod.Spec) pod.SetLabels(labels) + + // add eviction annotation to enable the cluster autoscaler to evict the pod in order to drain the node + // since catalog pods are not backed by a controller, they cannot be evicted by default + if annotations == nil { + annotations = make(map[string]string) + } + annotations[ClusterAutoscalingAnnotationKey] = "true" + pod.SetAnnotations(annotations) + return pod }