2022年1月12日 星期三

k8s | memory.swap.max or memory.memsw.limit_in_bytes: no such file or directory error message

建立完K8s cluster後,查看Pods狀態時,發現coredns佈署失敗查看log顯示內容如下所示,由於我用兩個不同Cgroup版本都有遇到所以訊息會不同,錯誤訊息的意思是找不到配置swap的檔案。

Cgroup V1:memory.memsw.limit_in_bytes
Cgroup V2:memory.swap.max

錯誤訊息

Error: container create failed: time="2022-01-10T03:07:53Z" level=error msg="container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: process_linux.go:508: setting cgroup config for procHooks process caused: open /sys/fs/cgroup/memory/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod70ef1923_72cd_4241_acc3_b7072874a827.slice/crio-a8a741c4a6f97ecbb16b852baa01ec8b5927bf3b2f05ef70ce640d72f7063f2b.scope/memory.memsw.limit_in_bytes: no such file or directory"

Error: container create failed: time="2022-01-10T06:09:23Z" level=error msg="container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: process_linux.go:508: setting cgroup config for procHooks process caused: open /sys/fs/cgroup/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7787302f_99d1_4461_aa64_100b4b8a6154.slice/crio-72a7e55c051e87aaf0d6336237137470b3584937fb872ed1ef29b052ed7afeb7.scope/memory.swap.max: no such file or directory"


解決方法


編輯/etc/default/grub加入
如下

GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
更新grub

$ sudo update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-92-generic
Found initrd image: /boot/initrd.img-5.4.0-92-generic
Found linux image: /boot/vmlinuz-5.4.0-91-generic
Found initrd image: /boot/initrd.img-5.4.0-91-generic
done

然後重新開機後應該就可以看到coredns正常啟動了。



沒有留言: