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.
apiVersion: policies.kyverno.io/v1alpha1kind: MutatingPolicymetadata:name: add-safe-to-evictannotations:policies.kyverno.io/title: Add Safe To Evictpolicies.kyverno.io/category: Otherpolicies.kyverno.io/subject: Pod,Annotationpolicies.kyverno.io/minversion: 1.6.0policies.kyverno.io/description: 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.spec:matchConstraints:resourceRules:- apiGroups:- ""apiVersions:- v1operations:- CREATE- UPDATEresources:- podsmatchConditions:- name: has-emptydir-or-hostpathexpression: |has(object.spec.volumes) &&object.spec.volumes.exists(v, has(v.emptyDir) || has(v.hostPath))- name: annotation-not-presentexpression: |!has(object.metadata.annotations) ||!object.metadata.annotations.exists(k, k == 'cluster-autoscaler.kubernetes.io/safe-to-evict')mutations:- patchType: ApplyConfigurationapplyConfiguration:expression: |Object{metadata: Object.metadata{annotations: {"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}}}
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.
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.
ReplicaSets serve as an intermediate controller for various Pod controllers like Deployments. When a new version of a Deployment is initiated, it generates a new ReplicaSet with the specified number of replicas and scales down the current one to zero. Consequently, numerous empty ReplicaSets may accumulate in the cluster, leading to clutter and potential false positives in policy reports if enabled. This cleanup policy is designed to remove empty ReplicaSets across the cluster within a specified timeframe, for instance, ReplicaSets created one day ago, ensuring the ability to rollback to previous ReplicaSets in case of deployment issues