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. This policy prevents changes or deletions to a 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: protect-node-label-fooannotations:policies.kyverno.io/title: Restrict node label changespolicies.kyverno.io/category: Samplepolicies.kyverno.io/subject: Node, Labelpolicies.kyverno.io/minversion: 1.6.0policies.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. This policy prevents changes or deletions to a 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-value-changesmatch:any:- resources:kinds:- Nodevalidate:allowExistingViolations: falsemessage: Modifying the `foo` label on a Node is not allowed.deny:conditions:all:- key: "{{ request.object.metadata.labels.foo || '' }}"operator: NotEqualsvalue: ""- key: "{{ request.object.metadata.labels.foo || '' }}"operator: NotEqualsvalue: "{{ request.oldObject.metadata.labels.foo || '' }}"- name: prevent-label-key-removalmatch:any:- resources:kinds:- Nodepreconditions:all:- key: "{{ request.operation || 'BACKGROUND' }}"operator: Equalsvalue: UPDATE- key: "{{ request.oldObject.metadata.labels.foo || '' }}"operator: Equalsvalue: "?*"validate:allowExistingViolations: falsemessage: Removing the `foo` label on a Node is not allowed.pattern:metadata:labels:foo: "*"
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.
This policy ensures that the name of the ApplicationSet is the same value provided in the project.