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: send notification when stoping watching resource in reports syst…
…em (kyverno#5298) * fix: send notification when stoping watching resource in reports system Signed-off-by: Charles-Edouard Brétéché <[email protected]> * add kuttl test Signed-off-by: Charles-Edouard Brétéché <[email protected]> * rework Signed-off-by: Charles-Edouard Brétéché <[email protected]> * readme Signed-off-by: Charles-Edouard Brétéché <[email protected]> Signed-off-by: Charles-Edouard Brétéché <[email protected]>
- Loading branch information
1 parent
19f0e7e
commit fcca45b
Showing
11 changed files
with
103 additions
and
3 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
6 changes: 6 additions & 0 deletions
6
test/conformance/kuttl/reports/background/background-scan-report-deletion/00-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 |
4 changes: 4 additions & 0 deletions
4
test/conformance/kuttl/reports/background/background-scan-report-deletion/01-pod.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: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- pod.yaml |
4 changes: 4 additions & 0 deletions
4
...e/kuttl/reports/background/background-scan-report-deletion/02-background-scan-report.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: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
assert: | ||
- background-scan-report-assert.yaml |
8 changes: 8 additions & 0 deletions
8
...onformance/kuttl/reports/background/background-scan-report-deletion/03-delete-report.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,8 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
delete: | ||
- apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
name: podsecurity-subrule-restricted | ||
error: | ||
- background-scan-report-error.yaml |
13 changes: 13 additions & 0 deletions
13
.../conformance/kuttl/reports/background/background-scan-report-deletion/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,13 @@ | ||
## Description | ||
|
||
This test creates a policy and a pod, it then expects a background scan report to be created for the pod. | ||
When the policy is deleted, the background scan report should also be deleted. | ||
|
||
## Steps | ||
|
||
1. - Create a cluster policy | ||
- Assert the policy becomes ready | ||
1. - Create a pod | ||
1. - Assert a background scan report is created for the pod and contains the right summary | ||
1. - Delete the policy | ||
- Assert the background scan report is deleted for the pod |
14 changes: 14 additions & 0 deletions
14
...ttl/reports/background/background-scan-report-deletion/background-scan-report-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,14 @@ | ||
apiVersion: kyverno.io/v1alpha2 | ||
kind: BackgroundScanReport | ||
metadata: | ||
ownerReferences: | ||
- apiVersion: v1 | ||
kind: Pod | ||
name: badpod01 | ||
spec: | ||
summary: | ||
error: 0 | ||
fail: 1 | ||
pass: 0 | ||
skip: 0 | ||
warn: 0 |
7 changes: 7 additions & 0 deletions
7
...uttl/reports/background/background-scan-report-deletion/background-scan-report-error.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: kyverno.io/v1alpha2 | ||
kind: BackgroundScanReport | ||
metadata: | ||
ownerReferences: | ||
- apiVersion: v1 | ||
kind: Pod | ||
name: badpod01 |
13 changes: 13 additions & 0 deletions
13
test/conformance/kuttl/reports/background/background-scan-report-deletion/pod.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,13 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: badpod01 | ||
spec: | ||
containers: | ||
- name: container01 | ||
image: dummyimagename | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
runAsNonRoot: true | ||
seccompProfile: | ||
type: RuntimeDefault |
9 changes: 9 additions & 0 deletions
9
test/conformance/kuttl/reports/background/background-scan-report-deletion/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: podsecurity-subrule-restricted | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |
18 changes: 18 additions & 0 deletions
18
test/conformance/kuttl/reports/background/background-scan-report-deletion/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,18 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: podsecurity-subrule-restricted | ||
spec: | ||
background: true | ||
rules: | ||
- match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
name: restricted | ||
validate: | ||
podSecurity: | ||
level: restricted | ||
version: latest | ||
validationFailureAction: audit |