mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
cef4a9b546
commit
151d0b3298
3 changed files with 80 additions and 0 deletions
19
test/cli/test/restrict-something/kyverno-test.yaml
Normal file
19
test/cli/test/restrict-something/kyverno-test.yaml
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Taken from https://github.com/kyverno/kyverno/issues/6463
|
||||
name: repro-dups-bug
|
||||
policies:
|
||||
- policy.yaml
|
||||
resources:
|
||||
- resources.yaml
|
||||
results:
|
||||
- policy: restrict-something
|
||||
rule: validate-some-foo
|
||||
resources:
|
||||
- nginx-foo
|
||||
kind: Pod
|
||||
result: pass
|
||||
- policy: restrict-something
|
||||
rule: validate-some-non-foo
|
||||
resources:
|
||||
- nginx-too
|
||||
kind: Pod
|
||||
result: fail
|
42
test/cli/test/restrict-something/policy.yaml
Normal file
42
test/cli/test/restrict-something/policy.yaml
Normal file
|
@ -0,0 +1,42 @@
|
|||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: restrict-something
|
||||
spec:
|
||||
validationFailureAction: audit
|
||||
background: true
|
||||
rules:
|
||||
- name: validate-some-foo
|
||||
match:
|
||||
resources:
|
||||
kinds:
|
||||
- Pod
|
||||
namespaces:
|
||||
- foo
|
||||
validate:
|
||||
message: "Unknown image registry."
|
||||
deny:
|
||||
conditions:
|
||||
- key: "{{ images.containers.*.registry }}"
|
||||
operator: NotIn
|
||||
value:
|
||||
- "foo.io"
|
||||
- name: validate-some-non-foo
|
||||
match:
|
||||
any:
|
||||
- resources:
|
||||
kinds:
|
||||
- Pod
|
||||
exclude:
|
||||
any:
|
||||
- resources:
|
||||
namespaces:
|
||||
- foo
|
||||
validate:
|
||||
message: "Unknown image registry."
|
||||
deny:
|
||||
conditions:
|
||||
- key: "{{ images.containers.*.registry }}"
|
||||
operator: NotIn
|
||||
value:
|
||||
- "bar.io"
|
19
test/cli/test/restrict-something/resources.yaml
Normal file
19
test/cli/test/restrict-something/resources.yaml
Normal file
|
@ -0,0 +1,19 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: nginx-foo
|
||||
namespace: foo
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: foo.io/nginx:1.7.9
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: nginx-too
|
||||
namespace: bar
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: foo.io/nginx:1.7.9
|
Loading…
Reference in a new issue