From 6baa678e279828320ae01ddd91a282e6a7e73a24 Mon Sep 17 00:00:00 2001 From: Jim Bugwadia Date: Fri, 8 Nov 2019 19:02:49 -0800 Subject: [PATCH] rename add_safe_to_evict --- pkg/testrunner/testrunner_test.go | 6 +++--- samples/{MutateSafeToEvict.md => AddSafeToEvict.md} | 11 ++++++++--- ...o-evict_annotation.yaml => add_safe_to_evict.yaml} | 6 +++--- ...tate_safe-to-evict.yaml => add_safe_to_evict.yaml} | 6 +++--- ...te_safe-to-evict2.yaml => add_safe_to_evict2.yaml} | 6 +++--- 5 files changed, 20 insertions(+), 15 deletions(-) rename samples/{MutateSafeToEvict.md => AddSafeToEvict.md} (74%) rename samples/best_practices/{add_safe-to-evict_annotation.yaml => add_safe_to_evict.yaml} (89%) rename test/scenarios/samples/best_practices/{scenario_mutate_safe-to-evict.yaml => add_safe_to_evict.yaml} (73%) rename test/scenarios/samples/best_practices/{scenario_mutate_safe-to-evict2.yaml => add_safe_to_evict2.yaml} (73%) diff --git a/pkg/testrunner/testrunner_test.go b/pkg/testrunner/testrunner_test.go index 01902bf979..31293fca40 100644 --- a/pkg/testrunner/testrunner_test.go +++ b/pkg/testrunner/testrunner_test.go @@ -123,12 +123,12 @@ func Test_validate_disallow_helm_tiller(t *testing.T) { testScenario(t, "test/scenarios/samples/best_practices/scenario_validate_disallow_helm_tiller.yaml") } -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(t *testing.T) { + testScenario(t, "test/scenarios/samples/best_practices/add_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") + testScenario(t, "test/scenarios/samples/best_practices/add_safe_to_evict2.yaml") } func Test_known_ingress(t *testing.T) { diff --git a/samples/MutateSafeToEvict.md b/samples/AddSafeToEvict.md similarity index 74% rename from samples/MutateSafeToEvict.md rename to samples/AddSafeToEvict.md index 86717cf950..ddec6a4168 100644 --- a/samples/MutateSafeToEvict.md +++ b/samples/AddSafeToEvict.md @@ -16,10 +16,15 @@ This policy matches and mutates pods with `emptyDir` and `hostPath` volumes, to apiVersion: "kyverno.io/v1alpha1" kind: "ClusterPolicy" metadata: - name: "annotate-emptydir-hostpath" + name: "add-safe-to-evict" + annotations: + policies.kyverno.io/category: AutoScaling + 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. spec: rules: - - name: "empty-dir-add-safe-to-evict" + - name: "annotate-empty-dir" match: resources: kinds: @@ -32,7 +37,7 @@ spec: spec: volumes: - (emptyDir): {} - - name: "host-path-add-safe-to-evict" + - name: "annotate-host-path" match: resources: kinds: diff --git a/samples/best_practices/add_safe-to-evict_annotation.yaml b/samples/best_practices/add_safe_to_evict.yaml similarity index 89% rename from samples/best_practices/add_safe-to-evict_annotation.yaml rename to samples/best_practices/add_safe_to_evict.yaml index 63fd5cc621..ae6a1d2968 100644 --- a/samples/best_practices/add_safe-to-evict_annotation.yaml +++ b/samples/best_practices/add_safe_to_evict.yaml @@ -1,7 +1,7 @@ apiVersion: "kyverno.io/v1alpha1" kind: "ClusterPolicy" metadata: - name: "annotate-emptydir-hostpath" + name: "add-safe-to-evict" annotations: policies.kyverno.io/category: AutoScaling policies.kyverno.io/description: The Kubernetes cluster autoscaler does not evict pods that @@ -9,7 +9,7 @@ metadata: cluster-autoscaler.kubernetes.io/safe-to-evict=true must be added to the pods. spec: rules: - - name: "empty-dir-add-safe-to-evict" + - name: "annotate-empty-dir" match: resources: kinds: @@ -22,7 +22,7 @@ spec: spec: volumes: - (emptyDir): {} - - name: "host-path-add-safe-to-evict" + - name: "annotate-host-path" match: resources: kinds: diff --git a/test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict.yaml b/test/scenarios/samples/best_practices/add_safe_to_evict.yaml similarity index 73% rename from test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict.yaml rename to test/scenarios/samples/best_practices/add_safe_to_evict.yaml index 782f23a365..c861cf65d4 100644 --- a/test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict.yaml +++ b/test/scenarios/samples/best_practices/add_safe_to_evict.yaml @@ -1,19 +1,19 @@ # file path is relative to project root input: - policy: samples/best_practices/add_safe-to-evict_annotation.yaml + policy: samples/best_practices/add_safe_to_evict.yaml resource: test/resources/pod-with-emptydir.yaml expected: mutation: patchedresource: test/output/pod-with-emptydir.yaml policyresponse: - policy: annotate-emptydir-hostpath + policy: add-safe-to-evict resource: kind: Pod apiVersion: v1 namespace: '' name: pod-with-emptydir rules: - - name: empty-dir-add-safe-to-evict + - name: annotate-empty-dir type: Mutation success: true message: "successfully processed overlay" \ No newline at end of file diff --git a/test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict2.yaml b/test/scenarios/samples/best_practices/add_safe_to_evict2.yaml similarity index 73% rename from test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict2.yaml rename to test/scenarios/samples/best_practices/add_safe_to_evict2.yaml index fae3b040ab..7fce426d61 100644 --- a/test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict2.yaml +++ b/test/scenarios/samples/best_practices/add_safe_to_evict2.yaml @@ -1,19 +1,19 @@ # file path is relative to project root input: - policy: samples/best_practices/add_safe-to-evict_annotation.yaml + policy: samples/best_practices/add_safe_to_evict.yaml resource: test/resources/pod-with-hostpath.yaml expected: mutation: patchedresource: test/output/pod-with-hostpath.yaml policyresponse: - policy: annotate-emptydir-hostpath + policy: add-safe-to-evict resource: kind: Pod apiVersion: v1 namespace: '' name: pod-with-hostpath rules: - - name: host-path-add-safe-to-evict + - name: annotate-host-path type: Mutation success: true message: "successfully processed overlay"