Files
kyverno-2026-example/02-validation/01-resource-validation/require-min-replicas-production.yaml
2026-04-08 20:22:14 +07:00

32 lines
1.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-min-replicas-production
annotations:
policies.kyverno.io/title: "Минимальное количество реплик в production"
policies.kyverno.io/category: Availability
policies.kyverno.io/severity: high
policies.kyverno.io/subject: Deployment
policies.kyverno.io/description: >-
В namespace production требуется минимум 2 реплики для Deployment.
Одна реплика = single point of failure при обновлении ноды или пода.
spec:
validationFailureAction: Enforce
background: true
rules:
- name: check-min-replicas
match:
resources:
kinds:
- Deployment
namespaces:
- production
validate:
message: >-
Deployment '{{ request.object.metadata.name }}' в production
имеет {{ request.object.spec.replicas }} реплику(и).
Минимально требуется 2 реплики для обеспечения доступности.
pattern:
spec:
replicas: ">=2"