1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/samples/best_practices/add_safe_to_evict.yaml

39 lines
1.1 KiB
YAML
Raw Normal View History

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:
patchStrategicMerge:
2019-11-04 17:55:13 -08:00
metadata:
annotations:
+(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:
patchStrategicMerge:
2019-11-05 12:28:44 -08:00
metadata:
annotations:
+(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: "*"