When a Pod requests an emptyDir, by default it does not have a size limit which may allow it to consume excess or all of the space in the medium backing the volume. This can quickly overrun a Node and may result in a denial of service for other workloads. This policy adds a sizeLimit field to all Pods mounting emptyDir volumes, if not present, and sets it to 100Mi.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: add-emptydir-sizelimitannotations:pod-policies.kyverno.io/autogen-controllers: nonepolicies.kyverno.io/title: Add emptyDir sizeLimitpolicies.kyverno.io/category: Otherpolicies.kyverno.io/subject: Podpolicies.kyverno.io/minversion: 1.6.0kyverno.io/kyverno-version: 1.7.3,1.8.0-rc2kyverno.io/kubernetes-version: "1.24"policies.kyverno.io/description: When a Pod requests an emptyDir, by default it does not have a size limit which may allow it to consume excess or all of the space in the medium backing the volume. This can quickly overrun a Node and may result in a denial of service for other workloads. This policy adds a sizeLimit field to all Pods mounting emptyDir volumes, if not present, and sets it to 100Mi.spec:rules:- name: mutate-emptydirmatch:any:- resources:kinds:- Podmutate:foreach:- list: request.object.spec.volumes[]preconditions:all:- key: "{{element.keys(@)}}"operator: AnyInvalue: emptyDir- key: "{{element.emptyDir.sizeLimit || ''}}"operator: Equalsvalue: ""patchesJson6902: |-- path: "/spec/volumes/{{elementIndex}}/emptyDir/sizeLimit"op: addvalue: 100Mi
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.
CAST AI will not downscale a node that includes a pod with the autoscaling.cast.ai/removal-disabled="true" label on it, this protects sensitive workloads from being evicted and can be attributed to any pod to protect against unwanted downscaling. This policy will mutate jobs and cronjobs to add the removal-disabled label to protect against eviction.