1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-30 19:35:06 +00:00

add tect case

This commit is contained in:
Jim Bugwadia 2019-11-05 15:32:45 -08:00
parent 664a85363a
commit cab87f24ba
7 changed files with 62 additions and 3 deletions

View file

@ -127,6 +127,10 @@ func Test_validate_disallow_helm_tiller(t *testing.T) {
testScenario(t, "test/scenarios/samples/best_practices/scenario_validate_disallow_helm_tiller.yaml")
}
func Test_mutate_add_safe_to_evict_annotation(t *testing.T) {
func Test_add_safe_to_evict_annotation(t *testing.T) {
testScenario(t, "test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict.yaml")
}
func Test_add_safe_to_evict_annotation2(t *testing.T) {
testScenario(t, "test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict2.yaml")
}

View file

@ -1,7 +1,7 @@
apiVersion: "kyverno.io/v1alpha1"
kind: "ClusterPolicy"
metadata:
name: "annotate-emptyDir"
name: "annotate-emptydir-hostpath"
annotations:
policies.kyverno.io/category: AutoScaling
policies.kyverno.io/description: The Kubernetes cluster autoscaler does not evict pods that

View file

@ -2,6 +2,9 @@ apiVersion: v1
kind: Pod
metadata:
name: pod-with-emptydir
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: true
spec:
containers:
- image: k8s.gcr.io/test-webserver

View file

@ -0,0 +1,18 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-with-hostpath
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: true
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /tmp/foo
name: host-volume
volumes:
- name: host-volume
hostPath:
path: "/tmp/foo"

View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-with-hostpath
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /tmp/foo
name: host-volume
volumes:
- name: host-volume
hostPath:
path: "/tmp/foo"

View file

@ -6,7 +6,7 @@ expected:
mutation:
patchedresource: test/output/pod-with-emptydir.yaml
policyresponse:
policy: annotate-emptyDir
policy: annotate-emptydir-hostpath
resource:
kind: Pod
apiVersion: v1

View file

@ -0,0 +1,19 @@
# file path is relative to project root
input:
policy: samples/best_practices/add_safe-to-evict_annotation.yaml
resource: test/resources/pod-with-hostpath.yaml
expected:
mutation:
patchedresource: test/output/pod-with-hostpath.yaml
policyresponse:
policy: annotate-emptydir-hostpath
resource:
kind: Pod
apiVersion: v1
namespace: ''
name: pod-with-hostpath
rules:
- name: host-path-add-safe-to-evict
type: Mutation
success: true
message: "successfully processed overlay"