mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
chore: run background-only tests with chainsaw (#8943)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
This commit is contained in:
parent
dcea5b084d
commit
fc841c0417
48 changed files with 473 additions and 0 deletions
1
.github/workflows/conformance.yaml
vendored
1
.github/workflows/conformance.yaml
vendored
|
@ -196,6 +196,7 @@ jobs:
|
|||
# - verify-manifests
|
||||
# - verifyImages
|
||||
- webhooks
|
||||
- background-only
|
||||
needs: prepare-images
|
||||
name: chainsaw - ${{ matrix.k8s-version.name }} - ${{ matrix.config.name }} - ${{ matrix.tests }}
|
||||
steps:
|
||||
|
|
|
@ -3,6 +3,9 @@ kind: Configuration
|
|||
metadata:
|
||||
name: congiguration
|
||||
spec:
|
||||
timeouts:
|
||||
assert: 90s
|
||||
error: 90s
|
||||
parallel: 1
|
||||
fullName: true
|
||||
failFast: true
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: policy
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: policy.yaml
|
||||
- assert:
|
||||
file: policy-assert.yaml
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: resource
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: resource.yaml
|
|
@ -0,0 +1,12 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: event
|
||||
spec:
|
||||
try:
|
||||
- assert:
|
||||
file: background-event.yaml
|
||||
- error:
|
||||
file: admission-event.yaml
|
||||
catch:
|
||||
- events: {}
|
|
@ -0,0 +1,10 @@
|
|||
## Description
|
||||
|
||||
This test creates a policy with `admission` set to `false`.
|
||||
Then it creates a resource that violates the policy.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
The resource creates fine as the policy doesn't apply at admission time.
|
||||
No admission ezvent is created.
|
||||
One background event is created.
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: v1
|
||||
involvedObject:
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
name: pod
|
||||
kind: Event
|
||||
metadata: {}
|
||||
reportingComponent: kyverno-admission
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: v1
|
||||
involvedObject:
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
name: pod
|
||||
kind: Event
|
||||
metadata: {}
|
||||
reportingComponent: kyverno-scan
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: validate
|
||||
spec: {}
|
||||
status:
|
||||
conditions:
|
||||
- reason: Succeeded
|
||||
status: "True"
|
||||
type: Ready
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: validate
|
||||
spec:
|
||||
validationFailureAction: Enforce
|
||||
admission: false
|
||||
background: true
|
||||
rules:
|
||||
- name: validate
|
||||
match:
|
||||
any:
|
||||
- resources:
|
||||
kinds:
|
||||
- Pod
|
||||
validate:
|
||||
deny: {}
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod
|
||||
spec:
|
||||
containers:
|
||||
- name: container
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- containerPort: 80
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: policy
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: policy.yaml
|
||||
- assert:
|
||||
file: policy-assert.yaml
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: resource
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: resource.yaml
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: report
|
||||
spec:
|
||||
try:
|
||||
- error:
|
||||
file: admission-report.yaml
|
|
@ -0,0 +1,9 @@
|
|||
## Description
|
||||
|
||||
This test creates a policy with `admission` set to `false`.
|
||||
Then it creates a resource that violates the policy.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
The resource creates fine as the policy doesn't apply at admission time.
|
||||
No admission report is created.
|
|
@ -0,0 +1,7 @@
|
|||
apiVersion: kyverno.io/v1alpha2
|
||||
kind: AdmissionReport
|
||||
metadata:
|
||||
ownerReferences:
|
||||
- apiVersion: v1
|
||||
kind: Pod
|
||||
name: pod
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: validate
|
||||
spec: {}
|
||||
status:
|
||||
conditions:
|
||||
- reason: Succeeded
|
||||
status: "True"
|
||||
type: Ready
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: validate
|
||||
spec:
|
||||
validationFailureAction: Enforce
|
||||
admission: false
|
||||
background: true
|
||||
rules:
|
||||
- name: validate
|
||||
match:
|
||||
any:
|
||||
- resources:
|
||||
kinds:
|
||||
- Pod
|
||||
validate:
|
||||
deny: {}
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod
|
||||
spec:
|
||||
containers:
|
||||
- name: container
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- containerPort: 80
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: policy
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: policy.yaml
|
||||
- assert:
|
||||
file: policy-assert.yaml
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: resource
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: resource.yaml
|
|
@ -0,0 +1,8 @@
|
|||
## Description
|
||||
|
||||
This test creates a policy with `admission` set to `false`.
|
||||
Then it creates a resource that violates the policy.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
The resource creates fine as the policy doesn't apply at admission time.
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: validate
|
||||
spec: {}
|
||||
status:
|
||||
conditions:
|
||||
- reason: Succeeded
|
||||
status: "True"
|
||||
type: Ready
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: validate
|
||||
spec:
|
||||
validationFailureAction: Enforce
|
||||
admission: false
|
||||
background: true
|
||||
rules:
|
||||
- name: validate
|
||||
match:
|
||||
any:
|
||||
- resources:
|
||||
kinds:
|
||||
- Pod
|
||||
validate:
|
||||
deny: {}
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod
|
||||
spec:
|
||||
containers:
|
||||
- name: container
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- containerPort: 80
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: policy
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: policy.yaml
|
||||
- assert:
|
||||
file: policy-assert.yaml
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: resource
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: resource.yaml
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: event
|
||||
spec:
|
||||
try:
|
||||
- assert:
|
||||
file: background-event.yaml
|
||||
- error:
|
||||
file: admission-event.yaml
|
|
@ -0,0 +1,10 @@
|
|||
## Description
|
||||
|
||||
This test creates a policy with `admission` set to `false`.
|
||||
Then it creates a resource that violates the policy.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
The resource creates fine as the policy doesn't apply at admission time.
|
||||
No admission ezvent is created.
|
||||
One background event is created.
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: v1
|
||||
involvedObject:
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
name: pod
|
||||
kind: Event
|
||||
metadata: {}
|
||||
reportingComponent: kyverno-admission
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: v1
|
||||
involvedObject:
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
name: pod
|
||||
kind: Event
|
||||
metadata: {}
|
||||
reportingComponent: kyverno-scan
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: Policy
|
||||
metadata:
|
||||
name: validate
|
||||
spec: {}
|
||||
status:
|
||||
conditions:
|
||||
- reason: Succeeded
|
||||
status: "True"
|
||||
type: Ready
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: Policy
|
||||
metadata:
|
||||
name: validate
|
||||
spec:
|
||||
validationFailureAction: Enforce
|
||||
admission: false
|
||||
background: true
|
||||
rules:
|
||||
- name: validate
|
||||
match:
|
||||
any:
|
||||
- resources:
|
||||
kinds:
|
||||
- Pod
|
||||
validate:
|
||||
deny: {}
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod
|
||||
spec:
|
||||
containers:
|
||||
- name: container
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- containerPort: 80
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: policy
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: policy.yaml
|
||||
- assert:
|
||||
file: policy-assert.yaml
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: resource
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: resource.yaml
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: report
|
||||
spec:
|
||||
try:
|
||||
- error:
|
||||
file: admission-report.yaml
|
|
@ -0,0 +1,9 @@
|
|||
## Description
|
||||
|
||||
This test creates a policy with `admission` set to `false`.
|
||||
Then it creates a resource that violates the policy.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
The resource creates fine as the policy doesn't apply at admission time.
|
||||
No admission report is created.
|
|
@ -0,0 +1,7 @@
|
|||
apiVersion: kyverno.io/v1alpha2
|
||||
kind: AdmissionReport
|
||||
metadata:
|
||||
ownerReferences:
|
||||
- apiVersion: v1
|
||||
kind: Pod
|
||||
name: pod
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: Policy
|
||||
metadata:
|
||||
name: validate
|
||||
spec: {}
|
||||
status:
|
||||
conditions:
|
||||
- reason: Succeeded
|
||||
status: "True"
|
||||
type: Ready
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: Policy
|
||||
metadata:
|
||||
name: validate
|
||||
spec:
|
||||
validationFailureAction: Enforce
|
||||
admission: false
|
||||
background: true
|
||||
rules:
|
||||
- name: validate
|
||||
match:
|
||||
any:
|
||||
- resources:
|
||||
kinds:
|
||||
- Pod
|
||||
validate:
|
||||
deny: {}
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod
|
||||
spec:
|
||||
containers:
|
||||
- name: container
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- containerPort: 80
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
name: policy
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: policy.yaml
|
||||
- assert:
|
||||
file: policy-assert.yaml
|
|
@ -0,0 +1,9 @@
|
|||
apiVersion: chainsaw.kyverno.io/v1alpha1
|
||||
kind: TestStep
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: resource
|
||||
spec:
|
||||
try:
|
||||
- apply:
|
||||
file: resource.yaml
|
|
@ -0,0 +1,8 @@
|
|||
## Description
|
||||
|
||||
This test creates a policy with `admission` set to `false`.
|
||||
Then it creates a resource that violates the policy.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
The resource creates fine as the policy doesn't apply at admission time.
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: Policy
|
||||
metadata:
|
||||
name: validate
|
||||
spec: {}
|
||||
status:
|
||||
conditions:
|
||||
- reason: Succeeded
|
||||
status: "True"
|
||||
type: Ready
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: Policy
|
||||
metadata:
|
||||
name: validate
|
||||
spec:
|
||||
validationFailureAction: Enforce
|
||||
admission: false
|
||||
background: true
|
||||
rules:
|
||||
- name: validate
|
||||
match:
|
||||
any:
|
||||
- resources:
|
||||
kinds:
|
||||
- Pod
|
||||
validate:
|
||||
deny: {}
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod
|
||||
spec:
|
||||
containers:
|
||||
- name: container
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- containerPort: 80
|
Loading…
Reference in a new issue