Install metrics server in Kubernetes
The Metrics Server is a vital component in the Kubernetes ecosystem, providing valuable insights into resource usage across pods and nodes. It is the source of container resource metrics for auto-scaling objects in Kubernetes
Metrics Server collects resource metrics from Kubelets and exposes them in Kubernetes apiserver through Metrics API
Install the metrics server
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
Validate metrics server is installed
kubectl get pods -n kube-system
Note
After installation, you may find that metrics server is not in running state and “kubectl get apiservices” will show MissingEndpoints
v1beta1.metrics.k8s.io kube-system/metrics-server False (MissingEndpoints)
To fix this, you need to edit the deployment for metrics-server using below command
kubectl edit deployment metrics-server -n kube-system
- This will open the deployment yaml in an editor.
You can add an argument –kubelet-insecure-tls to existing args section. The new args section will look like below
containers: - args: - - cert-dir=/tmp - - kubelet-insecure-tls
Now you can verify that metrics server is running as expected
After metrics server is in running state, commands like kubectl top pods will work