1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-01-20 18:52:16 +00:00
kyverno/examples/policy_mutate_validate_qos.yaml
2019-07-29 19:01:17 -07:00

50 lines
1.3 KiB
YAML

apiVersion : kyverno.io/v1alpha1
kind: Policy
metadata:
name: policy-qos
spec:
# validationFailureAction: "audit"
rules:
- name: add-memory-limit
match:
resources:
kinds:
- Deployment
selector :
matchLabels:
test: qos
mutate:
overlay:
spec:
template:
spec:
containers:
# the wildcard * will match all containers in the list
- (name): "*"
resources:
limits:
# add memory limit if it is not exist
"+(memory)": "300Mi"
"+(cpu)": "100"
- name: check-cpu-memory-limits
match:
resources:
kinds:
- Deployment
selector :
matchLabels:
test: qos
validate:
message: "Resource limits are required for CPU and memory"
pattern:
spec:
template:
spec:
containers:
# match all contianers
- (name): "*"
resources:
limits:
# cpu and memory are required
memory: "?*"
cpu: "?*"