Categories
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:
        args:
          - --cert-dir=/tmp
          - --secure-port=4443
          - --kubelet-insecure-tls

  1. Apply components.yaml with kubectl apply -f components.yaml:
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
serviceaccount/metrics-server created
deployment.apps/metrics-server created
service/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server 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 *