mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-07 00:17:13 +00:00
86 lines
No EOL
2 KiB
YAML
86 lines
No EOL
2 KiB
YAML
apiVersion : kyverno.io/v1alpha1
|
|
kind : Policy
|
|
metadata :
|
|
name : policy-deployment
|
|
spec :
|
|
rules:
|
|
- name: add-label
|
|
match:
|
|
resources:
|
|
kinds :
|
|
- Deployment
|
|
selector :
|
|
matchLabels :
|
|
cli: test
|
|
mutate:
|
|
patches:
|
|
- path: /metadata/labels/isMutated
|
|
op: add
|
|
value: "true"
|
|
overlay:
|
|
spec:
|
|
template:
|
|
spec:
|
|
containers:
|
|
# if the image nginx, set the imagePullPolicy to Always
|
|
- (image): "*nginx*"
|
|
imagePullPolicy: "Always"
|
|
- name: add-label2
|
|
match:
|
|
resources:
|
|
kinds :
|
|
- Deployment
|
|
selector :
|
|
matchLabels :
|
|
cli: test
|
|
mutate:
|
|
patches:
|
|
- path: /metadata/labels/app1
|
|
op: replace
|
|
value: "nginx_is_mutated"
|
|
- name: add-label3
|
|
match:
|
|
resources:
|
|
kinds :
|
|
- Deployment
|
|
selector :
|
|
matchLabels :
|
|
cli: test
|
|
mutate:
|
|
patches:
|
|
- path: /metadata/labels/app2
|
|
op: add
|
|
value: "nginx_is_mutated2"
|
|
- name: check-image
|
|
match:
|
|
resources:
|
|
kinds :
|
|
- Deployment
|
|
selector :
|
|
matchLabels :
|
|
cli: test
|
|
validate:
|
|
message: "The imagePullPolicy must be Always when using image nginx"
|
|
pattern:
|
|
spec:
|
|
template:
|
|
spec:
|
|
containers:
|
|
- (image): "*nginx*"
|
|
imagePullPolicy: "Always"
|
|
- name: check-registries
|
|
match:
|
|
resources:
|
|
kinds:
|
|
- Deployment
|
|
- StatefulSet
|
|
validate:
|
|
message: "Registry is not allowed"
|
|
pattern:
|
|
spec:
|
|
template:
|
|
spec:
|
|
containers:
|
|
- name: "*"
|
|
# Check allowed registries
|
|
image: "*nirmata/* | launcher.gcr.io/*" |