2023-09-18 00:24:26 +02:00
|
|
|
---
|
2019-11-13 13:56:20 -08:00
|
|
|
apiVersion: kyverno.io/v1
|
2019-10-14 10:47:54 -07:00
|
|
|
kind: ClusterPolicy
|
2019-10-09 17:37:31 -07:00
|
|
|
metadata:
|
2019-10-11 18:57:16 -07:00
|
|
|
annotations:
|
2019-11-11 18:21:16 -08:00
|
|
|
policies.kyverno.io/category: Workload Management
|
2023-09-18 00:24:26 +02:00
|
|
|
policies.kyverno.io/description: As application workloads share cluster resources,
|
|
|
|
it is important to limit resources requested and consumed by each pod. It is
|
|
|
|
recommended to require 'resources.requests' and 'resources.limits.memory' per
|
|
|
|
pod. If a namespace level request or limit is specified, defaults will automatically
|
|
|
|
be applied to each pod based on the 'LimitRange' configuration.
|
|
|
|
name: require-pod-requests-limits
|
2019-10-09 17:37:31 -07:00
|
|
|
spec:
|
2023-09-18 00:24:26 +02:00
|
|
|
admission: true
|
|
|
|
background: true
|
2019-10-09 17:37:31 -07:00
|
|
|
rules:
|
2023-09-18 00:24:26 +02:00
|
|
|
- match:
|
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
|
|
|
name: validate-resources
|
2019-10-09 17:37:31 -07:00
|
|
|
validate:
|
2023-09-18 00:24:26 +02:00
|
|
|
message: CPU and memory resource requests and limits are required
|
2019-10-09 17:37:31 -07:00
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- resources:
|
|
|
|
limits:
|
2023-09-18 00:24:26 +02:00
|
|
|
memory: ?*
|
|
|
|
requests:
|
|
|
|
cpu: ?*
|
|
|
|
memory: ?*
|
|
|
|
validationFailureAction: Audit
|