Skip to content

Commit

Permalink
fix: add autoscaling eviction annotation to catalog pods to enable pr…
Browse files Browse the repository at this point in the history
…oper draining of nodes (#2669)

Signed-off-by: Daniel Sover <dsover@redhat.com>
  • Loading branch information
exdx committed Apr 29, 2022
1 parent c7b6534 commit dbd5b6f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/controller/registry/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit dbd5b6f

Please sign in to comment.