2023-09-18 00:24:26 +02:00
|
|
|
---
|
2019-12-10 09:51:15 -08:00
|
|
|
apiVersion: kyverno.io/v1
|
|
|
|
kind: ClusterPolicy
|
2023-09-18 00:24:26 +02:00
|
|
|
metadata:
|
2019-11-04 17:55:13 -08:00
|
|
|
annotations:
|
2019-11-11 18:21:16 -08:00
|
|
|
policies.kyverno.io/category: Workload Management
|
2023-09-18 00:24:26 +02:00
|
|
|
policies.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.
|
|
|
|
name: add-safe-to-evict
|
|
|
|
spec:
|
|
|
|
admission: true
|
|
|
|
background: true
|
|
|
|
rules:
|
|
|
|
- match:
|
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
|
|
|
mutate:
|
2020-09-23 04:49:09 +05:30
|
|
|
patchStrategicMerge:
|
2019-11-04 17:55:13 -08:00
|
|
|
metadata:
|
|
|
|
annotations:
|
2020-09-23 04:49:09 +05:30
|
|
|
+(cluster-autoscaler.kubernetes.io/safe-to-evict): "true"
|
2023-09-18 00:24:26 +02:00
|
|
|
spec:
|
|
|
|
volumes:
|
2021-09-13 18:59:28 +03:00
|
|
|
- <(emptyDir): {}
|
2023-09-18 00:24:26 +02:00
|
|
|
name: annotate-empty-dir
|
|
|
|
- match:
|
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
|
|
|
mutate:
|
2020-09-23 04:49:09 +05:30
|
|
|
patchStrategicMerge:
|
2019-11-05 12:28:44 -08:00
|
|
|
metadata:
|
|
|
|
annotations:
|
2020-09-23 04:49:09 +05:30
|
|
|
+(cluster-autoscaler.kubernetes.io/safe-to-evict): "true"
|
2023-09-18 00:24:26 +02:00
|
|
|
spec:
|
|
|
|
volumes:
|
2021-09-13 18:59:28 +03:00
|
|
|
- hostPath:
|
2023-09-18 00:24:26 +02:00
|
|
|
<(path): '*'
|
|
|
|
name: annotate-host-path
|
|
|
|
validationFailureAction: Audit
|