Kyverno allows cluster administrators to manage environment specific configurations independently of workload configurations and enforce configuration best practices for their clusters
- Ensure that your cluster has a rule mandating the inclusion of a specific label whenever a POD is created.
- Ensure that your cluster has a rule mandating the inclusion of resource quota limits whenever a POD is created.
- K8S Cluster(s)
kubectl create -f https://github.com/kyverno/kyverno/releases/download/v1.10.0/install.yaml
kubectl apply -f require-pod-labels.yml
kubectl apply -f require-pod-requests-limits.yml
kubectl run nginx-1 --image=nginx
You will receive the error below:
Error from server: admission webhook "validate.kyverno.svc-fail" denied the request:
resource Pod/default/nginx-1 was blocked due to the following policies
require-labels:
check-for-labels: 'validation error: The label `team` is required. rule check-for-labels
failed at path /metadata/labels/team/'
require-requests-limits:
validate-resources: 'validation error: CPU and memory resource requests and limits
are required. rule validate-resources failed at path /spec/containers/0/resources/limits/'
kubectl apply -f example-pod.yml
This will work: pod/nginx-2 created