forked from kyverno/kyverno
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ns labels matching (kyverno#6020)
* fix ns labels matching Signed-off-by: ShutingZhao <[email protected]> * add kuttl tests Signed-off-by: ShutingZhao <[email protected]> Signed-off-by: ShutingZhao <[email protected]>
- Loading branch information
1 parent
0a19556
commit 36abeae
Showing
10 changed files
with
94 additions
and
1 deletion.
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
6 changes: 6 additions & 0 deletions
6
...e/kuttl/validate/clusterpolicy/standard/enforce/ns-selector-with-wildcard-kind/01-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,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- ns.yaml | ||
assert: | ||
- ns.yaml |
6 changes: 6 additions & 0 deletions
6
...ttl/validate/clusterpolicy/standard/enforce/ns-selector-with-wildcard-kind/02-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,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- policy.yaml | ||
assert: | ||
- policy-assert.yaml |
7 changes: 7 additions & 0 deletions
7
...l/validate/clusterpolicy/standard/enforce/ns-selector-with-wildcard-kind/03-pod-fail.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: | ||
- file: pod-fail.yaml | ||
shouldFail: true | ||
- file: pod-pass.yaml | ||
shouldFail: false |
12 changes: 12 additions & 0 deletions
12
...alidate/clusterpolicy/standard/enforce/ns-selector-with-wildcard-kind/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,12 @@ | ||
# ## Description | ||
|
||
This test validates that the namespaceSelector is applied to a wildcard policy successfully. | ||
|
||
## Expected Behavior | ||
|
||
The pod `test-validate/nginx-block` is blocked, and the pod `default/nginx-pass` is created. | ||
|
||
|
||
## Reference Issue(s) | ||
|
||
https://github.com/kyverno/kyverno/issues/6015 |
6 changes: 6 additions & 0 deletions
6
...ance/kuttl/validate/clusterpolicy/standard/enforce/ns-selector-with-wildcard-kind/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,6 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: test-wildcard | ||
labels: | ||
freeze: "true" |
11 changes: 11 additions & 0 deletions
11
...uttl/validate/clusterpolicy/standard/enforce/ns-selector-with-wildcard-kind/pod-fail.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,11 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
app: nginx | ||
name: nginx-block | ||
namespace: test-wildcard | ||
spec: | ||
containers: | ||
- image: nginx | ||
name: test |
11 changes: 11 additions & 0 deletions
11
...uttl/validate/clusterpolicy/standard/enforce/ns-selector-with-wildcard-kind/pod-pass.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,11 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
app: nginx | ||
name: nginx-pass | ||
namespace: default | ||
spec: | ||
containers: | ||
- image: nginx | ||
name: test |
9 changes: 9 additions & 0 deletions
9
...validate/clusterpolicy/standard/enforce/ns-selector-with-wildcard-kind/policy-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,9 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: freeze-policy | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |
23 changes: 23 additions & 0 deletions
23
.../kuttl/validate/clusterpolicy/standard/enforce/ns-selector-with-wildcard-kind/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,23 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: freeze-policy | ||
spec: | ||
validationFailureAction: Enforce | ||
background: false | ||
rules: | ||
- name: freeze-rule | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- "*" | ||
namespaceSelector: | ||
matchExpressions: | ||
- key: freeze | ||
operator: In | ||
values: | ||
- "true" | ||
validate: | ||
message: "Namespace is frozen." | ||
deny: {} |