rancher-desktop: Docker stats and kubectl top pod not working when on moby engine

Actual Behavior

kubectl top pod shows error: Metrics not available docker stats shows all stats zero for every container

Steps to Reproduce

just run: kubectl top pod or docker stats

Result

kubectl top pod shows error: Metrics not available docker stats shows all stats zero for every container

Expected Behavior

Some nice values

Additional Information

Minikube on ubuntu works On containerd engine it returns statistics for kubectl top pod but I cannot use containerd for other reasons. HorizontalPodAutoscaler is not working because of this docker.log shows error level messages:

  • collecting stats for <id>: no metrics received
  • loading cgroup for <number> error=cgroups: cannot find cgroup mount destination

It looks like it might work on cgroupv2 (minikube on ubuntu works) but the rancher-desktop vm is on cgroups v1 and there might be some incompatibility with fresh containerd and moby, but this is just my speculation.

Rancher Desktop Version

1.9.1

Rancher Desktop K8s Version

1.27.3

Which container engine are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Windows 10 Enterprice 21H2

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

vpn: Check Point Endpoint Security

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 7
  • Comments: 17 (4 by maintainers)

Most upvoted comments

I have confirmed the missing stats on a Win11 test machine in the lab. I can see that the stats work on @gunamata’s machine, and even after trying to match all settings in the lab machine, it continued to fail.

I could get stats to work by switching WSL2 to use cgroups v2: Shutdown Rancher Desktop, create a .wslconfig file, make sure WSL2 itself shuts down.

C:\Users\SUSE>type %USERPROFILE%\.wslconfig
[wsl2]
kernelCommandLine=cgroup_no_v1=all
C:\Users\SUSE>wsl --shutdown

When I restart Rancher Desktop now, docker stats shows all the stats.

I have not done any comprehensive testing to see if switching to cgroup v2 is breaking any other functionality.

And for the record, @gunamata’s machine is running cgroup v1 (the default) and stats are still working.

The solution proposed by @jandubois works, and I have been using it without problems. If I find an issue I’ll post it.