From 766c7381b052b42ae629e29961a10edcff59dfb3 Mon Sep 17 00:00:00 2001 From: bn-ruslanpanasiuk Date: Wed, 30 Oct 2024 18:37:29 +0200 Subject: [PATCH 1/7] feat: Create HorizontalPodAutoscaler.yaml --- .../templates/HorizontalPodAutoscaler.yaml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 charts/app/templates/HorizontalPodAutoscaler.yaml diff --git a/charts/app/templates/HorizontalPodAutoscaler.yaml b/charts/app/templates/HorizontalPodAutoscaler.yaml new file mode 100644 index 0000000..d4f5cb9 --- /dev/null +++ b/charts/app/templates/HorizontalPodAutoscaler.yaml @@ -0,0 +1,34 @@ +{{ $fullName := include "app.fullname" . }} +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ $fullName }} + namespace: {{ .Values.namespace }} + labels: + {{- include "app.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ $fullname }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} +{{- end }} From 0db5807436c804ae761204d16bd9d6fb9c8df92a Mon Sep 17 00:00:00 2001 From: bn-ruslanpanasiuk Date: Wed, 30 Oct 2024 18:39:32 +0200 Subject: [PATCH 2/7] feat: add autoscaling options to values.yaml --- charts/app/values.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/charts/app/values.yaml b/charts/app/values.yaml index 6d4576a..b9400c0 100644 --- a/charts/app/values.yaml +++ b/charts/app/values.yaml @@ -182,3 +182,10 @@ nodeSelector: { } tolerations: [ ] affinity: { } + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 5 + targetCPUUtilizationPercentage: 90 + targetMemoryUtilizationPercentage: 90 From c794088a00a567aa99cd9255ca1a1d99af4ab804 Mon Sep 17 00:00:00 2001 From: bn-ruslanpanasiuk Date: Wed, 30 Oct 2024 18:43:13 +0200 Subject: [PATCH 3/7] fix: naming --- charts/app/templates/HorizontalPodAutoscaler.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/app/templates/HorizontalPodAutoscaler.yaml b/charts/app/templates/HorizontalPodAutoscaler.yaml index d4f5cb9..c318c47 100644 --- a/charts/app/templates/HorizontalPodAutoscaler.yaml +++ b/charts/app/templates/HorizontalPodAutoscaler.yaml @@ -11,7 +11,7 @@ spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: {{ $fullname }} + name: {{ $fullName }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} metrics: From caeada6d8bc4cac38f0d4020de3c4906d6ba8a10 Mon Sep 17 00:00:00 2001 From: bn-ruslanpanasiuk Date: Wed, 30 Oct 2024 18:49:50 +0200 Subject: [PATCH 4/7] fix: remove namespace from hpa --- charts/app/templates/HorizontalPodAutoscaler.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/charts/app/templates/HorizontalPodAutoscaler.yaml b/charts/app/templates/HorizontalPodAutoscaler.yaml index c318c47..6cc0a85 100644 --- a/charts/app/templates/HorizontalPodAutoscaler.yaml +++ b/charts/app/templates/HorizontalPodAutoscaler.yaml @@ -4,7 +4,6 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: {{ $fullName }} - namespace: {{ .Values.namespace }} labels: {{- include "app.labels" . | nindent 4 }} spec: From 94e12cb3db6e0598ebb5da339e41ff7c9894673a Mon Sep 17 00:00:00 2001 From: bn-ruslanpanasiuk Date: Wed, 30 Oct 2024 18:52:51 +0200 Subject: [PATCH 5/7] feat: Update README.md --- charts/app/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/charts/app/README.md b/charts/app/README.md index eafa071..d95bbac 100644 --- a/charts/app/README.md +++ b/charts/app/README.md @@ -67,6 +67,12 @@ Common Web application Helm Chart | startupProbe.enabled | bool | `true` | | | tolerations | list | `[]` | | | volumes | list | `[]` | | +| autoscaling.enabled | bool | `false` | Enable or disable Horizontal Pod Autoscaling | +| autoscaling.minReplicas | int | `1` | Minimum number of replicas for autoscaling | +| autoscaling.maxReplicas | int | `10` | Maximum number of replicas for autoscaling | +| autoscaling.targetCPUUtilizationPercentage | int | `80` | Target CPU utilization percentage for autoscaling | +| autoscaling.targetMemoryUtilizationPercentage | int | `80` | Target memory utilization percentage for autoscaling | + ---------------------------------------------- Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) From 1311edd1caf02f8e343b4699d9461c7437594332 Mon Sep 17 00:00:00 2001 From: bn-ruslanpanasiuk Date: Wed, 30 Oct 2024 19:51:06 +0200 Subject: [PATCH 6/7] fix: Update README.md --- charts/app/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/app/README.md b/charts/app/README.md index d95bbac..6db816b 100644 --- a/charts/app/README.md +++ b/charts/app/README.md @@ -69,9 +69,9 @@ Common Web application Helm Chart | volumes | list | `[]` | | | autoscaling.enabled | bool | `false` | Enable or disable Horizontal Pod Autoscaling | | autoscaling.minReplicas | int | `1` | Minimum number of replicas for autoscaling | -| autoscaling.maxReplicas | int | `10` | Maximum number of replicas for autoscaling | -| autoscaling.targetCPUUtilizationPercentage | int | `80` | Target CPU utilization percentage for autoscaling | -| autoscaling.targetMemoryUtilizationPercentage | int | `80` | Target memory utilization percentage for autoscaling | +| autoscaling.maxReplicas | int | `5` | Maximum number of replicas for autoscaling | +| autoscaling.targetCPUUtilizationPercentage | int | `90` | Target CPU utilization percentage for autoscaling | +| autoscaling.targetMemoryUtilizationPercentage | int | `90` | Target memory utilization percentage for autoscaling | ---------------------------------------------- From a7b9c5163e79d7bff5aab7b0a2d8e03d9ff20aca Mon Sep 17 00:00:00 2001 From: bn-ruslanpanasiuk Date: Thu, 7 Nov 2024 13:59:13 +0200 Subject: [PATCH 7/7] fix: Update values.yaml --- charts/app/values.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/app/values.yaml b/charts/app/values.yaml index b9400c0..b5f1430 100644 --- a/charts/app/values.yaml +++ b/charts/app/values.yaml @@ -186,6 +186,6 @@ affinity: { } autoscaling: enabled: false minReplicas: 1 - maxReplicas: 5 - targetCPUUtilizationPercentage: 90 - targetMemoryUtilizationPercentage: 90 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80