This policy ensures that Deployments, ReplicaSets, StatefulSets, and DaemonSets are only allowed if they have a corresponding Horizontal Pod Autoscaler (HPA) configured in the same namespace. The policy checks for the presence of an HPA that targets the resource and denies the creation or update of the resource if no such HPA exists. This policy helps enforce scaling practices and ensures that resources are managed efficiently.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: check-hpa-existsannotations:policies.kyverno.io/title: Ensure HPA for Deploymentspolicies.kyverno.io/category: Otherpolicies.kyverno.io/severity: mediumkyverno.io/kyverno-version: 1.11.0policies.kyverno.io/minversion: 1.9.0kyverno.io/kubernetes-version: "1.28"policies.kyverno.io/subject: Deployment,ReplicaSet,StatefulSet,DaemonSetpolicies.kyverno.io/description: This policy ensures that Deployments, ReplicaSets, StatefulSets, and DaemonSets are only allowed if they have a corresponding Horizontal Pod Autoscaler (HPA) configured in the same namespace. The policy checks for the presence of an HPA that targets the resource and denies the creation or update of the resource if no such HPA exists. This policy helps enforce scaling practices and ensures that resources are managed efficiently.spec:validationFailureAction: Auditbackground: truerules:- name: validate-hpamatch:any:- resources:kinds:- Deployment- ReplicaSet- StatefulSet- DaemonSetcontext:- name: hpasapiCall:urlPath: /apis/autoscaling/v1/namespaces/{{ request.namespace }}/horizontalpodautoscalersjmesPath: items[].spec.scaleTargetRef.namevalidate:message: Deployment is not allowed without a corresponding HPA.deny:conditions:all:- key: "{{ request.object.metadata.name }}"operator: AnyNotInvalue: "{{ hpas }}"
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.