From 6a94179b616aad20ba15e3550b36a93d11f75daa Mon Sep 17 00:00:00 2001 From: shuting Date: Wed, 22 May 2019 20:07:41 -0700 Subject: [PATCH] update examples --- examples/generate/configMap.yaml | 20 +++++++++++ examples/generate/namespace.yaml | 7 ++++ examples/generate/policy_generate.yaml | 34 +++++++++++++++++++ .../overlay/policy_set_imagePullPolicy.yaml | 20 +++++++++++ .../overlay/set_imagePullPolicy_nginx.yaml | 23 +++++++++++++ examples/mutate/patches/endpoints.yaml | 13 +++++++ examples/mutate/patches/policy_endpoints.yaml | 27 +++++++++++++++ 7 files changed, 144 insertions(+) create mode 100644 examples/generate/configMap.yaml create mode 100644 examples/generate/namespace.yaml create mode 100644 examples/generate/policy_generate.yaml create mode 100644 examples/mutate/overlay/policy_set_imagePullPolicy.yaml create mode 100644 examples/mutate/overlay/set_imagePullPolicy_nginx.yaml create mode 100644 examples/mutate/patches/endpoints.yaml create mode 100644 examples/mutate/patches/policy_endpoints.yaml diff --git a/examples/generate/configMap.yaml b/examples/generate/configMap.yaml new file mode 100644 index 0000000000..8524e95d4a --- /dev/null +++ b/examples/generate/configMap.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: game-config + namespace: default + labels: + originalLabel : isHere +data: + ui.properties : | + color.good=green + color.bad=red + + game.properties : | + enemies=predators + lives=3 + + configmap.data: | + ns=default + labels=originalLabel + labelscount=1 diff --git a/examples/generate/namespace.yaml b/examples/generate/namespace.yaml new file mode 100644 index 0000000000..566684da82 --- /dev/null +++ b/examples/generate/namespace.yaml @@ -0,0 +1,7 @@ +kind: Namespace +apiVersion: v1 +metadata: + name: "ns2" + labels: + LabelForSelector : "namespace2" + \ No newline at end of file diff --git a/examples/generate/policy_generate.yaml b/examples/generate/policy_generate.yaml new file mode 100644 index 0000000000..8645a9736f --- /dev/null +++ b/examples/generate/policy_generate.yaml @@ -0,0 +1,34 @@ +apiVersion: kyverno.io/v1alpha1 +kind: Policy +metadata: + name: "zk-kafka-address" +spec: + rules: + - name: "copy-comfigmap" + resource : + kinds : + - Namespace + selector: + matchLabels: + LabelForSelector : "namespace2" + generate : + kind: ConfigMap + name : copied-cm + copyFrom : + namespace : default + name : game-config + data : + secretData: "data from cmg" + - name: "zk-kafka-address" + resource: + kinds: + - Namespace + selector: + matchExpressions: + - {key: LabelForSelector, operator: In, values: [namespace2]} + generate: + kind: ConfigMap + name: zk-kafka-address + data: + ZK_ADDRESS: "192.168.10.10:2181,192.168.10.11:2181,192.168.10.12:2181" + KAFKA_ADDRESS: "192.168.10.13:9092,192.168.10.14:9092,192.168.10.15:9092" diff --git a/examples/mutate/overlay/policy_set_imagePullPolicy.yaml b/examples/mutate/overlay/policy_set_imagePullPolicy.yaml new file mode 100644 index 0000000000..0bf8a3331c --- /dev/null +++ b/examples/mutate/overlay/policy_set_imagePullPolicy.yaml @@ -0,0 +1,20 @@ +apiVersion: kyverno.io/v1alpha1 +kind: Policy +metadata: + name: set-image-pull-policy +spec: + rules: + - name: set-image-pull-policy + resource: + kinds: + - Deployment + mutate: + overlay: + spec: + template: + spec: + containers: + # match images which end with :latest + - (image): "*:latest" + # set the imagePullPolicy to "Always" + imagePullPolicy: "Always" \ No newline at end of file diff --git a/examples/mutate/overlay/set_imagePullPolicy_nginx.yaml b/examples/mutate/overlay/set_imagePullPolicy_nginx.yaml new file mode 100644 index 0000000000..20d0713896 --- /dev/null +++ b/examples/mutate/overlay/set_imagePullPolicy_nginx.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + labels: + app: nginx +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:latest + ports: + - containerPort: 80 + - name: ghost + image: ghost:latest diff --git a/examples/mutate/patches/endpoints.yaml b/examples/mutate/patches/endpoints.yaml new file mode 100644 index 0000000000..958d931482 --- /dev/null +++ b/examples/mutate/patches/endpoints.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Endpoints +metadata: + name: test-endpoint + labels: + label : test +subsets: +- addresses: + - ip: 192.168.10.171 + ports: + - name: secure-connection + port: 443 + protocol: TCP diff --git a/examples/mutate/patches/policy_endpoints.yaml b/examples/mutate/patches/policy_endpoints.yaml new file mode 100644 index 0000000000..4e36eda51d --- /dev/null +++ b/examples/mutate/patches/policy_endpoints.yaml @@ -0,0 +1,27 @@ +apiVersion : kyverno.io/v1alpha1 +kind : Policy +metadata : + name : policy-endpoints +spec : + rules: + - name: pEP + resource: + kinds : + - Endpoints + selector: + matchLabels: + label : test + mutate: + patches: + - path : "/subsets/0/ports/0/port" + op : replace + value: 9663 + - path : "/subsets/0" + op: add + value: + addresses: + - ip: "192.168.10.172" + ports: + - name: load-balancer-connection + port: 80 + protocol: UDP \ No newline at end of file