Skip to content

Commit a031a08

Browse files
authored
Chart: Add resize policy. (#13906)
1 parent 7c43c91 commit a031a08

File tree

6 files changed

+57
-0
lines changed

6 files changed

+57
-0
lines changed

charts/ingress-nginx/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ metadata:
443443
| controller.readinessProbe.timeoutSeconds | int | `1` | |
444444
| controller.replicaCount | int | `1` | |
445445
| controller.reportNodeInternalIp | bool | `false` | Bare-metal considerations via the host network https://kubernetes.github.io/ingress-nginx/deploy/baremetal/#via-the-host-network Ingress status was blank because there is no Service exposing the Ingress-Nginx Controller in a configuration using the host network, the default --publish-service flag used in standard cloud setups does not apply |
446+
| controller.resizePolicy | list | `[]` | Resize policy for controller containers. Ref: https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources |
446447
| controller.resources.requests.cpu | string | `"100m"` | |
447448
| controller.resources.requests.memory | string | `"90Mi"` | |
448449
| controller.runtimeClassName | string | `""` | Instruct the kubelet to use the named RuntimeClass to run the pod |

charts/ingress-nginx/templates/controller-daemonset.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ spec:
174174
{{- if .Values.controller.resources }}
175175
resources: {{ toYaml .Values.controller.resources | nindent 12 }}
176176
{{- end }}
177+
{{- if semverCompare ">=1.33.0-0" .Capabilities.KubeVersion.Version }}
178+
{{- if .Values.controller.resizePolicy }}
179+
resizePolicy: {{ toYaml .Values.controller.resizePolicy | nindent 12 }}
180+
{{- end }}
181+
{{- end }}
177182
{{- if .Values.controller.extraContainers }}
178183
{{- toYaml .Values.controller.extraContainers | nindent 8 }}
179184
{{- end }}

charts/ingress-nginx/templates/controller-deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ spec:
180180
{{- if .Values.controller.resources }}
181181
resources: {{ toYaml .Values.controller.resources | nindent 12 }}
182182
{{- end }}
183+
{{- if semverCompare ">=1.33.0-0" .Capabilities.KubeVersion.Version }}
184+
{{- if .Values.controller.resizePolicy }}
185+
resizePolicy: {{ toYaml .Values.controller.resizePolicy | nindent 12 }}
186+
{{- end }}
187+
{{- end }}
183188
{{- if .Values.controller.extraContainers }}
184189
{{- toYaml .Values.controller.extraContainers | nindent 8 }}
185190
{{- end }}

charts/ingress-nginx/tests/controller-daemonset_test.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,23 @@ tests:
208208
- equal:
209209
path: spec.template.spec.runtimeClassName
210210
value: myClass
211+
212+
- it: should create a DaemonSet with resize policy if `controller.resizePolicy` is set
213+
capabilities:
214+
majorVersion: 1
215+
minorVersion: 33
216+
set:
217+
controller.kind: DaemonSet
218+
controller.resizePolicy:
219+
- resourceName: cpu
220+
restartPolicy: NotRequired
221+
- resourceName: memory
222+
restartPolicy: RestartContainer
223+
asserts:
224+
- equal:
225+
path: spec.template.spec.containers[0].resizePolicy
226+
value:
227+
- resourceName: cpu
228+
restartPolicy: NotRequired
229+
- resourceName: memory
230+
restartPolicy: RestartContainer

charts/ingress-nginx/tests/controller-deployment_test.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,22 @@ tests:
231231
- equal:
232232
path: spec.template.spec.runtimeClassName
233233
value: myClass
234+
235+
- it: should create a Deployment with resize policy if `controller.resizePolicy` is set
236+
capabilities:
237+
majorVersion: 1
238+
minorVersion: 33
239+
set:
240+
controller.resizePolicy:
241+
- resourceName: cpu
242+
restartPolicy: NotRequired
243+
- resourceName: memory
244+
restartPolicy: RestartContainer
245+
asserts:
246+
- equal:
247+
path: spec.template.spec.containers[0].resizePolicy
248+
value:
249+
- resourceName: cpu
250+
restartPolicy: NotRequired
251+
- resourceName: memory
252+
restartPolicy: RestartContainer

charts/ingress-nginx/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,13 @@ controller:
401401
requests:
402402
cpu: 100m
403403
memory: 90Mi
404+
# -- Resize policy for controller containers.
405+
# Ref: https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources
406+
resizePolicy: []
407+
# - resourceName: cpu
408+
# restartPolicy: NotRequired
409+
# - resourceName: memory
410+
# restartPolicy: RestartContainer
404411
# Mutually exclusive with keda autoscaling
405412
autoscaling:
406413
enabled: false

0 commit comments

Comments
 (0)