2023-09-18 00:24:26 +02:00
|
|
|
---
|
2021-06-08 02:05:53 +05:30
|
|
|
apiVersion: kyverno.io/v1
|
|
|
|
kind: ClusterPolicy
|
|
|
|
metadata:
|
|
|
|
name: select-secrets
|
|
|
|
spec:
|
2023-09-18 00:24:26 +02:00
|
|
|
admission: true
|
2021-06-08 02:05:53 +05:30
|
|
|
background: false
|
|
|
|
rules:
|
2023-09-18 00:24:26 +02:00
|
|
|
- context:
|
|
|
|
- apiCall:
|
|
|
|
jmesPath: metadata.labels.foo
|
|
|
|
method: GET
|
|
|
|
urlPath: /api/v1/namespaces/{{request.object.metadata.namespace}}/secrets/{{request.object.spec.volumes[0].secret.secretName}}
|
|
|
|
name: volsecret
|
2021-06-08 02:05:53 +05:30
|
|
|
match:
|
2023-09-18 00:24:26 +02:00
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
|
|
|
name: select-secrets-from-volumes
|
2021-06-08 02:05:53 +05:30
|
|
|
preconditions:
|
2023-09-18 00:24:26 +02:00
|
|
|
all:
|
|
|
|
- key: '{{ request.operation }}'
|
|
|
|
operator: Equals
|
|
|
|
value: CREATE
|
2021-06-08 02:05:53 +05:30
|
|
|
validate:
|
2023-09-18 00:24:26 +02:00
|
|
|
message: The Secret named {{request.object.spec.volumes[0].secret.secretName}}
|
|
|
|
is restricted and may not be used.
|
2021-06-08 02:05:53 +05:30
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
containers:
|
2023-09-18 00:24:26 +02:00
|
|
|
- image: registry.domain.com/*
|
|
|
|
validationFailureAction: Enforce
|