Back to 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.

View on GitHub

Policy Definition

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: deployment-has-multiple-replicas
annotations:
policies.kyverno.io/title: Require Multiple Replicas
policies.kyverno.io/category: Sample
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Deployment
policies.kyverno.io/minversion: 1.6.0
policies.kyverno.io/description: 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.
spec:
validationFailureAction: Audit
background: true
rules:
- name: deployment-has-multiple-replicas
match:
any:
- resources:
kinds:
- Deployment
validate:
message: Deployments should have more than one replica to ensure availability.
pattern:
spec:
replicas: ">1"

Related Policies