1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/test/conformance/chainsaw/webhook-configurations/cpol-match-conditions-pass/policy.yaml
shuting 273a0a52f9
chore: add chainsaw tests for policy based webhook configuration (#9561)
* add chainsaw tests

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* add chainsaw tests

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* update policy

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* add delay

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* add debug steps

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* attempt fix

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* attempt fix

Signed-off-by: ShutingZhao <shuting@nirmata.com>

---------

Signed-off-by: ShutingZhao <shuting@nirmata.com>
2024-01-31 16:44:01 +00:00

43 lines
No EOL
1 KiB
YAML

---
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
annotations:
pod-policies.kyverno.io/autogen-controllers: none
name: cpol-fine-grained-match-conditions-pass
spec:
admission: true
background: true
webhookConfiguration:
matchConditions:
- name: "select-namespace"
expression: '(object.metadata.namespace == "cpol-fine-grained-match-conditions-pass-ns")'
- name: 'exclude-requests-by-groups'
expression: '!("system:authenticated" in request.userInfo.groups)'
rules:
- match:
any:
- resources:
kinds:
- Pod
name: require-image-tag
validate:
message: An image tag is required
pattern:
spec:
containers:
- image: '*:*'
- match:
any:
- resources:
kinds:
- Pod
name: validate-image-tag
validate:
message: Using a mutable image tag e.g. 'latest' is not allowed
pattern:
spec:
containers:
- image: '!*:latest'
validationFailureAction: Enforce
failurePolicy: Ignore