为什么 k3s 安装失败?k3s.service 的作业失败,因为控制进程退出并显示错误代码

为什么 k3s 安装失败?k3s.service 的作业失败,因为控制进程退出并显示错误代码

我在 Ubuntu 22.04 上安装了 k3s

curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --flannel-backend none" K3S_TOKEN=prokupljejbb sh -s -

[INFO]  Installing k3s to /usr/local/bin/k3s
[INFO]  Skipping installation of SELinux RPM
[INFO]  Skipping /usr/local/bin/kubectl symlink to k3s, already exists
[INFO]  Skipping /usr/local/bin/crictl symlink to k3s, already exists
[INFO]  Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
[INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
[INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO]  env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO]  systemd: Creating service file /etc/systemd/system/k3s.service
[INFO]  systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO]  No change detected so skipping service start

地位

systemctl status k3s
● k3s.service - Lightweight Kubernetes
     Loaded: loaded (/etc/systemd/system/k3s.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2023-04-28 12:48:49 CEST; 1s ago
       Docs: https://k3s.io
    Process: 77789 ExecStartPre=/bin/sh -xc ! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service (code=>
    Process: 77791 ExecStartPre=/sbin/modprobe br_netfilter (code=exited, status=0/SUCCESS)
    Process: 77792 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
    Process: 77793 ExecStart=/usr/local/bin/k3s server --flannel-backend none (code=exited, status=203/EXEC)
   Main PID: 77793 

我尝试开始

systemctl start k3s
Job for k3s.service failed because the control process exited with error code.
See "systemctl status k3s.service" and "journalctl -xeu k3s.service" for details.

ls -laZ /usr/local/bin/k3s
total 65716
drwxr-xr-x 2 root root ?     4096 апр 28 12:47 .
drwxr-xr-x 3 root root ?     4096 апр 28 12:47 ..
-rwxr-xr-x 1 root root ? 67284992 апр 28 12:47 k3s.bin

status=203/EXEC指向什么?

我删除了符号链接并删除了目录

[INFO]  Creating /usr/local/bin/kubectl symlink to k3s
[INFO]  Creating /usr/local/bin/crictl symlink to k3s
[INFO]  Creating /usr/local/bin/ctr symlink to k3s
[INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
[INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO]  env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO]  systemd: Creating service file /etc/systemd/system/k3s.service
[INFO]  systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO]  No change detected so skipping service start

我现在得到 0

   Process: 97794 ExecStartPre=/bin/sh -xc ! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service (code=>
    Process: 97796 ExecStartPre=/sbin/modprobe br_netfilter (code=exited, status=0/SUCCESS)
    Process: 97797 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
    Process: 97798 ExecStart=/usr/local/bin/k3s server --flannel-backend none (code=exited, status=1/FAILURE)
   Main PID: 97798 (code=exited, status=1/FAILURE)

输出日志控制

The process' exit code is 'exited' and its exit status is 1.
апр 28 13:31:32 miki-IdeaPad systemd[1]: k3s.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit k3s.service has entered the 'failed' state with result 'exit-code'.
апр 28 13:31:32 miki-IdeaPad systemd[1]: Failed to start Lightweight Kubernetes.
░░ Subject: A start job for unit k3s.service has failed
░░ Defined-By: systemd

为什么?

答案1

EXEC 结果表示指定的路径无法作为进程执行,例如因为它不存在或者由于权限或类似原因。(通常系统日志 – 例如journalctl– 会显示更精确的原因。)

事实上,指定的路径/usr/local/bin/k3s不是一个可执行文件,甚至不是一个文件——根据你的“ls”输出,它是一个目录。安装脚本没有检查这种可能性,只是将下载的可执行文件转储到目录中。

删除整个“k3s”目录,还删除脚本提到的符号链接(“kubectl”、“crictl”和“ctr”),然后重新运行安装脚本。

相关内容