Add ignoreLimits flag to container resources (#74)

This commit is contained in:
Youcef Guichi
2023-07-12 14:55:34 +02:00
committed by GitHub
parent 8c0968d1b5
commit aae45103a2
5 changed files with 39 additions and 2 deletions
Binary file not shown.
Binary file not shown.
@@ -117,8 +117,13 @@ spec:
{{- include "common.volumeMountsRef.tpl" . | nindent 10 }} {{- include "common.volumeMountsRef.tpl" . | nindent 10 }}
{{- if not .Values.resources.ignore }} {{- if not .Values.resources.ignore }}
resources: resources:
{{- if .Values.resources.ignoreLimits }}
requests:
{{- toYaml .Values.resources.requests | nindent 14 }}
{{- else }}
{{- toYaml .Values.resources | nindent 12 }} {{- toYaml .Values.resources | nindent 12 }}
{{- end }} {{- end }}
{{- end }}
{{- if .Values.sidecar }} {{- if .Values.sidecar }}
- name: {{ template "robustName" .Release.Name }}-sidecar - name: {{ template "robustName" .Release.Name }}-sidecar
securityContext: *securityContext securityContext: *securityContext
@@ -16,3 +16,25 @@ tests:
asserts: asserts:
- isNull: - isNull:
path: spec.template.spec.containers[0].resources path: spec.template.spec.containers[0].resources
- it: Should ignore resources limits when ignoreLimits flag is set
set:
resources:
ignoreLimits: true
asserts:
- isNull:
path: spec.template.spec.containers[0].resources.limits
- isNotNull:
path: spec.template.spec.containers[0].resources.requests
- it: Should create requests when ignoreLimits flag is set
set:
resources:
ignoreLimits: true
requests:
cpu: "1000m"
memory: "200Mi"
asserts:
- isNotNull:
path: spec.template.spec.containers[0].resources.requests
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 1000m
+10
View File
@@ -283,6 +283,16 @@
true true
] ]
}, },
"ignoreLimits": {
"$id": "#/properties/resources/properties/ignoreLimits",
"type": "boolean",
"title": "Ignore limits",
"description": "If set to true, limits in resource configuration will be ignored",
"default": false,
"examples": [
true
]
},
"requests": { "requests": {
"$id": "#/properties/resources/properties/requests", "$id": "#/properties/resources/properties/requests",
"type": "object", "type": "object",