Add eviction annotation for theatre-secrets-install#504
Closed
epatmalnieks-gc wants to merge 58 commits into
Closed
Add eviction annotation for theatre-secrets-install#504epatmalnieks-gc wants to merge 58 commits into
epatmalnieks-gc wants to merge 58 commits into
Conversation
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
previously approved these changes
Jun 17, 2026
0x0013
requested changes
Jun 17, 2026
0x0013
left a comment
Contributor
There was a problem hiding this comment.
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 | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
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,
)
}4e5ddc8 to
c4114b5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The theatre-secrets-install init container mounts an
emptyDirvolume to share secrets into the main container. The cluster autoscaler treats any pod with a localemptyDirvolume 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-installon any pod it mutates, which signals the cluster autoscaler that it is safe to evict this volume.