Docker Kubernetes

Kubernetes Metrics Server on Docker Desktop

After setting up Docker Desktop and Kubernetes on WSL, I noticed that I was unable to gather cluster node CPU and memory information using kubectl top node. A quick look at the Kubernetes documentation indicated that I needed to install the Metrics Server. However, most current articles addressing how to install the Kubernetes Metrics Server for Docker Desktop are a bit out of date.

Here are the steps I followed to get the latest release of the Kubernetes Metrics Server running with the Docker Desktop Kubernetes release.

Deploying the Metrics Server

  1. Download the most recent components.yaml from the metrics-server GitHub repo.
  2. Edit components.yaml and add --kubelet-insecure-tls to the the args section for the metrics-server deployment:
          - --cert-dir=/tmp
          - --secure-port=4443
          - --kubelet-insecure-tls

  1. Apply components.yaml with kubectl apply -f components.yaml: created created created created
serviceaccount/metrics-server created
deployment.apps/metrics-server created
service/metrics-server created created created

  1. Enjoy your newly available CPU and memory statistics!
NAME             CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
docker-desktop   222m         5%     2046Mi          16%

Note that you may see a message like error: metrics not available yet right after the Metrics Server has been started. Just wait a bit and the statistics should be gathered successfully.

If you continue to see issues with the Metrics Server, you can troubleshoot by using kubectl describe pod metrics-server-<your-pod-id> -n kube-system to look at the pod’s most recent events.

Leave a Reply

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