forked from kyverno/kyverno
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: synchronize source resource update to clone list resource (kyver…
…no#5317) * fix: synchronize source resource update to clone list target resource Signed-off-by: prateekpandey14 <prateek.pandey@nirmata.com> * add kuttl test to verify the clone list synchronized behavior Signed-off-by: prateekpandey14 <prateek.pandey@nirmata.com> * refactor functions parameters Signed-off-by: prateekpandey14 <prateek.pandey@nirmata.com> * fix the kuttl test description and behavior README Signed-off-by: prateekpandey14 <prateek.pandey@nirmata.com> * Use entire content to compare Signed-off-by: prateekpandey14 <prateek.pandey@nirmata.com>
- Loading branch information
1 parent
79d18d1
commit 2b4ff1e
Showing
18 changed files
with
234 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...rate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/00-cluster-policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- manifests.yaml | ||
- cluster-policy.yaml | ||
assert: | ||
- cluster-policy-ready.yaml |
6 changes: 6 additions & 0 deletions
6
...tl/generate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/01-trigger.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- ns.yaml | ||
assert: | ||
- resource-assert.yaml |
6 changes: 6 additions & 0 deletions
6
...ttl/generate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/02-update.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- ns.yaml | ||
assert: | ||
- resource-assert.yaml |
6 changes: 6 additions & 0 deletions
6
...erate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/03-update-source.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- update-source.yaml | ||
assert: | ||
- synchronized-target.yaml |
11 changes: 11 additions & 0 deletions
11
...enerate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Description | ||
|
||
This test verifies the synchronize behavior of generated resource, if the selected source resources using a matched label selector `allowedToBeCloned: "true"` gets changed, the update should be synchronized with the target resource as well. | ||
|
||
## Expected Behavior | ||
|
||
This test ensures that update of source resource(ConfigMap) match selected using `allowedToBeCloned: "true"` label get synchronized with target resource created by a ClusterPolicy `generate.cloneList` rule, otherwise the test fails. | ||
|
||
## Reference Issue(s) | ||
|
||
#4930 |
9 changes: 9 additions & 0 deletions
9
...e/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/cluster-policy-ready.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: sync-secret-with-multi-clone | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |
32 changes: 32 additions & 0 deletions
32
...enerate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/cluster-policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: sync-secret-with-multi-clone | ||
spec: | ||
generateExistingOnPolicyUpdate: true | ||
rules: | ||
- name: sync-secret | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Namespace | ||
exclude: | ||
any: | ||
- resources: | ||
namespaces: | ||
- kube-system | ||
- default | ||
- kube-public | ||
- kyverno | ||
generate: | ||
namespace: "{{request.object.metadata.name}}" | ||
synchronize : true | ||
cloneList: | ||
namespace: default | ||
kinds: | ||
- v1/Secret | ||
- v1/ConfigMap | ||
selector: | ||
matchLabels: | ||
allowedToBeCloned: "true" |
21 changes: 21 additions & 0 deletions
21
...ttl/generate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/manifests.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
4 changes: 4 additions & 0 deletions
4
...ance/kuttl/generate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/ns.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: prod |
38 changes: 38 additions & 0 deletions
38
...nerate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/resource-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
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-secret-with-multi-clone | ||
kyverno.io/background-gen-rule: sync-secret | ||
kyverno.io/generated-by-kind: Namespace | ||
kyverno.io/generated-by-name: prod | ||
kyverno.io/generated-by-namespace: "" | ||
policy.kyverno.io/policy-name: sync-secret-with-multi-clone | ||
policy.kyverno.io/synchronize: enable | ||
name: image-secret | ||
namespace: prod | ||
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-secret-with-multi-clone | ||
kyverno.io/background-gen-rule: sync-secret | ||
kyverno.io/generated-by-kind: Namespace | ||
kyverno.io/generated-by-name: prod | ||
kyverno.io/generated-by-namespace: "" | ||
policy.kyverno.io/policy-name: sync-secret-with-multi-clone | ||
policy.kyverno.io/synchronize: enable | ||
name: bootstrap-config | ||
namespace: prod |
18 changes: 18 additions & 0 deletions
18
...te/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/synchronized-target.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
apiVersion: v1 | ||
data: | ||
initial_lives: "50" | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
allowedToBeCloned: "true" | ||
app.kubernetes.io/managed-by: kyverno | ||
generate.kyverno.io/clone-policy-name: sync-secret-with-multi-clone | ||
kyverno.io/background-gen-rule: sync-secret | ||
kyverno.io/generated-by-kind: Namespace | ||
kyverno.io/generated-by-name: prod | ||
kyverno.io/generated-by-namespace: "" | ||
policy.kyverno.io/policy-name: sync-secret-with-multi-clone | ||
policy.kyverno.io/synchronize: enable | ||
name: bootstrap-config | ||
namespace: prod |
9 changes: 9 additions & 0 deletions
9
...generate/clusterpolicy/standard/clone/sync/cpol-clone-list-sync-update/update-source.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: bootstrap-config | ||
namespace: default | ||
labels: | ||
allowedToBeCloned: "true" | ||
data: | ||
initial_lives: "50" |