add karpenter do-not-disrupt policy for v1#1421
Open
anushkaaaaaaaa wants to merge 1 commit intokyverno:mainfrom
Open
add karpenter do-not-disrupt policy for v1#1421anushkaaaaaaaa wants to merge 1 commit intokyverno:mainfrom
anushkaaaaaaaa wants to merge 1 commit intokyverno:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Kyverno policy to support Karpenter v1.x by applying the karpenter.sh/do-not-disrupt: true annotation to Pods created from Jobs and CronJobs, preventing Karpenter from disrupting nodes running those workloads.
Changes:
- Introduces
add-karpenter-donot-disruptClusterPolicy to mutate Job and CronJob pod templates with the new annotation. - Adds Artifact Hub package metadata for the new policy.
- Adds Kyverno CLI tests and Chainsaw integration tests (resources + expected patched outputs).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| karpenter/add-karpenter-donot-disrupt/artifacthub-pkg.yml | Adds Artifact Hub package metadata for the new policy. |
| karpenter/add-karpenter-donot-disrupt/add-karpenter-donot-disrupt.yaml | New ClusterPolicy mutating Jobs/CronJobs to add karpenter.sh/do-not-disrupt. |
| karpenter/add-karpenter-donot-disrupt/.kyverno-test/resource.yaml | Kyverno CLI test input resources (Job + CronJob). |
| karpenter/add-karpenter-donot-disrupt/.kyverno-test/patched01.yaml | Expected Kyverno CLI patched Job output. |
| karpenter/add-karpenter-donot-disrupt/.kyverno-test/patched02.yaml | Expected Kyverno CLI patched CronJob output. |
| karpenter/add-karpenter-donot-disrupt/.kyverno-test/kyverno-test.yaml | Kyverno CLI test harness configuration. |
| karpenter/add-karpenter-donot-disrupt/.chainsaw-test/chainsaw-test.yaml | Chainsaw test steps applying policy/resources and asserting outputs. |
| karpenter/add-karpenter-donot-disrupt/.chainsaw-test/policy-ready.yaml | Expected “policy ready” assertion manifest for Chainsaw. |
| karpenter/add-karpenter-donot-disrupt/.chainsaw-test/resource-others.yaml | Additional Chainsaw test inputs to validate overwriting existing annotation values. |
| karpenter/add-karpenter-donot-disrupt/.chainsaw-test/patched03.yaml | Expected Chainsaw patched Job output (with extra annotations preserved). |
| karpenter/add-karpenter-donot-disrupt/.chainsaw-test/patched04.yaml | Expected Chainsaw patched CronJob output (with extra annotations preserved). |
Comments suppressed due to low confidence (1)
karpenter/add-karpenter-donot-disrupt/artifacthub-pkg.yml:23
artifacthub-pkg.ymlfiles in this repo include adigestfield (for example,karpenter/add-karpenter-donot-evict/artifacthub-pkg.yml:23). This new package metadata is missingdigest, which may break Artifact Hub packaging/validation. Please add the appropriatedigestentry for this policy package, consistent with the otherartifacthub-pkg.ymlfiles.
annotations:
kyverno/category: "Karpenter, EKS Best Practices"
kyverno/kubernetesVersion: "1.23"
kyverno/subject: "Pod"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
karpenter/add-karpenter-donot-disrupt/.chainsaw-test/policy-ready.yaml
Outdated
Show resolved
Hide resolved
Signed-off-by: Anushka Sharan <anushkasharan05@gmail.com>
fe18881 to
f7c73e3
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.
Related issue
Fixes #1191
Proposed Changes
Add a new Karpenter policy
add-karpenter-donot-disruptfor Karpenter v1.0+.Starting with Karpenter v1.0, the
karpenter.sh/do-not-evictannotation has been replaced bykarpenter.sh/do-not-disrupt. This policy mutates Jobs and CronJobs so that Pods spawned by them will contain thekarpenter.sh/do-not-disrupt: trueannotation, preventing Karpenter from disrupting nodes running these workloads.Reference: https://karpenter.sh/v1.0/upgrading/v1-migration/
Checklist