2019-12-10 09:51:15 -08:00
|
|
|
apiVersion: kyverno.io/v1
|
|
|
|
kind: ClusterPolicy
|
2019-11-04 17:55:13 -08:00
|
|
|
metadata:
|
2019-12-10 09:51:15 -08:00
|
|
|
name: add-safe-to-evict
|
2019-11-04 17:55:13 -08:00
|
|
|
annotations:
|
2019-11-11 18:21:16 -08:00
|
|
|
policies.kyverno.io/category: Workload Management
|
2019-11-05 12:28:44 -08:00
|
|
|
policies.kyverno.io/description: The Kubernetes cluster autoscaler does not evict pods that
|
2019-11-05 16:45:37 -08:00
|
|
|
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.
|
2019-11-04 17:55:13 -08:00
|
|
|
spec:
|
|
|
|
rules:
|
2019-12-10 09:51:15 -08:00
|
|
|
- name: annotate-empty-dir
|
2019-11-04 17:55:13 -08:00
|
|
|
match:
|
|
|
|
resources:
|
|
|
|
kinds:
|
2019-12-10 09:51:15 -08:00
|
|
|
- Pod
|
2019-11-04 17:55:13 -08:00
|
|
|
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"
|
2019-11-04 17:55:13 -08:00
|
|
|
spec:
|
|
|
|
volumes:
|
2019-11-05 12:28:44 -08:00
|
|
|
- (emptyDir): {}
|
2019-12-10 09:51:15 -08:00
|
|
|
- name: annotate-host-path
|
2019-11-05 12:28:44 -08:00
|
|
|
match:
|
|
|
|
resources:
|
|
|
|
kinds:
|
2019-12-10 09:51:15 -08:00
|
|
|
- Pod
|
2019-11-05 12:28:44 -08:00
|
|
|
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"
|
2019-11-05 12:28:44 -08:00
|
|
|
spec:
|
|
|
|
volumes:
|
|
|
|
- (hostPath):
|
2019-11-05 12:59:22 -08:00
|
|
|
path: "*"
|