Rather than creating a deny list of annotations, it may be more useful to invert that list and create an allow list which then denies any others. This policy demonstrates how to allow two annotations with a specific key name of fluxcd.io/ while denying others that do not meet the pattern.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: allowed-annotationsannotations:policies.kyverno.io/title: Allowed Annotationspolicies.kyverno.io/category: Otherpolicies.kyverno.io/severity: mediumkyverno.io/kyverno-version: 1.6.0policies.kyverno.io/minversion: 1.6.0kyverno.io/kubernetes-version: "1.23"policies.kyverno.io/subject: Pod, Annotationpolicies.kyverno.io/description: Rather than creating a deny list of annotations, it may be more useful to invert that list and create an allow list which then denies any others. This policy demonstrates how to allow two annotations with a specific key name of fluxcd.io/ while denying others that do not meet the pattern.spec:validationFailureAction: Auditbackground: truerules:- name: allowed-fluxcd-annotationsmatch:any:- resources:kinds:- Podvalidate:message: The only approved FluxCD annotations are `fluxcd.io/cow` and `fluxcd.io/dog`.deny:conditions:all:- key: "{{ request.object.metadata.annotations.keys(@)[?contains(@, 'fluxcd.io/')] }}"operator: AnyNotInvalue:- fluxcd.io/cow- fluxcd.io/dog
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.