All Policies
Add Pod priorityClassName
A Pod PriorityClass is used to provide a guarantee on the scheduling of a Pod relative to others. This policy adds the priorityClassName of `non-production` to any Pod deployed into a Namespace that does not have the label env=production.
Policy Definition
/other/add-pod-priorityclassname/add-pod-priorityclassname.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: add-pod-priorityclassname
5 annotations:
6 policies.kyverno.io/title: Add Pod priorityClassName
7 policies.kyverno.io/category: Other
8 policies.kyverno.io/severity: medium
9 policies.kyverno.io/subject: Pod
10 kyverno.io/kyverno-version: 1.7.1
11 policies.kyverno.io/minversion: 1.6.0
12 kyverno.io/kubernetes-version: "1.23"
13 policies.kyverno.io/description: >-
14 A Pod PriorityClass is used to provide a guarantee on the scheduling of a Pod relative to others.
15 This policy adds the priorityClassName of `non-production` to any Pod deployed
16 into a Namespace that does not have the label env=production.
17spec:
18 background: false
19 rules:
20 - name: add-priorityclass
21 match:
22 any:
23 - resources:
24 kinds:
25 - Pod
26 namespaceSelector:
27 matchExpressions:
28 - key: env
29 operator: NotIn
30 values:
31 - production
32 mutate:
33 patchesJson6902: |-
34 - op: remove
35 path: '/spec/priority'
36 - op: add
37 path: /spec/priorityClassName
38 value: 'non-production'