mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
refactor: optimise and use kuttl TestStep with tests (#5328)
* refactor: use kuttl teststep with tests Signed-off-by: prateekpandey14 <prateek.pandey@nirmata.com> * optimize kuttl generate test Signed-off-by: prateekpandey14 <prateek.pandey@nirmata.com> Signed-off-by: prateekpandey14 <prateek.pandey@nirmata.com>
This commit is contained in:
parent
775ee71a06
commit
9b2331fedc
14 changed files with 89 additions and 55 deletions
|
@ -0,0 +1,7 @@
|
||||||
|
apiVersion: kuttl.dev/v1beta1
|
||||||
|
kind: TestStep
|
||||||
|
apply:
|
||||||
|
- manifests.yaml
|
||||||
|
- cluster-policy.yaml
|
||||||
|
assert:
|
||||||
|
- cluster-policy-ready.yaml
|
|
@ -1,11 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: image-secret
|
|
||||||
namespace: prod
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: bootstap-config
|
|
||||||
namespace: prod
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
apiVersion: kuttl.dev/v1beta1
|
||||||
|
kind: TestStep
|
||||||
|
apply:
|
||||||
|
- ns.yaml
|
||||||
|
assert:
|
||||||
|
- resource-assert.yaml
|
|
@ -1,7 +1,7 @@
|
||||||
apiVersion: kyverno.io/v1
|
apiVersion: kyverno.io/v1
|
||||||
kind: ClusterPolicy
|
kind: ClusterPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: sync-secret-with-multi-clone
|
name: sync-with-multi-clone
|
||||||
status:
|
status:
|
||||||
conditions:
|
conditions:
|
||||||
- reason: Succeeded
|
- reason: Succeeded
|
|
@ -1,9 +1,9 @@
|
||||||
apiVersion: kyverno.io/v1
|
apiVersion: kyverno.io/v1
|
||||||
kind: ClusterPolicy
|
kind: ClusterPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: sync-secret-with-multi-clone
|
name: sync-with-multi-clone
|
||||||
spec:
|
spec:
|
||||||
generateExistingOnPolicyUpdate: true
|
generateExistingOnPolicyUpdate: false
|
||||||
rules:
|
rules:
|
||||||
- name: sync-secret
|
- name: sync-secret
|
||||||
match:
|
match:
|
||||||
|
@ -30,25 +30,3 @@ spec:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
allowedToBeCloned: "true"
|
allowedToBeCloned: "true"
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: bootstap-config
|
|
||||||
namespace: default
|
|
||||||
labels:
|
|
||||||
allowedToBeCloned: "true"
|
|
||||||
data:
|
|
||||||
initial_lives: "15"
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: image-secret
|
|
||||||
namespace: default
|
|
||||||
labels:
|
|
||||||
allowedToBeCloned: "true"
|
|
||||||
type: kubernetes.io/basic-auth
|
|
||||||
stringData:
|
|
||||||
username: admin
|
|
||||||
password: t0p-Secret-super
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: bootstrap-config
|
||||||
|
namespace: default
|
||||||
|
labels:
|
||||||
|
allowedToBeCloned: "true"
|
||||||
|
data:
|
||||||
|
initial_lives: "15"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: image-secret
|
||||||
|
namespace: default
|
||||||
|
labels:
|
||||||
|
allowedToBeCloned: "true"
|
||||||
|
type: kubernetes.io/basic-auth
|
||||||
|
stringData:
|
||||||
|
username: admin
|
||||||
|
password: t0p-Secret-super
|
|
@ -1,4 +1,4 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
metadata:
|
metadata:
|
||||||
name: prod
|
name: prod-1
|
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
password: dDBwLVNlY3JldC1zdXBlcg==
|
||||||
|
username: YWRtaW4=
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
allowedToBeCloned: "true"
|
||||||
|
app.kubernetes.io/managed-by: kyverno
|
||||||
|
generate.kyverno.io/clone-policy-name: sync-with-multi-clone
|
||||||
|
kyverno.io/generated-by-kind: Namespace
|
||||||
|
kyverno.io/generated-by-name: prod-1
|
||||||
|
kyverno.io/generated-by-namespace: ""
|
||||||
|
policy.kyverno.io/policy-name: sync-with-multi-clone
|
||||||
|
policy.kyverno.io/synchronize: enable
|
||||||
|
name: image-secret
|
||||||
|
namespace: prod-1
|
||||||
|
type: kubernetes.io/basic-auth
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
initial_lives: "15"
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
allowedToBeCloned: "true"
|
||||||
|
app.kubernetes.io/managed-by: kyverno
|
||||||
|
generate.kyverno.io/clone-policy-name: sync-with-multi-clone
|
||||||
|
kyverno.io/generated-by-kind: Namespace
|
||||||
|
kyverno.io/generated-by-name: prod-1
|
||||||
|
kyverno.io/generated-by-namespace: ""
|
||||||
|
policy.kyverno.io/policy-name: sync-with-multi-clone
|
||||||
|
policy.kyverno.io/synchronize: enable
|
||||||
|
name: bootstrap-config
|
||||||
|
namespace: prod-1
|
|
@ -1,9 +1,9 @@
|
||||||
apiVersion: kyverno.io/v1
|
apiVersion: kyverno.io/v1
|
||||||
kind: ClusterPolicy
|
kind: ClusterPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: sync-secret-with-multi-clone
|
name: sync-with-multi-clone-update
|
||||||
status:
|
status:
|
||||||
conditions:
|
conditions:
|
||||||
- reason: Succeeded
|
- reason: Succeeded
|
||||||
status: "True"
|
status: "True"
|
||||||
type: Ready
|
type: Ready
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
apiVersion: kyverno.io/v1
|
apiVersion: kyverno.io/v1
|
||||||
kind: ClusterPolicy
|
kind: ClusterPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: sync-secret-with-multi-clone
|
name: sync-with-multi-clone-update
|
||||||
spec:
|
spec:
|
||||||
generateExistingOnPolicyUpdate: true
|
generateExistingOnPolicyUpdate: false
|
||||||
rules:
|
rules:
|
||||||
- name: sync-secret
|
- name: sync-secret
|
||||||
match:
|
match:
|
||||||
|
@ -29,4 +29,4 @@ spec:
|
||||||
- v1/ConfigMap
|
- v1/ConfigMap
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
allowedToBeCloned: "true"
|
allowedToBeCloned: "true"
|
||||||
|
|
|
@ -8,12 +8,11 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
allowedToBeCloned: "true"
|
allowedToBeCloned: "true"
|
||||||
app.kubernetes.io/managed-by: kyverno
|
app.kubernetes.io/managed-by: kyverno
|
||||||
generate.kyverno.io/clone-policy-name: sync-secret-with-multi-clone
|
generate.kyverno.io/clone-policy-name: sync-with-multi-clone-update
|
||||||
kyverno.io/background-gen-rule: sync-secret
|
|
||||||
kyverno.io/generated-by-kind: Namespace
|
kyverno.io/generated-by-kind: Namespace
|
||||||
kyverno.io/generated-by-name: prod
|
kyverno.io/generated-by-name: prod
|
||||||
kyverno.io/generated-by-namespace: ""
|
kyverno.io/generated-by-namespace: ""
|
||||||
policy.kyverno.io/policy-name: sync-secret-with-multi-clone
|
policy.kyverno.io/policy-name: sync-with-multi-clone-update
|
||||||
policy.kyverno.io/synchronize: enable
|
policy.kyverno.io/synchronize: enable
|
||||||
name: image-secret
|
name: image-secret
|
||||||
namespace: prod
|
namespace: prod
|
||||||
|
@ -27,12 +26,11 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
allowedToBeCloned: "true"
|
allowedToBeCloned: "true"
|
||||||
app.kubernetes.io/managed-by: kyverno
|
app.kubernetes.io/managed-by: kyverno
|
||||||
generate.kyverno.io/clone-policy-name: sync-secret-with-multi-clone
|
generate.kyverno.io/clone-policy-name: sync-with-multi-clone-update
|
||||||
kyverno.io/background-gen-rule: sync-secret
|
|
||||||
kyverno.io/generated-by-kind: Namespace
|
kyverno.io/generated-by-kind: Namespace
|
||||||
kyverno.io/generated-by-name: prod
|
kyverno.io/generated-by-name: prod
|
||||||
kyverno.io/generated-by-namespace: ""
|
kyverno.io/generated-by-namespace: ""
|
||||||
policy.kyverno.io/policy-name: sync-secret-with-multi-clone
|
policy.kyverno.io/policy-name: sync-with-multi-clone-update
|
||||||
policy.kyverno.io/synchronize: enable
|
policy.kyverno.io/synchronize: enable
|
||||||
name: bootstrap-config
|
name: bootstrap-config
|
||||||
namespace: prod
|
namespace: prod
|
||||||
|
|
|
@ -7,12 +7,11 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
allowedToBeCloned: "true"
|
allowedToBeCloned: "true"
|
||||||
app.kubernetes.io/managed-by: kyverno
|
app.kubernetes.io/managed-by: kyverno
|
||||||
generate.kyverno.io/clone-policy-name: sync-secret-with-multi-clone
|
generate.kyverno.io/clone-policy-name: sync-with-multi-clone-update
|
||||||
kyverno.io/background-gen-rule: sync-secret
|
|
||||||
kyverno.io/generated-by-kind: Namespace
|
kyverno.io/generated-by-kind: Namespace
|
||||||
kyverno.io/generated-by-name: prod
|
kyverno.io/generated-by-name: prod
|
||||||
kyverno.io/generated-by-namespace: ""
|
kyverno.io/generated-by-namespace: ""
|
||||||
policy.kyverno.io/policy-name: sync-secret-with-multi-clone
|
policy.kyverno.io/policy-name: sync-with-multi-clone-update
|
||||||
policy.kyverno.io/synchronize: enable
|
policy.kyverno.io/synchronize: enable
|
||||||
name: bootstrap-config
|
name: bootstrap-config
|
||||||
namespace: prod
|
namespace: prod
|
||||||
|
|
|
@ -3,7 +3,7 @@ kind: ClusterPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: zk-kafka-address
|
name: zk-kafka-address
|
||||||
spec:
|
spec:
|
||||||
generateExistingOnPolicyUpdate: true
|
generateExistingOnPolicyUpdate: false
|
||||||
rules:
|
rules:
|
||||||
- name: k-kafka-address
|
- name: k-kafka-address
|
||||||
match:
|
match:
|
||||||
|
@ -32,4 +32,4 @@ spec:
|
||||||
somekey: somevalue
|
somekey: somevalue
|
||||||
data:
|
data:
|
||||||
ZK_ADDRESS: "192.168.10.10:2181,192.168.10.11:2181,192.168.10.12:2181"
|
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"
|
KAFKA_ADDRESS: "192.168.10.13:9092,192.168.10.14:9092,192.168.10.15:9092"
|
||||||
|
|
|
@ -3,7 +3,7 @@ kind: ClusterPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: zk-kafka-address
|
name: zk-kafka-address
|
||||||
spec:
|
spec:
|
||||||
generateExistingOnPolicyUpdate: true
|
generateExistingOnPolicyUpdate: false
|
||||||
rules:
|
rules:
|
||||||
- name: k-kafka-address
|
- name: k-kafka-address
|
||||||
match:
|
match:
|
||||||
|
@ -32,4 +32,4 @@ spec:
|
||||||
somekey: somevalue
|
somekey: somevalue
|
||||||
data:
|
data:
|
||||||
ZK_ADDRESS: "192.168.10.10:2181,192.168.10.11:2181,192.168.10.12:2181"
|
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"
|
KAFKA_ADDRESS: "192.168.10.13:9092,192.168.10.14:9092,192.168.10.15:9092"
|
||||||
|
|
Loading…
Add table
Reference in a new issue