问题描述
我正在尝试将LXC容器(debian)设置为Kubernetes节点。 到目前为止,唯一的障碍是kubeadm初始化脚本...
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR SystemVerification]: failed to parse kernel config: unable to load kernel module: "configs",output: "modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.4.44-2-pve/modules.dep.bin'\nmodprobe: FATAL: Module configs not found in directory /lib/modules/5.4.44-2-pve\n",err: exit status 1
[preflight] If you know what you are doing,you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
经过研究,我发现我可能需要添加以下内容:linux.kernel_modules: ip_tables,ip6_tables,netlink_diag,nf_nat,overlay
但是,将其添加到/etc/pve/lxc/107.conf
不会执行任何操作。
有人知道如何添加linux内核模块吗?
解决方法
我不确定您要遵循的指南是什么,但是假设主机上具有必需的内核模块,则可以这样做:
lxc config set my-container linux.kernel_modules overlay
您也可以关注this guide from K3s。基本上:
lxc config edit k3s-lxc
和
config:
linux.kernel_modules: ip_tables,ip6_tables,netlink_diag,nf_nat,overlay
raw.lxc: lxc.mount.auto=proc:rw sys:rw
security.privileged: "true"
security.nesting: "true"
✌️
,要允许使用 modprobe 加载特权 proxmox lxc 容器内的任何模块,您需要将此选项添加到容器配置中:
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop:
lxc.mount.auto: proc:rw sys:rw
lxc.mount.entry: /lib/modules lib/modules none bind 0 0
在此之前,您必须先在容器内创建 /lib/modules 文件夹
,对于从主机运行的修复 ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file
:
pct set $VMID --mp0 /usr/lib/modules/$(uname -r),mp=/lib/modules/$(uname -r),ro=1,backup=0
对于从主机运行的修复 [ERROR SystemVerification]: failed to parse kernel config
:
pct push $VMID /boot/config-$(uname -r) /boot/config-$(uname -r)
其中 $VMID
是您的容器 ID。