All Policies
Add Pod Disruption Budget
A PodDisruptionBudget limits the number of Pods of a replicated application that are down simultaneously from voluntary disruptions. For example, a quorum-based application would like to ensure that the number of replicas running is never brought below the number needed for a quorum. As an application owner, you can create a PodDisruptionBudget (PDB) for each application. This policy will create a PDB resource whenever a new Deployment is created.
Policy Definition
/other/create-default-pdb/create-default-pdb.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: create-default-pdb
5 annotations:
6 policies.kyverno.io/title: Add Pod Disruption Budget
7 policies.kyverno.io/category: Sample
8 kyverno.io/kyverno-version: 1.6.2
9 policies.kyverno.io/minversion: 1.6.0
10 policies.kyverno.io/subject: Deployment
11 policies.kyverno.io/description: >-
12 A PodDisruptionBudget limits the number of Pods of a replicated application that
13 are down simultaneously from voluntary disruptions. For example, a quorum-based
14 application would like to ensure that the number of replicas running is never brought
15 below the number needed for a quorum. As an application owner, you can create a PodDisruptionBudget (PDB)
16 for each application. This policy will create a PDB resource whenever a new Deployment is created.
17spec:
18 rules:
19 - name: create-default-pdb
20 match:
21 any:
22 - resources:
23 kinds:
24 - Deployment
25 generate:
26 apiVersion: policy/v1
27 kind: PodDisruptionBudget
28 name: "{{request.object.metadata.name}}-default-pdb"
29 namespace: "{{request.object.metadata.namespace}}"
30 data:
31 spec:
32 minAvailable: 1
33 selector: "{{request.object.spec.selector}}"