Configure Horizontal Pod AutoScaler (HPA)

Deploy the Metrics Server

Metrics Server is a scalable, efficient source of container resource metrics for Kubernetes built-in autoscaling pipelines.

These metrics will drive the scaling behavior of the deployments.

We will deploy the metrics server using Helm configured in a previous module

# create the metrics-service namespace
kubectl create namespace metrics

# deploy the metrics-server
helm install metrics-server \
    stable/metrics-server \
    --version 2.11.1 \
    --namespace metrics

Some versions of EKS may get the following error once you create the HPA in the next step

kubectl describe hpa

... failed to get cpu utilization: unable to get metrics for resource cpu

To fix, set the following values for the metric-server helm release as described here

  - --kubelet-preferred-address-types=InternalIP

Lets’ verify the status of the metrics-server APIService (it could take several minutes)

kubectl get apiservice -o yaml | yq - r 'status'

  - lastTransitionTime: "2020-02-18T21:33:26Z"
    message: all checks passed
    reason: Passed
    status: "True"
    type: Available

We are now ready to scale a deployed application