没有这样的文件或目录:'/lib/modules/5.2.0/modules.builtin'

没有这样的文件或目录:'/lib/modules/5.2.0/modules.builtin'

我正在尝试使用 Kubespray 安装 Kubernetes 集群。我在脚本运行时收到此错误:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.2.0/modules.builtin'

我使用 Ubuntu 22.04 作为控制平面和工作节点。

你知道我该如何解决这个问题吗?

答案1

好的。我遇到了同样的错误。

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-01] (item=ip_vs) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-02] (item=ip_vs) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-03] (item=ip_vs) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-01] (item=ip_vs_rr) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs_rr", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs_rr", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-03] (item=ip_vs_rr) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs_rr", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs_rr", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-02] (item=ip_vs_rr) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs_rr", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs_rr", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-01] (item=ip_vs_wrr) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs_wrr", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs_wrr", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-03] (item=ip_vs_wrr) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs_wrr", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs_wrr", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-02] (item=ip_vs_wrr) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs_wrr", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs_wrr", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-01] (item=ip_vs_sh) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs_sh", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs_sh", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-03] (item=ip_vs_sh) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs_sh", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs_sh", "params": "", "state": "present"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'
failed: [nl-k8-02] (item=ip_vs_sh) => {"ansible_loop_var": "item", "changed": false, "item": "ip_vs_sh", "msg": "[Errno 2] No such file or directory: '/lib/modules/5.15.0-73-generic/modules.builtin'", "name": "ip_vs_sh", "params": "", "state": "present"}

原因是我尝试通过 kubespray 安装 k8slxd 容器. 这就是为什么 lxd 容器内的文件夹 /lib/modules 当然是空的。

我不清楚你的情况,但是:

  • 如果你尝试在普通的 Linux 主机上安装 K8s,那么文件“modules.builtin”是包“linux-modules-5.2.0-generic”的一部分
  • 如果您尝试在 lxd 容器内安装 k8s,请返回主主机并加载以下内核模块:
    br_netfilter
    ip_vs
    ip_vs_rr
    ip_vs_wrr
    ip_vs_sh
    nf_conntrack

为了确保每次主机启动时都会加载它们,请使用以下命令

# cat /etc/modules-load.d/modules.conf  | grep -v '#'

br_netfilter
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack

#  systemctl restart systemd-modules-load
#  systemctl status  systemd-modules-load

ansible 中产生错误的文件如下:

$kubespray_folder/kubespray/roles/kubernetes/node/tasks/main.yml

希望它能像对我一样有所帮助

相关内容