diff --git a/charts/app/README.md b/charts/app/README.md index eafa071..6db816b 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 | `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 | + ---------------------------------------------- Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) diff --git a/charts/app/templates/HorizontalPodAutoscaler.yaml b/charts/app/templates/HorizontalPodAutoscaler.yaml new file mode 100644 index 0000000..6cc0a85 --- /dev/null +++ b/charts/app/templates/HorizontalPodAutoscaler.yaml @@ -0,0 +1,33 @@ +{{ $fullName := include "app.fullname" . }} +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ $fullName }} + 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 }} diff --git a/charts/app/values.yaml b/charts/app/values.yaml index 6d4576a..b5f1430 100644 --- a/charts/app/values.yaml +++ b/charts/app/values.yaml @@ -182,3 +182,10 @@ nodeSelector: { } tolerations: [ ] affinity: { } + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80