diff --git a/deployments/helm-chart/README.md b/deployments/helm-chart/README.md index 65a402e799..fce988fce2 100644 --- a/deployments/helm-chart/README.md +++ b/deployments/helm-chart/README.md @@ -248,6 +248,12 @@ Parameter | Description | Default `controller.readyStatus.initialDelaySeconds` | The number of seconds after the Ingress Controller pod has started before readiness probes are initiated. | 0 `controller.enableLatencyMetrics` | Enable collection of latency metrics for upstreams. Requires `prometheus.create`. | false `controller.minReadySeconds` | Specifies the minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available. [docs](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#min-ready-seconds) | 0 +`controller.autoscaling.enabled` | Enables HorizontalPodAutoscaling. | false +`controller.autoscaling.annotations` | The annotations of the Ingress Controller HorizontalPodAutoscaler. | {} +`controller.autoscaling.minReplicas` | Minimum number of replicas for the HPA. | 1 +`controller.autoscaling.maxReplicas` | Maximum number of replicas for the HPA. | 3 +`controller.autoscaling.targetCPUUtilizationPercentage` | The target CPU utilization percentage. | 50 +`controller.autoscaling.targetMemoryUtilizationPercentage` | The target memory utilization percentage. | 50 `controller.strategy` | Specifies the strategy used to replace old Pods by new ones. [docs](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy) | {} `controller.disableIPV6` | Disable IPV6 listeners explicitly for nodes that do not support the IPV6 stack. | false `rbac.create` | Configures RBAC. | true diff --git a/deployments/helm-chart/templates/controller-hpa.yaml b/deployments/helm-chart/templates/controller-hpa.yaml new file mode 100644 index 0000000000..1d705f15d1 --- /dev/null +++ b/deployments/helm-chart/templates/controller-hpa.yaml @@ -0,0 +1,37 @@ +{{- if and .Values.controller.autoscaling.enabled (eq .Values.controller.kind "deployment") (semverCompare ">=1.23.0" .Capabilities.KubeVersion.Version) -}} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "nginx-ingress.serviceName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "nginx-ingress.labels" . | nindent 4 }} +{{- if .Values.controller.autoscaling.annotations }} + annotations: +{{ toYaml .Values.controller.autoscaling.annotations | indent 4 }} +{{- end }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ default (include "nginx-ingress.name" .) .Values.controller.name }} + minReplicas: {{ .Values.controller.autoscaling.minReplicas }} + maxReplicas: {{ .Values.controller.autoscaling.maxReplicas }} + metrics: + {{- if .Values.controller.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.controller.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.controller.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.controller.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/helm-chart/values.yaml b/deployments/helm-chart/values.yaml index 85788bd8b8..1a0dd650f9 100644 --- a/deployments/helm-chart/values.yaml +++ b/deployments/helm-chart/values.yaml @@ -119,6 +119,21 @@ controller: ## The termination grace period of the Ingress Controller pod. terminationGracePeriodSeconds: 30 + ## HorizontalPodAutoscaling (HPA) + autoscaling: + ## Enables HorizontalPodAutoscaling. + enabled: false + ## The annotations of the Ingress Controller HorizontalPodAutoscaler. + annotations: {} + ## Minimum number of replicas for the HPA. + minReplicas: 1 + ## Maximum number of replicas for the HPA. + maxReplicas: 3 + ## The target cpu utilization percentage. + targetCPUUtilizationPercentage: 50 + ## The target memory utilization percentage. + targetMemoryUtilizationPercentage: 50 + ## The resources of the Ingress Controller pods. resources: requests: diff --git a/docs/content/installation/installation-with-helm.md b/docs/content/installation/installation-with-helm.md index 5222b891f9..937e597abe 100644 --- a/docs/content/installation/installation-with-helm.md +++ b/docs/content/installation/installation-with-helm.md @@ -236,6 +236,12 @@ The following tables lists the configurable parameters of the NGINX Ingress Cont |``controller.readyStatus.initialDelaySeconds`` | The number of seconds after the Ingress Controller pod has started before readiness probes are initiated. | 0 | |``controller.enableLatencyMetrics`` | Enable collection of latency metrics for upstreams. Requires ``prometheus.create``. | false | |``controller.minReadySeconds`` | Specifies the minimum number of seconds for which a newly created Pod should be ready, without any of its containers crashing, for it to be considered available. [docs](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#min-ready-seconds) | 0 | +|``controller.autoscaling.enabled`` | Enables HorizontalPodAutoscaling. | false | +|``controller.autoscaling.annotations`` | The annotations of the Ingress Controller HorizontalPodAutoscaler. | {} | +|``controller.autoscaling.minReplicas`` | Minimum number of replicas for the HPA. | 1 | +|``controller.autoscaling.maxReplicas`` | Maximum number of replicas for the HPA. | 3 | +|``controller.autoscaling.targetCPUUtilizationPercentage`` | The target CPU utilization percentage. | 50 | +|``controller.autoscaling.targetMemoryUtilizationPercentage`` | The target memory utilization percentage. | 50 | |``controller.strategy`` | Specifies the strategy used to replace old Pods with new ones. [docs](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy) | {} | | `controller.disableIPV6` | Disable IPV6 listeners explicitly for nodes that do not support the IPV6 stack. | false | |``rbac.create`` | Configures RBAC. | true |