Karbon and Metrics API: A simple approach with metrics-server

Nutanix.dev - Karbon and Metrics API A simple approach with metrics-server

In a previous article Karbon and Metrics API: A Practical Guide we have seen how to implement the Prometheus Adapter to expose all the features of the Metrics API (resource metricscustom metrics, and external metrics APIs).

In some cases like troubleshooting or simple autoscaling needs, a more basic approach may be enough.

With the release of karbon 2.4, internal architecture changes have been made and it is now even easier to install metrics-server component in a secure way.

Install Kubernetes Metrics Server

Verify the prerequisites

In order to follow this guide, you need an already deployed Karbon Kubernetes cluster.

Prism Karbon clusters view

Once the cluster is deployed, you can download the kubeconfig admin file and install it on your workstation. This can be done from the Prism graphical interface or with the karbon kubectl plugin.

This image has an empty alt attribute; its file name is image-1024x769.png
Prism UI to download Kubeconfig

Metrics Server helm chart

The preferred way to install metrics-server on Karbon is to use Helm (v3+).

Helm installation is easy by following the official documentation.

Next you need to add the metrics-server Helm repository and install the metrics-server helm chart with the right options.

helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/ && helm repo update

helm install --wait -n metrics-server --create-namespace metrics-server metrics-server/metrics-server --set replicas=2

For more information or to go deeper in metrics-server settings, visit the official documentation.

Verify metrics-server install

Waiting a few minutes, you should see the pods in the metrics-server namespace running.

You can also verify if your metrics-server is correctly integrated in the API aggregation layer.

you will see the metrics API redirecting the metrics-server service

Test the resource Metrics API

Now that your metrics-server component is installed, it is easy to test it with the kubectl top command.

Conclusion

Through this short article you have seen how extremely simple it is to start using the resources Metrics API as well as troubleshooting.

This can also be a starting point to explore the logic of Horizon Pod Autoscaling mechanism.

Related Resources