2019-11-04 17:55:13 -08:00
|
|
|
apiVersion: "kyverno.io/v1alpha1"
|
|
|
|
kind: "ClusterPolicy"
|
|
|
|
metadata:
|
|
|
|
name: "annotate-emptyDir"
|
|
|
|
annotations:
|
|
|
|
policies.kyverno.io/category: AutoScaling
|
2019-11-05 12:28:44 -08:00
|
|
|
policies.kyverno.io/description: The Kubernetes cluster autoscaler does not evict pods that
|
|
|
|
use hostPath or emptyDir volumes. To allow eviction the annotation
|
|
|
|
cluster-autoscaler.kubernetes.io/safe-to-evict=true is added to the pod.
|
2019-11-04 17:55:13 -08:00
|
|
|
spec:
|
|
|
|
rules:
|
2019-11-05 12:28:44 -08:00
|
|
|
- name: "empty-dir-add-safe-to-evict"
|
2019-11-04 17:55:13 -08:00
|
|
|
match:
|
|
|
|
resources:
|
|
|
|
kinds:
|
|
|
|
- "Pod"
|
|
|
|
mutate:
|
|
|
|
overlay:
|
|
|
|
metadata:
|
|
|
|
annotations:
|
|
|
|
+(cluster-autoscaler.kubernetes.io/safe-to-evict): true
|
|
|
|
spec:
|
|
|
|
volumes:
|
2019-11-05 12:28:44 -08:00
|
|
|
- (emptyDir): {}
|
|
|
|
- name: "host-path-add-safe-to-evict"
|
|
|
|
match:
|
|
|
|
resources:
|
|
|
|
kinds:
|
|
|
|
- "Pod"
|
|
|
|
mutate:
|
|
|
|
overlay:
|
|
|
|
metadata:
|
|
|
|
annotations:
|
|
|
|
+(cluster-autoscaler.kubernetes.io/safe-to-evict): true
|
|
|
|
spec:
|
|
|
|
volumes:
|
|
|
|
- (hostPath):
|
|
|
|
path: "*"
|