All Policies
Memory Requests Equal Limits
Pods which have memory limits equal to requests could be given a QoS class of Guaranteed if they also set CPU limits equal to requests. Guaranteed is the highest schedulable class. This policy checks that all containers in a given Pod have memory requests equal to limits.
Policy Definition
/other/memory-requests-equal-limits/memory-requests-equal-limits.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: memory-requests-equal-limits
5 annotations:
6 policies.kyverno.io/title: Memory Requests Equal Limits
7 policies.kyverno.io/category: Sample
8 policies.kyverno.io/severity: medium
9 policies.kyverno.io/subject: Pod
10 policies.kyverno.io/minversion: 1.6.0
11 policies.kyverno.io/description: >-
12 Pods which have memory limits equal to requests could be given a QoS class of Guaranteed if
13 they also set CPU limits equal to requests. Guaranteed is the highest schedulable class.
14 This policy checks that all containers in a given Pod have memory requests equal to limits.
15spec:
16 validationFailureAction: Audit
17 background: false
18 rules:
19 - name: memory-requests-equal-limits
20 match:
21 any:
22 - resources:
23 kinds:
24 - Pod
25 validate:
26 message: "resources.requests.memory must be equal to resources.limits.memory"
27 deny:
28 conditions:
29 any:
30 - key: "{{ request.object.spec.containers[?resources.requests.memory!=resources.limits.memory] | length(@) }}"
31 operator: NotEquals
32 value: 0