背景
最近闲的没事(并不),寻思搭建一套日常测试用的K8S集群,遂折腾折腾Rancher 。
信心满满地部署Rancher server容器:
sudo docker run --privileged -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:stable
然而容器却没有健康运行。在查看容器log后发现了警告:
[FATAL] k3s exited with: exit status 1
原因
在一顿Google中后终于找到了原因:
issue。大意是说: Debian11系统中Docker默认使用cgroup v2,而k3s只支持cgroup v1,对v2压根不兼容。如果想正常运行,需要手动调整成cgroup v1。
我的操作系统是Ubuntu22.04,而Ubuntu从21.10开始默认使用cgroup v2,同样中招。
issue里一哥们也是直接开喷:
this is stupid, it should be noted in the rancher manual, i wasted 2 day for this shit
the manaul say : "Rancher should work with any modern Linux distribution" well its false thenhow i know that rancher cant work on a fresh debian 11 ( latest ) out of the box ?
works fine after switching to v1
说实话,这确实是挺烦的,纯纯耽误时间。
解决
一句话:改变cgroup v2成 cgroup v1 change cgroup version
步骤
- 在
/etc/default/grub中加入一行
GRUB_CMDLINE_LINUX="systemd.unified_cgroup_hierarchy=0"
- 执行
sudo update-grub - reboot 重启系统
然后执行docker info 就会发现版本改动生效咯