Chart: Align HPA & KEDA conditions. (#11110)

This commit is contained in:
Marco Ebert 2024-03-12 14:43:51 +01:00 committed by GitHub
parent aa5deedae3
commit 9480cde724
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 70 additions and 8 deletions

View file

@ -19,7 +19,7 @@ spec:
matchLabels:
{{- include "ingress-nginx.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: controller
{{- if not (or .Values.controller.autoscaling.enabled .Values.controller.keda.enabled) }}
{{- if eq .Values.controller.autoscaling.enabled .Values.controller.keda.enabled }}
replicas: {{ .Values.controller.replicaCount }}
{{- end }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}

View file

@ -1,4 +1,4 @@
{{- if and .Values.controller.keda.enabled (eq .Values.controller.kind "Deployment") -}}
{{- if and (eq .Values.controller.kind "Deployment") .Values.controller.keda.enabled (not .Values.controller.autoscaling.enabled) -}}
apiVersion: {{ .Values.controller.keda.apiVersion }}
kind: ScaledObject
metadata:

View file

@ -1,7 +1,10 @@
# PDB is not supported for DaemonSets.
# https://github.com/kubernetes/kubernetes/issues/108124
{{- if eq .Values.controller.kind "Deployment" }}
{{- $replicas := .Values.controller.replicaCount }}
{{- if .Values.controller.autoscaling.enabled }}
{{- if and .Values.controller.autoscaling.enabled (not .Values.controller.keda.enabled) }}
{{- $replicas = .Values.controller.autoscaling.minReplicas }}
{{- else if .Values.controller.keda.enabled }}
{{- else if and .Values.controller.keda.enabled (not .Values.controller.autoscaling.enabled) }}
{{- $replicas = .Values.controller.keda.minReplicas }}
{{- end }}
{{- if gt ($replicas | int) 1 }}
@ -30,3 +33,4 @@ spec:
maxUnavailable: {{ .Values.controller.maxUnavailable }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -21,6 +21,28 @@ tests:
path: spec.replicas
value: 3
- it: should create a Deployment without replicas if `controller.autoscaling.enabled` is true
set:
controller.autoscaling.enabled: true
asserts:
- notExists:
path: spec.replicas
- it: should create a Deployment without replicas if `controller.keda.enabled` is true
set:
controller.keda.enabled: true
asserts:
- notExists:
path: spec.replicas
- it: should create a Deployment with replicas if `controller.autoscaling.enabled` is true and `controller.keda.enabled` is true
set:
controller.autoscaling.enabled: true
controller.keda.enabled: true
asserts:
- exists:
path: spec.replicas
- it: should create a Deployment with argument `--enable-metrics=false` if `controller.metrics.enabled` is false
set:
controller.metrics.enabled: false

View file

@ -3,9 +3,8 @@ templates:
- controller-hpa.yaml
tests:
- it: should create a HPA if `controller.kind` is "Deployment" and `controller.autoscaling.enabled` is true
- it: should create an HPA if `controller.autoscaling.enabled` is true
set:
controller.kind: Deployment
controller.autoscaling.enabled: true
asserts:
- hasDocuments:
@ -15,3 +14,18 @@ tests:
- equal:
path: metadata.name
value: RELEASE-NAME-ingress-nginx-controller
- it: should not create an HPA if `controller.autoscaling.enabled` is true and `controller.keda.enabled` is true
set:
controller.autoscaling.enabled: true
controller.keda.enabled: true
asserts:
- hasDocuments:
count: 0
- it: should not create an HPA if `controller.kind` is "DaemonSet"
set:
controller.kind: DaemonSet
asserts:
- hasDocuments:
count: 0

View file

@ -3,9 +3,8 @@ templates:
- controller-keda.yaml
tests:
- it: should create a ScaledObject if `controller.kind` is "Deployment" and `controller.keda.enabled` is true
- it: should create a ScaledObject if `controller.keda.enabled` is true
set:
controller.kind: Deployment
controller.keda.enabled: true
asserts:
- hasDocuments:
@ -15,3 +14,18 @@ tests:
- equal:
path: metadata.name
value: RELEASE-NAME-ingress-nginx-controller
- it: should not create a ScaledObject if `controller.keda.enabled` is true and `controller.autoscaling.enabled` is true
set:
controller.keda.enabled: true
controller.autoscaling.enabled: true
asserts:
- hasDocuments:
count: 0
- it: should not create a ScaledObject if `controller.kind` is "DaemonSet"
set:
controller.kind: DaemonSet
asserts:
- hasDocuments:
count: 0

View file

@ -63,3 +63,11 @@ tests:
asserts:
- hasDocuments:
count: 0
- it: should not create a PodDisruptionBudget if `controller.autoscaling.enabled` is true and `controller.keda.enabled` is true
set:
controller.autoscaling.enabled: true
controller.keda.enabled: true
asserts:
- hasDocuments:
count: 0