Skip to content

Commit dbd5b6f

Browse files
authored
fix: add autoscaling eviction annotation to catalog pods to enable proper draining of nodes (#2669)
Signed-off-by: Daniel Sover <[email protected]>
1 parent c7b6534 commit dbd5b6f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/controller/registry/reconciler/reconciler.go

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const (
2727
CatalogPriorityClassKey string = "operatorframework.io/priorityclass"
2828
// PodHashLabelKey is the key of a label for podspec hash information
2929
PodHashLabelKey = "olm.pod-spec-hash"
30+
//ClusterAutoscalingAnnotation is the annotation that enables the cluster autoscaler to evict catalog pods
31+
ClusterAutoscalingAnnotationKey string = "cluster-autoscaler.kubernetes.io/safe-to-evict"
3032
)
3133

3234
// RegistryEnsurer describes methods for ensuring a registry exists.
@@ -207,6 +209,15 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN
207209
}
208210
labels[PodHashLabelKey] = hashPodSpec(pod.Spec)
209211
pod.SetLabels(labels)
212+
213+
// add eviction annotation to enable the cluster autoscaler to evict the pod in order to drain the node
214+
// since catalog pods are not backed by a controller, they cannot be evicted by default
215+
if annotations == nil {
216+
annotations = make(map[string]string)
217+
}
218+
annotations[ClusterAutoscalingAnnotationKey] = "true"
219+
pod.SetAnnotations(annotations)
220+
210221
return pod
211222
}
212223

0 commit comments

Comments
 (0)