1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-28 10:28:36 +00:00

add kuttl test pol-clone-sync-modify-source (#6407)

Signed-off-by: ShutingZhao <shuting@nirmata.com>
This commit is contained in:
shuting 2023-02-27 19:51:21 +08:00 committed by GitHub
parent b6baa655cb
commit ccfcce83da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 88 additions and 0 deletions

View file

@ -0,0 +1,10 @@
apiVersion: kyverno.io/v2beta1
kind: Policy
metadata:
name: pol-sync-clone
namespace: poltest
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -0,0 +1,36 @@
apiVersion: v1
kind: Namespace
metadata:
name: poltest
---
apiVersion: v1
data:
foo: YmFy
kind: Secret
metadata:
name: regcred
namespace: poltest
type: Opaque
---
apiVersion: kyverno.io/v2beta1
kind: Policy
metadata:
name: pol-sync-clone
namespace: poltest
spec:
rules:
- name: gen-zk
match:
any:
- resources:
kinds:
- ConfigMap
generate:
apiVersion: v1
kind: Secret
name: myclonedsecret
namespace: poltest
synchronize: true
clone:
namespace: poltest
name: regcred

View file

@ -0,0 +1,7 @@
apiVersion: v1
data:
sj: js
kind: ConfigMap
metadata:
name: cm-2
namespace: poltest

View file

@ -0,0 +1,8 @@
apiVersion: v1
data:
foo: YmFy
kind: Secret
metadata:
name: myclonedsecret
namespace: poltest
type: Opaque

View file

@ -0,0 +1,8 @@
apiVersion: v1
data:
foo: aGVyZWlzY2hhbmdlZGRhdGE=
kind: Secret
metadata:
name: regcred
namespace: poltest
type: Opaque

View file

@ -0,0 +1,8 @@
apiVersion: v1
data:
foo: aGVyZWlzY2hhbmdlZGRhdGE=
kind: Secret
metadata:
name: myclonedsecret
namespace: poltest
type: Opaque

View file

@ -0,0 +1,11 @@
## Description
This test ensures that modification of the source (upstream) resource used by a Policy `generate` rule with sync enabled using a clone declaration causes those changes to be synced/propagated downstream.
## Expected Behavior
After the source is modified, the downstream resources should be synced to reflect those modifications. If the downstream resource reflects the changes made to the source, the test passes. If the downstream resource remains unsynced, the test fails.
## Reference Issue(s)
https://github.com/kyverno/kyverno/issues/5277