This policy ensures that Ingress resources do not have certain disallowed annotations and that the ingress-nginx controller Pod is running an appropriate version of the image. It checks for the presence of the `nginx.ingress.kubernetes.io/server-snippet` annotation and disallows its usage, enforces specific values for `auth-tls-verify-client`, and ensures that the ingress-nginx controller image is of the required version.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: check-ingress-nginx-controller-version-and-annotation-policyannotations:policies.kyverno.io/title: Ensure Valid Ingress NGINX Controller and Annotationspolicies.kyverno.io/category: Ingress, Securitypolicies.kyverno.io/severity: highkyverno.io/kyverno-version: 1.11.0policies.kyverno.io/minversion: 1.9.0kyverno.io/kubernetes-version: "1.28"policies.kyverno.io/subject: Ingress, Podpolicies.kyverno.io/description: This policy ensures that Ingress resources do not have certain disallowed annotations and that the ingress-nginx controller Pod is running an appropriate version of the image. It checks for the presence of the `nginx.ingress.kubernetes.io/server-snippet` annotation and disallows its usage, enforces specific values for `auth-tls-verify-client`, and ensures that the ingress-nginx controller image is of the required version.spec:validationFailureAction: Auditbackground: truerules:- name: validate-ingress-annotationsmatch:resources:kinds:- Ingressvalidate:message: The annotation nginx.ingress.kubernetes.io/server-snippet is not allowed.pattern:metadata:annotations:X(nginx.ingress.kubernetes.io/server-snippet): ""- name: validate-auth-tls-verify-clientmatch:resources:kinds:- Ingressvalidate:message: auth-tls-verify-client annotation must be 'on', 'off', 'optional', or 'optional_no_ca'.deny:conditions:any:- key: "{{request.object.metadata.annotations.\"nginx.ingress.kubernetes.io/auth-tls-verify-client\"}}"operator: AnyNotInvalue:- "on"- "off"- optional- optional_no_ca- name: ensure-ingress-nginx-controller-version-patternmatch:resources:kinds:- Podvalidate:message: The ingress-nginx controller image version must start with v1.11.pattern:spec:containers:- name: controllerimage: registry.k8s.io/ingress-nginx/controller:v1.11.*- name: deny-lower-ingress-nginx-controller-versionsmatch:resources:kinds:- Podvalidate:message: The ingress-nginx controller image version must be v1.11.2 or greater.deny:conditions:- key: "{{ request.object.spec.containers[?(@.name=='controller')].image }}"operator: AnyInvalue:- registry.k8s.io/ingress-nginx/controller:v1.11.0- registry.k8s.io/ingress-nginx/controller:v1.11.1- registry.k8s.io/ingress-nginx/controller:v1.10.*- registry.k8s.io/ingress-nginx/controller:v1.9.*- registry.k8s.io/ingress-nginx/controller:v1.8.*- registry.k8s.io/ingress-nginx/controller:v1.7.*- registry.k8s.io/ingress-nginx/controller:v1.6.*- registry.k8s.io/ingress-nginx/controller:v1.5.*- registry.k8s.io/ingress-nginx/controller:v1.4.*- registry.k8s.io/ingress-nginx/controller:v1.3.*- registry.k8s.io/ingress-nginx/controller:v1.2.*- registry.k8s.io/ingress-nginx/controller:v1.1.*- registry.k8s.io/ingress-nginx/controller:v1.0.*
This policy prevents the use of the default project in an Application.
Services of type LoadBalancer when deployed inside AWS have support for transport encryption if it is enabled via an annotation. This policy requires that Services of type LoadBalancer contain the annotation service.beta.kubernetes.io/aws-load-balancer-ssl-cert with some value.
This policy prevents updates to the project field after an Application is created.