2019-06-22 16:05:06 -07:00
|
|
|
apiVersion : kyverno.io/v1alpha1
|
|
|
|
kind: Policy
|
|
|
|
metadata:
|
|
|
|
name: policy-qos
|
|
|
|
spec:
|
|
|
|
rules:
|
|
|
|
- name: add-memory-limit
|
|
|
|
resource:
|
|
|
|
kinds:
|
|
|
|
- Deployment
|
|
|
|
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"
|
|
|
|
- name: check-cpu-memory-limits
|
|
|
|
resource:
|
|
|
|
kinds:
|
2019-06-23 16:28:43 -07:00
|
|
|
- Deployment
|
2019-06-22 16:05:06 -07:00
|
|
|
validate:
|
|
|
|
message: "Resource limits are required for CPU and memory"
|
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
template:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
# match all contianers
|
|
|
|
- (name): "*"
|
|
|
|
resources:
|
|
|
|
limits:
|
2019-06-24 10:42:38 -07:00
|
|
|
# cpu and memory are required
|
2019-06-22 16:05:06 -07:00
|
|
|
memory: "?*"
|
|
|
|
cpu: "?*"
|