Node labels are critical pieces of metadata upon which many other applications and logic may depend and should not be altered or removed by regular users. Many cloud providers also use Node labels to signal specific functions to applications. This policy prevents setting of a new label called `foo` on cluster Nodes. Use of this policy requires removal of the Node resource filter in the Kyverno ConfigMap ([Node,*,*]). Due to Kubernetes CVE-2021-25735, this policy requires, at minimum, one of the following versions of Kubernetes: v1.18.18, v1.19.10, v1.20.6, or v1.21.0.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: restrict-node-label-creationannotations:policies.kyverno.io/title: Restrict node label creation in CEL expressionspolicies.kyverno.io/category: Sample in CELpolicies.kyverno.io/subject: Node, Labelkyverno.io/kyverno-version: 1.12.1kyverno.io/kubernetes-version: 1.26-1.27policies.kyverno.io/description: "Node labels are critical pieces of metadata upon which many other applications and logic may depend and should not be altered or removed by regular users. Many cloud providers also use Node labels to signal specific functions to applications. This policy prevents setting of a new label called `foo` on cluster Nodes. Use of this policy requires removal of the Node resource filter in the Kyverno ConfigMap ([Node,*,*]). Due to Kubernetes CVE-2021-25735, this policy requires, at minimum, one of the following versions of Kubernetes: v1.18.18, v1.19.10, v1.20.6, or v1.21.0."spec:validationFailureAction: Enforcebackground: falserules:- name: prevent-label-setmatch:any:- resources:kinds:- NodecelPreconditions:- name: operation-should-be-updateexpression: request.operation == 'UPDATE'- name: has-foo-labelexpression: object.metadata.?labels.?foo.hasValue()validate:cel:expressions:- expression: "false"message: Setting the `foo` label on a Node is not allowed.
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.