Applications may involve multiple replicas of the same Pod for availability as well as scale purposes, yet Kubernetes does not by default provide a solution for availability. This policy sets a Pod anti-affinity configuration on Deployments which contain an `app` label if it is not already present.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: insert-pod-antiaffinityannotations:policies.kyverno.io/title: Add Pod Anti-Affinitypolicies.kyverno.io/category: Samplepolicies.kyverno.io/subject: Deployment, Podpolicies.kyverno.io/minversion: 1.6.0policies.kyverno.io/description: Applications may involve multiple replicas of the same Pod for availability as well as scale purposes, yet Kubernetes does not by default provide a solution for availability. This policy sets a Pod anti-affinity configuration on Deployments which contain an `app` label if it is not already present.spec:rules:- name: insert-pod-antiaffinitymatch:any:- resources:kinds:- Deploymentpreconditions:all:- key: "{{request.object.spec.template.metadata.labels.app || ''}}"operator: NotEqualsvalue: ""mutate:patchStrategicMerge:spec:template:spec:+(affinity):+(podAntiAffinity):+(preferredDuringSchedulingIgnoredDuringExecution):- weight: 1podAffinityTerm:topologyKey: kubernetes.io/hostnamelabelSelector:matchExpressions:- key: appoperator: Invalues:- "{{request.object.spec.template.metadata.labels.app}}"
The Kubernetes cluster autoscaler does not evict pods that use hostPath or emptyDir volumes. To allow eviction of these pods, the annotation cluster-autoscaler.kubernetes.io/safe-to-evict=true must be added to the pods.
The Kubernetes cluster autoscaler does not evict pods that use hostPath or emptyDir volumes. To allow eviction of these pods, the annotation cluster-autoscaler.kubernetes.io/safe-to-evict=true must be added to the pods.
Tiller, found in Helm v2, has known security challenges. It requires administrative privileges and acts as a shared resource accessible to any authenticated user. Tiller can lead to privilege escalation as restricted users can impact other users. It is recommended to use Helm v3+ which does not contain Tiller for these reasons. This policy validates that there is not an image containing the name `tiller`.