1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/samples/RequirePodRequestsLimits.md

36 lines
1.1 KiB
Markdown
Raw Normal View History

2019-10-23 14:06:03 -07:00
# Require pod resource requests and limits
Application workloads share cluster resources. Hence, it is important to manage resources assigned to each pod. It is recommended that `resources.requests.cpu`, `resources.requests.memory` and `resources.limits.memory` are configured per pod. Other resources such as GPUs may also be specified as needed.
2019-10-23 15:36:37 -07:00
2020-11-11 15:55:02 -05:00
If a namespace level request or limit is specified, defaults will automatically be applied to each pod based on the `LimitRange` configuration.
2019-10-23 14:06:03 -07:00
2020-11-11 15:55:02 -05:00
## Policy YAML
2019-10-23 14:06:03 -07:00
[require_pod_requests_limits.yaml](best_practices/require_pod_requests_limits.yaml)
````yaml
2019-11-13 13:56:20 -08:00
apiVersion: kyverno.io/v1
2019-10-23 14:06:03 -07:00
kind: ClusterPolicy
metadata:
2019-11-10 21:06:49 -08:00
name: require-pod-requests-limits
2019-10-23 14:06:03 -07:00
spec:
validationFailureAction: audit
2019-10-23 14:06:03 -07:00
rules:
2019-11-10 21:06:49 -08:00
- name: validate-resources
2019-10-23 14:06:03 -07:00
match:
resources:
kinds:
- Pod
validate:
message: "CPU and memory resource requests and limits are required"
pattern:
spec:
containers:
- resources:
requests:
memory: "?*"
cpu: "?*"
limits:
memory: "?*"
````