VerticalPodAutoscaler (VPA) is useful to automatically adjust the resources assigned to Pods. It requires defining a specific target resource by kind and name. There are no built-in validation checks by the VPA controller to ensure that the target resource is associated with it. This policy ensures that the matching kind has a matching VPA.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: check-vpa-configurationannotations:policies.kyverno.io/title: Check for matching VerticalPodAutoscaler (VPA)policies.kyverno.io/category: Otherpolicies.kyverno.io/severity: mediumkyverno.io/kyverno-version: 1.11.4kyverno.io/kubernetes-version: "1.27"policies.kyverno.io/subject: Deployment, StatefulSet, ReplicaSet, DaemonSet, VerticalPodAutoscalerpolicies.kyverno.io/description: "VerticalPodAutoscaler (VPA) is useful to automatically adjust the resources assigned to Pods. It requires defining a specific target resource by kind and name. There are no built-in validation checks by the VPA controller to ensure that the target resource is associated with it. This policy ensures that the matching kind has a matching VPA. "spec:validationFailureAction: Auditbackground: falserules:- name: check-vpa-configurationmatch:any:- resources:kinds:- Deployment- StatefulSet- ReplicaSet- DaemonSetcontext:- name: vpasapiCall:urlPath: /apis/autoscaling.k8s.io/v1/namespaces/{{request.object.metadata.namespace}}/verticalpodautoscalersjmesPath: items[?spec.targetRef.kind=='{{ request.object.kind }}'].spec.targetRef.namevalidate:message: Workload '{{request.object.kind}}/{{request.object.metadata.name}}' requires a matching VerticalPodAutoscaler (VPA) in the '{{request.object.metadata.namespace}}' namespace.deny:conditions:all:- key: "{{ request.object.metadata.name }}"operator: NotInvalue: "{{ vpas }}"
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.