Ultimate Way of Installing Metrics Server for Production Kubernetes Clusters

Metrics are very important in your Kubernetes cluster because you need them to monitor the pod resource usage. You also need metrics to trigger an autoscale using an Horizontal Pod Autoscaler (HPA). Metrics Server provides CPU and memory metrics so you can see them in Kubernetes Dashboard’s fancy graphs.

Kubernetes dashboard showing CPU and memory metrics in graphs
CPU and memory metrics in Kubernetes Dashboard

Install Helm v3

We will use Helm v3 to install metrics-server. Because Helm v3 has no server-side component, you can install it just by downloading a binary.

Note: If you already have Helm v3 installed you can skip this step.

On your local machine run the following command to install Helm:

curl -sSL -o get_helm.sh \
https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

Please see Helm installation documentation for alternative installation options.

Add Bitnami chart repository to Helm

Because Bitnami maintains the metrics server chart you have to add it to Helm. Use the following command to add Bitnami chart repository to Helm:

helm repo add bitnami https://charts.bitnami.com/bitnami

If you already have Bitnami chart repository it’s worth updating it using the following:

helm repo update

Install Metrics Server Helm chart

The following is an example values file that contains replica and resource settings:

Save the values file above as “metrics-server-production.yaml” and run the following command:

helm install --namespace kube-system \
metrics-server bitnami/metrics-server \
-f metrics-server-production.yaml

Upgrade Metrics Server

When you need to make a change to your Metrics Server installation you can just run the following command:

helm upgrade --namespace kube-system \
metrics-server bitnami/metrics-server \
-f metrics-server-production.yaml

Last words

That’s all you need to prepare Metrics Server for a production cluster. Since its resource requirements are quite minimal your cluster shouldn’t have any difficulty running it. Depending on the size of your cluster resource requirements may need to be adjusted. Comment below if you have any issues installing Metrics Server on your Kubernetes cluster.

References

See also

Leave a Reply

Your email address will not be published. Required fields are marked *