1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

chore: use more chainsaw step templates (#11317)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2024-10-04 11:54:39 +02:00 committed by GitHub
parent a5858cbb64
commit db7584c417
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
322 changed files with 2430 additions and 2562 deletions

View file

@ -4,35 +4,43 @@ metadata:
name: conditional-anchor
spec:
steps:
- name: apply-namespace
try:
- apply:
file: namespace.yaml
- name: apply-policy
try:
- apply:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: apply-labelled-resource
try:
- apply:
file: labelled-resource.yaml
- name: apply-unlabelled-resource
try:
- apply:
file: unlabelled-resource.yaml
- name: apply-scaling
try:
- script:
content:
"if kubectl -n test-anchors scale deployment labelled-deployment --replicas 2\nthen
\n exit 0\nelse \n exit 1\nfi\n"
- script:
content:
"if kubectl -n test-anchors scale deployment labelled-deployment --replicas 9\nthen
\n exit 1\nelse \n exit 0\nfi\n"
- script:
content:
"if kubectl -n test-anchors scale deployment unlabelled-deployment --replicas 9\nthen
\n exit 0\nelse \n exit 1\nfi\n"
- name: apply-namespace
try:
- apply:
file: namespace.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: restrict-scale
- name: apply-labelled-resource
try:
- apply:
file: labelled-resource.yaml
- name: apply-unlabelled-resource
try:
- apply:
file: unlabelled-resource.yaml
- name: apply-scaling
try:
- script:
content:
"if kubectl -n test-anchors scale deployment labelled-deployment --replicas 2\nthen
\n exit 0\nelse \n exit 1\nfi\n"
- script:
content:
"if kubectl -n test-anchors scale deployment labelled-deployment --replicas 9\nthen
\n exit 1\nelse \n exit 0\nfi\n"
- script:
content:
"if kubectl -n test-anchors scale deployment unlabelled-deployment --replicas 9\nthen
\n exit 0\nelse \n exit 1\nfi\n"

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-scale
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,35 +4,43 @@ metadata:
name: conditional-anchor
spec:
steps:
- name: apply-namespace
try:
- apply:
file: namespace.yaml
- name: apply-policy
try:
- apply:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: apply-labelled-resource
try:
- apply:
file: labelled-resource.yaml
- name: apply-unlabelled-resource
try:
- apply:
file: unlabelled-resource.yaml
- name: apply-scaling
try:
- script:
content:
"if kubectl -n test-anchors scale deployment labelled-deployment --replicas 2\nthen
\n exit 0\nelse \n exit 1\nfi\n"
- script:
content:
"if kubectl -n test-anchors scale deployment labelled-deployment --replicas 9\nthen
\n exit 1\nelse \n exit 0\nfi\n"
- script:
content:
"if kubectl -n test-anchors scale deployment unlabelled-deployment --replicas 9\nthen
\n exit 0\nelse \n exit 1\nfi\n"
- name: apply-namespace
try:
- apply:
file: namespace.yaml
- name: create policy
use:
template: ../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: restrict-scale
- name: apply-labelled-resource
try:
- apply:
file: labelled-resource.yaml
- name: apply-unlabelled-resource
try:
- apply:
file: unlabelled-resource.yaml
- name: apply-scaling
try:
- script:
content:
"if kubectl -n test-anchors scale deployment labelled-deployment --replicas 2\nthen
\n exit 0\nelse \n exit 1\nfi\n"
- script:
content:
"if kubectl -n test-anchors scale deployment labelled-deployment --replicas 9\nthen
\n exit 1\nelse \n exit 0\nfi\n"
- script:
content:
"if kubectl -n test-anchors scale deployment unlabelled-deployment --replicas 9\nthen
\n exit 0\nelse \n exit 1\nfi\n"

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-scale
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: apply-on-deletion
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: cpol-apply-on-deletion
- name: step-02
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: cpol-apply-on-deletion
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: apply-on-deletion
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: cpol-apply-on-deletion
- name: step-02
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: cpol-apply-on-deletion
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: cel-messages-upon-resource-failure
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: disallow-host-port-in-pods
- name: step-02
try:
- script:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-port-in-pods
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: cel-messages-upon-resource-failure
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: disallow-host-port-in-pods
- name: step-02
try:
- script:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-port-in-pods
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,18 +4,34 @@ metadata:
name: check-message-upon-resource-failure
spec:
steps:
- name: step-01
try:
- apply:
file: policy-1.yaml
- assert:
file: policy-assert1.yaml
- name: step-02
try:
- apply:
file: policy-2.yaml
- assert:
file: policy-assert2.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy-1.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-ns-owner-label
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy-2.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: preconditions-check
- name: step-03
try:
- script:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-ns-owner-label
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: preconditions-check
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,18 +4,34 @@ metadata:
name: check-message-upon-resource-failure
spec:
steps:
- name: step-01
try:
- apply:
file: policy-1.yaml
- assert:
file: policy-assert1.yaml
- name: step-02
try:
- apply:
file: policy-2.yaml
- assert:
file: policy-assert2.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy-1.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: require-ns-owner-label
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy-2.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: preconditions-check
- name: step-03
try:
- script:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-ns-owner-label
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: preconditions-check
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,20 +4,28 @@ metadata:
name: different-configuration-for-actions
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: step-02
try:
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-ns-labels
- name: step-02
try:
- apply:
file: good-resources.yaml
- name: step-03
try:
- apply:
file: good-resources.yaml
- name: step-03
try:
- apply:
expect:
- check:
($error != null): true
file: bad-resources.yaml
expect:
- check:
($error != null): true
file: bad-resources.yaml

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-ns-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: ephemeral-containers
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: restrict-image-registries
- name: step-02
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-image-registries
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: ephemeral-containers
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: restrict-image-registries
- name: step-02
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-image-registries
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -10,15 +10,26 @@ spec:
file: keda.yaml
- assert:
file: keda-ready.yaml
- name: step-01
try:
- apply:
file: cluster-policy.yaml
- assert:
file: cluster-policy-ready.yaml
- name: step-02
try:
- apply:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: external-metrics-policy
- name: wait policy ready
use:
template: ../../../../_step-templates/policy-ready.yaml
with:
bindings:
- name: name
value: external-metrics-policy-default
- name: namespace
value: default

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: external-metrics-policy
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -1,30 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: external-metrics-policy
spec:
validationFailureAction: Enforce
background: false
rules:
- name: external-metrics-rule
match:
all:
- clusterRoles:
- evil-cr
resources:
kinds:
- Secret
validate:
message: 'You should be careful when trying to change/delete {{request.oldObject.kind}} in {{request.oldObject.name}}. These are my-precious resources and touching them might break my heart.'
deny:
conditions:
any:
- key: '{{request.operation}}'
operator: Equals
value: DELETE
- key: '{{request.operation}}'
operator: Equals
value: UPDATE
- key: '{{request.operation}}'
operator: Equals
value: CREATE

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: external-metrics-policy-default
namespace: default
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -1,4 +1,35 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: external-metrics-policy
spec:
validationFailureAction: Enforce
background: false
rules:
- name: external-metrics-rule
match:
all:
- clusterRoles:
- evil-cr
resources:
kinds:
- Secret
validate:
message: 'You should be careful when trying to change/delete {{request.oldObject.kind}} in {{request.oldObject.name}}. These are my-precious resources and touching them might break my heart.'
deny:
conditions:
any:
- key: '{{request.operation}}'
operator: Equals
value: DELETE
- key: '{{request.operation}}'
operator: Equals
value: UPDATE
- key: '{{request.operation}}'
operator: Equals
value: CREATE
---
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: external-metrics-policy-default
@ -28,4 +59,4 @@ spec:
value: UPDATE
- key: '{{request.operation}}'
operator: Equals
value: CREATE
value: CREATE

View file

@ -10,15 +10,26 @@ spec:
file: keda.yaml
- assert:
file: keda-ready.yaml
- name: step-01
try:
- apply:
file: cluster-policy.yaml
- assert:
file: cluster-policy-ready.yaml
- name: step-02
try:
- apply:
file: policy.yaml
- assert:
file: policy-ready.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: external-metrics-policy
- name: wait policy ready
use:
template: ../../../../_step-templates/policy-ready.yaml
with:
bindings:
- name: name
value: external-metrics-policy-default
- name: namespace
value: default

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: external-metrics-policy
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -1,30 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: external-metrics-policy
spec:
background: false
rules:
- name: external-metrics-rule
match:
all:
- clusterRoles:
- evil-cr
resources:
kinds:
- Secret
validate:
failureAction: Enforce
message: 'You should be careful when trying to change/delete {{request.oldObject.kind}} in {{request.oldObject.name}}. These are my-precious resources and touching them might break my heart.'
deny:
conditions:
any:
- key: '{{request.operation}}'
operator: Equals
value: DELETE
- key: '{{request.operation}}'
operator: Equals
value: UPDATE
- key: '{{request.operation}}'
operator: Equals
value: CREATE

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: external-metrics-policy-default
namespace: default
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -1,4 +1,35 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: external-metrics-policy
spec:
background: false
rules:
- name: external-metrics-rule
match:
all:
- clusterRoles:
- evil-cr
resources:
kinds:
- Secret
validate:
failureAction: Enforce
message: 'You should be careful when trying to change/delete {{request.oldObject.kind}} in {{request.oldObject.name}}. These are my-precious resources and touching them might break my heart.'
deny:
conditions:
any:
- key: '{{request.operation}}'
operator: Equals
value: DELETE
- key: '{{request.operation}}'
operator: Equals
value: UPDATE
- key: '{{request.operation}}'
operator: Equals
value: CREATE
---
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: external-metrics-policy-default
@ -28,4 +59,4 @@ spec:
value: UPDATE
- key: '{{request.operation}}'
operator: Equals
value: CREATE
value: CREATE

View file

@ -4,12 +4,20 @@ metadata:
name: variable-substitution-failure-messages
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: test-panic
- name: step-02
try:
- script:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: test-panic
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: variable-substitution-failure-messages
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: test-panic
- name: step-02
try:
- script:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: test-panic
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: psa-run-as-non-root
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: psp-restricted-limited
- name: step-02
try:
- script:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: psp-restricted-limited
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -8,9 +8,17 @@ spec:
try:
- apply:
file: chainsaw-step-00-apply-1-1.yaml
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: generate-cm-for-kube-state-metrics-crds

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: generate-cm-for-kube-state-metrics-crds
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -8,9 +8,17 @@ spec:
try:
- apply:
file: chainsaw-step-00-apply-1-1.yaml
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: generate-cm-for-kube-state-metrics-crds

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: generate-cm-for-kube-state-metrics-crds
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,30 +4,38 @@ metadata:
name: two-rules-with-different-action
spec:
steps:
- name: step-01
try:
- script:
content: kubectl patch configmap kyverno -p '{"data":{"generateSuccessEvents":"true"}}' -n kyverno
- assert:
file: kyverno-configmap-assert.yaml
- name: step-02
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: step-03
try:
- name: step-01
try:
- script:
content: kubectl patch configmap kyverno -p '{"data":{"generateSuccessEvents":"true"}}' -n kyverno
- assert:
file: kyverno-configmap-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-ns-labels
- name: step-03
try:
- apply:
file: good-resources.yaml
- name: step-04
try:
- apply:
file: good-resources.yaml
- name: step-04
try:
- apply:
expect:
- check:
($error != null): true
file: bad-resources.yaml
- name: step-05
try:
- assert:
file: events-assert.yaml
expect:
- check:
($error != null): true
file: bad-resources.yaml
- name: step-05
try:
- assert:
file: events-assert.yaml

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-ns-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,20 +4,28 @@ metadata:
name: validate-pattern-should-fail
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: step-02
try:
- apply:
expect:
- check:
($error != null): true
file: resource.yaml
- name: step-03
try:
- assert:
file: event-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: priv
- name: step-02
try:
- apply:
expect:
- check:
($error != null): true
file: resource.yaml
- name: step-03
try:
- assert:
file: event-assert.yaml

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: priv
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,20 +4,28 @@ metadata:
name: validate-pattern-should-fail
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: step-02
try:
- apply:
expect:
- check:
($error != null): true
file: resource.yaml
- name: step-03
try:
- assert:
file: event-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: priv
- name: step-02
try:
- apply:
expect:
- check:
($error != null): true
file: resource.yaml
- name: step-03
try:
- assert:
file: event-assert.yaml

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: priv
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,27 +4,35 @@ metadata:
name: validate-pattern-should-pass
spec:
steps:
- name: step-01
try:
- script:
content: kubectl patch configmap kyverno -p '{"data":{"generateSuccessEvents":"true"}}' -n kyverno
- name: step-01
try:
- script:
content: kubectl patch configmap kyverno -p '{"data":{"generateSuccessEvents":"true"}}' -n kyverno
- assert:
file: kyverno-configmap-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: priv
- name: step-03
try:
- apply:
file: resource.yaml
- name: step-04
try:
- assert:
file: kyverno-configmap-assert.yaml
- name: step-02
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: step-03
try:
- apply:
file: resource.yaml
- name: step-04
try:
- assert:
file: event-assert.yaml
- name: step-05
try:
- assert:
file: report-pass-assert.yaml
file: event-assert.yaml
- name: step-05
try:
- assert:
file: report-pass-assert.yaml

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: priv
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,27 +4,35 @@ metadata:
name: validate-pattern-should-pass
spec:
steps:
- name: step-01
try:
- script:
content: kubectl patch configmap kyverno -p '{"data":{"generateSuccessEvents":"true"}}' -n kyverno
- name: step-01
try:
- script:
content: kubectl patch configmap kyverno -p '{"data":{"generateSuccessEvents":"true"}}' -n kyverno
- assert:
file: kyverno-configmap-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: priv
- name: step-03
try:
- apply:
file: resource.yaml
- name: step-04
try:
- assert:
file: kyverno-configmap-assert.yaml
- name: step-02
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: step-03
try:
- apply:
file: resource.yaml
- name: step-04
try:
- assert:
file: event-assert.yaml
- name: step-05
try:
- assert:
file: report-pass-assert.yaml
file: event-assert.yaml
- name: step-05
try:
- assert:
file: report-pass-assert.yaml

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: priv
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,17 +4,25 @@ metadata:
name: validate-pattern-should-skip
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: step-02
try:
- apply:
file: resource.yaml
- name: step-03
try:
- assert:
file: report-skip-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: priv
- name: step-02
try:
- apply:
file: resource.yaml
- name: step-03
try:
- assert:
file: report-skip-assert.yaml

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: priv
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,17 +4,25 @@ metadata:
name: validate-pattern-should-skip
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: step-02
try:
- apply:
file: resource.yaml
- name: step-03
try:
- assert:
file: report-skip-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: priv
- name: step-02
try:
- apply:
file: resource.yaml
- name: step-03
try:
- assert:
file: report-skip-assert.yaml

View file

@ -1,10 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: priv
spec: {}
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: variable-substitution-failure-messages
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: uid-groups-fsgroup-validate
- name: step-02
try:
- script:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: uid-groups-fsgroup-validate
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: variable-substitution-failure-messages
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: uid-groups-fsgroup-validate
- name: step-02
try:
- script:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: uid-groups-fsgroup-validate
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: ingress-unique-host
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,16 +4,26 @@ metadata:
name: lazyload
spec:
steps:
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: ingress-unique-host
- name: step-01
try:
- apply:
file: chainsaw-step-01-apply-1-1.yaml
- apply:
file: chainsaw-step-01-apply-1-2.yaml
- apply:
file: chainsaw-step-01-apply-1-3.yaml
- assert:
file: chainsaw-step-01-assert-1-1.yaml
- assert:
file: chainsaw-step-01-assert-1-2.yaml
- name: step-02

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-subjectaccessreview
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -12,10 +12,20 @@ spec:
file: chainsaw-step-01-apply-1-2.yaml
- apply:
file: chainsaw-step-01-apply-1-3.yaml
- apply:
file: chainsaw-step-01-apply-1-4.yaml
- assert:
file: chainsaw-step-01-assert-1-1.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-subjectaccessreview
- name: step-02
try:
- apply:

View file

@ -8,12 +8,20 @@ spec:
try:
- apply:
file: ns-bad.yaml
- name: step-02
try:
- apply:
file: policy.yaml
- assert:
file: policy.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: default
- name: step-03
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: ingress-unique-host
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,16 +4,26 @@ metadata:
name: lazyload
spec:
steps:
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: ingress-unique-host
- name: step-01
try:
- apply:
file: chainsaw-step-01-apply-1-1.yaml
- apply:
file: chainsaw-step-01-apply-1-2.yaml
- apply:
file: chainsaw-step-01-apply-1-3.yaml
- assert:
file: chainsaw-step-01-assert-1-1.yaml
- assert:
file: chainsaw-step-01-assert-1-2.yaml
- name: step-02

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-subjectaccessreview
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -12,10 +12,20 @@ spec:
file: chainsaw-step-01-apply-1-2.yaml
- apply:
file: chainsaw-step-01-apply-1-3.yaml
- apply:
file: chainsaw-step-01-apply-1-4.yaml
- assert:
file: chainsaw-step-01-assert-1-1.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-subjectaccessreview
- name: step-02
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -10,10 +10,20 @@ spec:
file: chainsaw-step-01-apply-1-1.yaml
- apply:
file: chainsaw-step-01-apply-1-2.yaml
- apply:
file: chainsaw-step-01-apply-1-3.yaml
- assert:
file: chainsaw-step-01-assert-1-1.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: validate-labels
- name: step-02
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate-labels
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -10,10 +10,20 @@ spec:
file: chainsaw-step-01-apply-1-1.yaml
- apply:
file: chainsaw-step-01-apply-1-2.yaml
- apply:
file: chainsaw-step-01-apply-1-3.yaml
- assert:
file: chainsaw-step-01-assert-1-1.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: validate-labels
- name: step-02
try:
- apply:

View file

@ -4,12 +4,20 @@ metadata:
name: cel-preconditions
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: disallow-host-port-range
- name: step-02
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-port-range
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -10,12 +10,20 @@ spec:
file: ns.yaml
- assert:
file: ns.yaml
- name: step-02
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: image-matches-namespace-environment.policy.example.com
- name: step-03
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: image-matches-namespace-environment.policy.example.com
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -10,12 +10,20 @@ spec:
file: ns.yaml
- assert:
file: ns.yaml
- name: step-02
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-statefulset-namespace
- name: step-03
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-statefulset-namespace
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: disallow-host-port
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: disallow-host-port
- name: step-02
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-port
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -18,12 +18,20 @@ spec:
file: namespaceConstraint.yaml
- assert:
file: namespaceConstraint.yaml
- name: step-03
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-namespace-name-01
- name: step-04
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-namespace-name-01
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -16,12 +16,20 @@ spec:
file: nameConstraint.yaml
- assert:
file: nameConstraint.yaml
- name: step-03
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-namespace-name-02
- name: step-04
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-namespace-name-02
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -24,12 +24,20 @@ spec:
file: replicaLimit.yaml
- assert:
file: replicaLimit.yaml
- name: step-04
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-deployment-replicas-01
- name: step-05
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-deployment-replicas-01
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -24,12 +24,20 @@ spec:
file: replicaLimit.yaml
- assert:
file: replicaLimit.yaml
- name: step-04
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: check-statefulset-replicas
- name: step-05
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-statefulset-replicas
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -4,12 +4,20 @@ metadata:
name: cel-preconditions
spec:
steps:
- name: step-01
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: disallow-host-port-range
- name: step-02
try:
- apply:

View file

@ -1,9 +0,0 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-port-range
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -10,12 +10,20 @@ spec:
file: ns.yaml
- assert:
file: ns.yaml
- name: step-02
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml
- name: create policy
use:
template: ../../../../../_step-templates/create-policy.yaml
with:
bindings:
- name: file
value: policy.yaml
- name: wait policy ready
use:
template: ../../../../../_step-templates/cluster-policy-ready.yaml
with:
bindings:
- name: name
value: image-matches-namespace-environment.policy.example.com
- name: step-03
try:
- apply:

Some files were not shown because too many files have changed in this diff Show more