Install HorizontalPodAutoscaler (HPA) using Helm
I'd like to do all k8s installation, configuration, and maintenance using Helm v3 (v3.7.2).
Thus I have setup yaml templates for:
- deployment
- configmap
- service
- ingress
Yet I can't find any information in the Helm v3 docs on setting up an HPA (HorizontalPodAutoscaler). Can this be done using an hpa.yaml that pulls from values.yaml?
Solution 1:
Yes. Example, try helm create nginx
will create a template project call "nginx", and inside the "nginx" directory you will find a templates/hpa.yaml example. Inside the values.yaml -> autoscaling is what control the HPA resources:
autoscaling:
enabled: false # <-- change to true to create HPA
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
Solution 2:
Can this be done using an hpa.yaml that pulls from values.yaml?
Yes. HPA is a native Kubernetes resource that you can template out just like you have done for your other resources. Helm is both a package management system and a templating tool, but it is unlikely its docs contain specific examples for all Kubernetes API objects.
You can see many examples of HPA templates in the Bitnami Helm Charts. For example, apache has an hpa.yaml
that is templated-out if .Values.autoscaling.enabled
.