Skip to content

add horizontalpodautoscaler #3276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions deployments/helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions deployments/helm-chart/templates/controller-hpa.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
15 changes: 15 additions & 0 deletions deployments/helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions docs/content/installation/installation-with-helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down