All Policies

Require Multiple Replicas

Deployments with a single replica cannot be highly available and thus the application may suffer downtime if that one replica goes down. This policy validates that Deployments have more than one replica.

Policy Definition

/other/require-deployments-have-multiple-replicas/require-deployments-have-multiple-replicas.yaml

 1apiVersion: kyverno.io/v1
 2kind: ClusterPolicy
 3metadata:
 4  name: deployment-has-multiple-replicas
 5  annotations:
 6    policies.kyverno.io/title: Require Multiple Replicas
 7    policies.kyverno.io/category: Sample
 8    policies.kyverno.io/severity: medium
 9    policies.kyverno.io/subject: Deployment
10    policies.kyverno.io/minversion: 1.6.0
11    policies.kyverno.io/description: >-
12      Deployments with a single replica cannot be highly available and thus the application
13      may suffer downtime if that one replica goes down. This policy validates that Deployments
14      have more than one replica.      
15spec:
16  validationFailureAction: audit
17  background: true
18  rules:
19    - name: deployment-has-multiple-replicas
20      match:
21        any:
22        - resources:
23            kinds:
24            - Deployment
25      validate:
26        message: "Deployments should have more than one replica to ensure availability."
27        pattern:
28          spec:
29            replicas: ">1"