microk8s: The memory cgroup is not enabled.

I appended cgroup_enable=memory cgroup_memory=1 to cmdline.txt file in each node and reboot but it not working.

microk8s inspect

Inspecting Certificates
Inspecting services
  Service snap.microk8s.daemon-cluster-agent is running
  Service snap.microk8s.daemon-containerd is running
  Service snap.microk8s.daemon-apiserver is running
  Service snap.microk8s.daemon-apiserver-kicker is running
  Service snap.microk8s.daemon-proxy is running
  Service snap.microk8s.daemon-kubelet is running
  Service snap.microk8s.daemon-scheduler is running
  Service snap.microk8s.daemon-controller-manager is running
  Copy service arguments to the final report tarball
Inspecting AppArmor configuration
Gathering system information
  Copy processes list to the final report tarball
  Copy snap list to the final report tarball
  Copy VM name (or none) to the final report tarball
  Copy disk usage information to the final report tarball
  Copy memory usage information to the final report tarball
  Copy server uptime to the final report tarball
  Copy current linux distribution to the final report tarball
  Copy openSSL information to the final report tarball
  Copy network configuration to the final report tarball
Inspecting kubernetes cluster
  Inspect kubernetes cluster

WARNING:  The memory cgroup is not enabled. 
The cluster may not be functioning properly. Please ensure cgroups are enabled 
See for example: https://microk8s.io/docs/install-alternatives#heading--arm 
Building the report tarball
  Report tarball is at /var/snap/microk8s/1669/inspection-report-20201027_221452.tar.gz

About this issue

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

Most upvoted comments

GRUB_CMDLINE_LINUX="cgroup_enable=memory cgroup_memory=1 systemd.unified_cgroup_hierarchy=0"

I needed all three of these.

Here is a fix for this in ubuntu 22.04. Open the file /etc/default/grub in an editor. Find where the string GRUB_CMDLINE_LINUX is set. Add cgroup_enable=memory cgroup_memory=1 to that string. Save the file and exit the editor. Then run sudo update-grub. Here is how my grub file looks like:

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="cgroup_enable=memory cgroup_memory=1 swapaccount=1 systemd.unified_cgroup_hierarchy=0"

Then you may restart your computer. Then run microk8s.inspect, everything should be ok. Below is my microk8s version MicroK8s v1.25.2 revision 4055

I’ve been trying to get microk8s 1.21/stable working on Ubuntu 21.10-arm64 on Pi-4 and it seems that perhaps microk8s doesn’t like the new default in Ubuntu 21.10 ( from the release notes )

systemd is being switched to the “unified” cgroup hierarchy (cgroup v2) by default. If for some reason you need to keep the legacy cgroup v1 hierarchy, you can select it via a kernel parameter at boot time: systemd.unified_cgroup_hierarchy=0 (bug 1850667 29)

So - after adding systemd.unified_cgroup_hierarchy=0 the issue with the memory cgroup error, goes away. (don’t forget to rebuild the initramfs! sudo update-initramfs -u )

To see which ( V1 or V2 ) you have configured - stat -c %T -f /sys/fs/cgroup

V1 — tmpfs

V2 — cgroup2fs

If you get errors about iptables or iptables-legacy ( it seems that installing the microk8s snap installs these rules anyway ) these two commands will clear the tables.

sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X sudo iptables-legacy -F && sudo iptables-legacy -t nat -F && sudo iptables-legacy -t mangle -F && sudo iptables-legacy -X

systemd, strikes again.

For anyone installing MicroK8S on Ubuntu 22.04 not raspberry pi here is a link to the steps I took: Microk8s setup on ubuntu 22.04

Problem present on my system as well. Looks like the inspect test is faulty.

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
cat /proc/cgroups
#subsys_name    hierarchy       num_cgroups     enabled
cpuset  0       206     1
cpu     0       206     1
cpuacct 0       206     1
blkio   0       206     1
memory  0       206     1
devices 0       206     1
freezer 0       206     1
net_cls 0       206     1
perf_event      0       206     1
net_prio        0       206     1
hugetlb 0       206     1
pids    0       206     1
rdma    0       206     1
misc    0       206     1
microk8s inspect
<snip>
WARNING:  The memory cgroup is not enabled.
The cluster may not be functioning properly. Please ensure cgroups are enabled
See for example: https://microk8s.io/docs/install-alternatives#heading--arm
cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-5.15.0-41-generic root=UUID=80...16 ro zswap.enabled=1 zswap.compressor=zstd cgroup_enable=memory cgroup_memory=1 cgroup_enable=cpuset
snap list | grep microk8s
microk8s   v1.21.12                          3202   1.21/stable      canonical**         classic
uname -a
Linux muon 5.15.0-41-generic #44-Ubuntu SMP Wed Jun 22 14:20:53 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Have you experienced the same issue on them? Enabling Cgroups should generally work the same way for server-based OSs. Once you have added the following and updated your grub and initramfs. You should be good to go. GRUB_CMDLINE_LINUX="cgroup_enable=memory cgroup_memory=1 systemd.unified_cgroup_hierarchy=0"

What about debian? Or devuan?

This issue has been been fixed by https://github.com/canonical/microk8s/pull/3518.

Same here, amd64 working fine before Ubuntu upgrade, should I try to change cgroups to v1?