Liveness and readiness probes need to be configured to correctly manage a Pod's lifecycle during deployments, restarts, and upgrades. For each Pod, a periodic `livenessProbe` is performed by the kubelet to determine if the Pod's containers are running or need to be restarted. A `readinessProbe` is used by Services and Deployments to determine if the Pod is ready to receive network traffic. This policy validates that all containers have one of livenessProbe, readinessProbe, or startupProbe defined.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: require-pod-probesannotations:pod-policies.kyverno.io/autogen-controllers: DaemonSet,Deployment,StatefulSetpolicies.kyverno.io/title: Require Pod Probespolicies.kyverno.io/category: Best Practices, EKS Best Practicespolicies.kyverno.io/severity: mediumpolicies.kyverno.io/subject: Podpolicies.kyverno.io/description: Liveness and readiness probes need to be configured to correctly manage a Pod's lifecycle during deployments, restarts, and upgrades. For each Pod, a periodic `livenessProbe` is performed by the kubelet to determine if the Pod's containers are running or need to be restarted. A `readinessProbe` is used by Services and Deployments to determine if the Pod is ready to receive network traffic. This policy validates that all containers have one of livenessProbe, readinessProbe, or startupProbe defined.spec:validationFailureAction: Auditbackground: truerules:- name: validate-probesmatch:any:- resources:kinds:- Podpreconditions:all:- key: "{{request.operation || 'BACKGROUND'}}"operator: AnyInvalue:- CREATE- UPDATEvalidate:message: Liveness, readiness, or startup probes are required for all containers.foreach:- list: request.object.spec.containers[]deny:conditions:all:- key: livenessProbeoperator: AllNotInvalue: "{{ element.keys(@)[] }}"- key: startupProbeoperator: AllNotInvalue: "{{ element.keys(@)[] }}"- key: readinessProbeoperator: AllNotInvalue: "{{ element.keys(@)[] }}"
This policy performs some best practices validation on Application fields. Path or chart must be specified but never both. And destination.name or destination.server must be specified but never both.
This policy prevents the use of the default project in an Application.
This policy prevents updates to the project field after an Application is created.