Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: policies.kyverno.io/v1alpha1
kind: MutatingPolicy
metadata:
name: add-karpenter-donot-evict
name: add-karpenter-donot-disrupt
annotations:
policies.kyverno.io/title: Add Karpenter Do Not Evict
policies.kyverno.io/title: Add Karpenter Do Not Disrupt
policies.kyverno.io/category: Karpenter, EKS Best Practices
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Pod
Expand All @@ -21,15 +21,15 @@ spec:
object.kind == "Job" ?
(has(object.spec.template.metadata) ?
(has(object.spec.template.metadata.annotations) ?
[JSONPatch{op: "add", path: "/spec/template/metadata/annotations/" + jsonpatch.escapeKey("karpenter.sh/do-not-evict"), value: "true"}] :
[JSONPatch{op: "add", path: "/spec/template/metadata/annotations", value: {"karpenter.sh/do-not-evict": "true"}}]
[JSONPatch{op: "add", path: "/spec/template/metadata/annotations/" + jsonpatch.escapeKey("karpenter.sh/do-not-disrupt"), value: "true"}] :
[JSONPatch{op: "add", path: "/spec/template/metadata/annotations", value: {"karpenter.sh/do-not-disrupt": "true"}}]
) :
[JSONPatch{op: "add", path: "/spec/template/metadata", value: {"annotations": {"karpenter.sh/do-not-evict": "true"}}}]
[JSONPatch{op: "add", path: "/spec/template/metadata", value: {"annotations": {"karpenter.sh/do-not-disrupt": "true"}}}]
) :
(has(object.spec.jobTemplate.spec.template.metadata) ?
(has(object.spec.jobTemplate.spec.template.metadata.annotations) ?
[JSONPatch{op: "add", path: "/spec/jobTemplate/spec/template/metadata/annotations/" + jsonpatch.escapeKey("karpenter.sh/do-not-evict"), value: "true"}] :
[JSONPatch{op: "add", path: "/spec/jobTemplate/spec/template/metadata/annotations", value: {"karpenter.sh/do-not-evict": "true"}}]
[JSONPatch{op: "add", path: "/spec/jobTemplate/spec/template/metadata/annotations/" + jsonpatch.escapeKey("karpenter.sh/do-not-disrupt"), value: "true"}] :
[JSONPatch{op: "add", path: "/spec/jobTemplate/spec/template/metadata/annotations", value: {"karpenter.sh/do-not-disrupt": "true"}}]
) :
[JSONPatch{op: "add", path: "/spec/jobTemplate/spec/template/metadata", value: {"annotations": {"karpenter.sh/do-not-evict": "true"}}}]
)
[JSONPatch{op: "add", path: "/spec/jobTemplate/spec/template/metadata", value: {"annotations": {"karpenter.sh/do-not-disrupt": "true"}}}]
)
23 changes: 23 additions & 0 deletions karpenter-mpol/add-karpenter-donot-disrupt/artifacthub-pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: add-karpenter-donot-disrupt
version: 1.0.0
displayName: Add Karpenter Do Not Disrupt
createdAt: "2023-04-10T20:11:12.000Z"
description: >-
If a Pod exists with the annotation `karpenter.sh/do-not-disrupt: true` on a Node, and a request is made to delete the Node, Karpenter will not drain any Pods from that Node or otherwise try to delete the Node. This is useful for Pods that should run uninterrupted to completion. This policy mutates Jobs and CronJobs so that Pods spawned by them will contain the `karpenter.sh/do-not-disrupt: true` annotation.
install: |-
```shell
kubectl apply -f https://raw.githubusercontent.com/kyverno/policies/main/karpenter-mpol/add-karpenter-donot-disrupt/add-karpenter-donot-disrupt.yaml
```
keywords:
- kyverno
- Karpenter
- EKS Best Practices
readme: |
If a Pod exists with the annotation `karpenter.sh/do-not-disrupt: true` on a Node, and a request is made to delete the Node, Karpenter will not drain any Pods from that Node or otherwise try to delete the Node. This is useful for Pods that should run uninterrupted to completion. This policy mutates Jobs and CronJobs so that Pods spawned by them will contain the `karpenter.sh/do-not-disrupt: true` annotation.

Refer to the documentation for more details on Kyverno annotations: https://artifacthub.io/docs/topics/annotations/kyverno/
annotations:
kyverno/category: "Karpenter, EKS Best Practices"
kyverno/kubernetesVersion: "1.23"
kyverno/subject: "Pod"
digest: bf608d4be5190ec39a1a94ba7931d3cfd2cca758fb30215c74c093fcb8a42dfb
23 changes: 0 additions & 23 deletions karpenter-mpol/add-karpenter-donot-evict/artifacthub-pkg.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: add-karpenter-donot-evict
name: add-karpenter-do-not-disrupt
annotations:
policies.kyverno.io/title: Add Karpenter Do Not Evict
policies.kyverno.io/title: Add Karpenter Do Not Disrupt
policies.kyverno.io/category: Karpenter, EKS Best Practices
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Pod
kyverno.io/kyverno-version: 1.7.1
policies.kyverno.io/minversion: 1.6.0
kyverno.io/kubernetes-version: "1.23"
policies.kyverno.io/description: >-
If a Pod exists with the annotation `karpenter.sh/do-not-evict: true` on a Node,
If a Pod exists with the annotation `karpenter.sh/do-not-disrupt: true` on a Node,
and a request is made to delete the Node, Karpenter will not drain any Pods from
that Node or otherwise try to delete the Node. This is useful for Pods that should
run uninterrupted to completion. This policy mutates Jobs and CronJobs
so that Pods spawned by them will contain the `karpenter.sh/do-not-evict: true` annotation.
so that Pods spawned by them will contain the `karpenter.sh/do-not-disrupt: true` annotation.
spec:
rules:
- name: do-not-evict-jobs
- name: do-not-disrupt-jobs
match:
any:
- resources:
Expand All @@ -30,8 +30,8 @@ spec:
template:
metadata:
annotations:
karpenter.sh/do-not-evict: "true"
- name: do-not-evict-cronjobs
karpenter.sh/do-not-disrupt: "true"
- name: do-not-disrupt-cronjobs
match:
any:
- resources:
Expand All @@ -45,4 +45,4 @@ spec:
template:
metadata:
annotations:
karpenter.sh/do-not-evict: "true"
karpenter.sh/do-not-disrupt: "true"
23 changes: 23 additions & 0 deletions karpenter/add-karpenter-donot-disrupt/artifacthub-pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: add-karpenter-do-not-disrupt
version: 1.0.0
displayName: Add Karpenter Do Not Disrupt
createdAt: "2023-04-10T20:11:12.000Z"
description: >-
If a Pod exists with the annotation `karpenter.sh/do-not-disrupt: true` on a Node, and a request is made to delete the Node, Karpenter will not drain any Pods from that Node or otherwise try to delete the Node. This is useful for Pods that should run uninterrupted to completion. This policy mutates Jobs and CronJobs so that Pods spawned by them will contain the `karpenter.sh/do-not-disrupt: true` annotation.
install: |-
```shell
kubectl apply -f https://raw.githubusercontent.com/kyverno/policies/main/karpenter/add-karpenter-donot-disrupt/add-karpenter-donot-disrupt.yaml
```
keywords:
- kyverno
- Karpenter
- EKS Best Practices
readme: |
If a Pod exists with the annotation `karpenter.sh/do-not-disrupt: true` on a Node, and a request is made to delete the Node, Karpenter will not drain any Pods from that Node or otherwise try to delete the Node. This is useful for Pods that should run uninterrupted to completion. This policy mutates Jobs and CronJobs so that Pods spawned by them will contain the `karpenter.sh/do-not-disrupt: true` annotation.

Refer to the documentation for more details on Kyverno annotations: https://artifacthub.io/docs/topics/annotations/kyverno/
annotations:
kyverno/category: "Karpenter, EKS Best Practices"
kyverno/kubernetesVersion: "1.23"
kyverno/subject: "Pod"
digest: 97c2cd7156ae13003509bd6322ba3cdefc87a0027098c63af4fdb65dce66c662
23 changes: 0 additions & 23 deletions karpenter/add-karpenter-donot-evict/artifacthub-pkg.yml

This file was deleted.