Skip to content

Add eviction annotation for theatre-secrets-install#504

Closed
epatmalnieks-gc wants to merge 58 commits into
masterfrom
add-eviction-annotation
Closed

Add eviction annotation for theatre-secrets-install#504
epatmalnieks-gc wants to merge 58 commits into
masterfrom
add-eviction-annotation

Conversation

@epatmalnieks-gc

Copy link
Copy Markdown

The theatre-secrets-install init container mounts an emptyDir volume to share secrets into the main container. The cluster autoscaler treats any pod with a local emptyDir volume as unsafe to evict, which can prevent nodes from being scaled down.
This PR introduces a change where the webhook now sets cluster-autoscaler.kubernetes.io/safe-to-evict-local-volumes: theatre-secrets-install on any pod it mutates, which signals the cluster autoscaler that it is safe to evict this volume.

goelozev and others added 30 commits March 16, 2026 16:59
Co-authored-by: Isaac James <isaac.james@hotmail.co.uk>
Co-authored-by: isaacjames <isaac.james@gocardless.com>
Co-authored-by: Emil Lozev <elozev@gocardless.com>
Co-authored-by: isaacjames <isaac.james@gocardless.com>
filipegalo-gc
filipegalo-gc previously approved these changes Jun 17, 2026

@0x0013 0x0013 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in chat, you will likely want to base this PR on top of pre-release-5.1.0 branch.

I've also added a suggestion comment.

Comment on lines +207 to +217
if mutatedPod.Annotations == nil {
mutatedPod.Annotations = map[string]string{}
}
if existing, ok := mutatedPod.Annotations[SafeToEvictLocalVolumesAnnotation]; ok {
if !slices.Contains(strings.Split(existing, ","), SecretsInstallVolume) {
mutatedPod.Annotations[SafeToEvictLocalVolumesAnnotation] = existing + "," + SecretsInstallVolume
}
} else {
mutatedPod.Annotations[SafeToEvictLocalVolumesAnnotation] = SecretsInstallVolume
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth using the k8s apimachinery provided functions, something like:

import (
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ...

	if metav1.HasAnnotation(mutatedPod.ObjectMeta, SafeToEvictLocalVolumesAnnotation) {
		existing := mutatedPod.GetAnnotations()[SafeToEvictLocalVolumesAnnotation]

		if !slices.Contains(strings.Split(existing, ","), SecretsInstallVolume) {
			metav1.SetMetaDataAnnotation(
				&mutatedPod.ObjectMeta,
				SafeToEvictLocalVolumesAnnotation,
				existing+","+SecretsInstallVolume,
			)
		}
	} else {
		metav1.SetMetaDataAnnotation(
			&mutatedPod.ObjectMeta,
			SafeToEvictLocalVolumesAnnotation,
			SecretsInstallVolume,
		)
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants