Kubernetes Metrics Server provides resource usage metrics of nodes and pods within a Kubernetes cluster. With it you can track CPU and memory usage within the cluster. It can then be leveraged for vertical and horizontal Pod scaling. Installation is fairly simple but if you’re using self-signed certificates within your cluster it will fail to run and collect metrics.
Below I detail the steps to quickly and easily install and configure Kubernetes Metrics Server using self-signed certificates.
If you have internet access from your cluster by far the easiest way to install is directly from the Kubernetes Sigs metric-server repo on GitHub.
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
This will apply all the required components for Metrics Server.
Once installed you will see a new deployment called metrics-server under the kube-system namespace. You will, however, notice that it won’t be in a Ready state.
We need to make a quick change to the metrics-server Deployment. You can do this by running the following command.
kubectl edit deployments.apps -n kube-system metrics-server
Scroll down and locate the args section of the deployed container. Press ‘i’ for insert mode and paste the following line in as an additional argument as shown below.
--kubelet-insecure-tls
Press escape and ‘:wq!’ to save the changed configuration of the deployment.
After a few moments you’ll notice the metrics-server Pod being recreated and the deployment now in a ready state.
It takes a few minutes for the metrics server to start collecting and reporting usage. At which point you can use kubectl top nodes and kubectl top pods to display those metrics.
This is a nice quick way to get Kubernetes Metrics Server up and going with self-signed certificates. With Metrics Server now running you can start to take advantage of things like Pod autoscaling.