k3s-io / k3s

Lightweight Kubernetes
https://k3s.io
Apache License 2.0
27.66k stars 2.32k forks source link

k3s.service from install script is wrong? #6274

Closed stratus-ss closed 1 year ago

stratus-ss commented 1 year ago

Environmental Info: K3s Version:

k3s -v
k3s version v1.24.6+k3s1 (a8e0c66d)
go version go1.18.6

Node(s) CPU architecture, OS, and Version:

Single node on an AMD EPYC cpu (x86_64)

CentOS Stream 9

uname -a
Linux bastion.stratus.lab 5.14.0-171.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Oct 1 12:56:27 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Cluster Configuration:

Single Node install with the script in the quick start

Describe the bug:

Running the script does not allow the k3s to start. It appears to be a problem with the service file.

Steps To Reproduce:

No customizations have been done. Simply curl the script in the on the quick-start page.

Expected behavior:

Cluster initializes and the service starts

Actual behavior:

During the script running the following output is observed:

[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]  systemd: Starting 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.

Investigating the logs I see the following:

Oct 14 13:29:18 bastion.stratus.lab sh[37322]: + /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service
Oct 14 13:29:18 bastion.stratus.lab sh[37323]: Failed to get unit file state for nm-cloud-setup.service: No such file or directory
Oct 14 13:29:18 bastion.stratus.lab k3s[37326]: Incorrect Usage: flag provided but not defined: -hg

The service file has the following content:

[Unit]
Description=Lightweight Kubernetes
Documentation=https://k3s.io
Wants=network-online.target
After=network-online.target

[Install]
WantedBy=multi-user.target

[Service]
Type=notify
EnvironmentFile=-/etc/default/%N
EnvironmentFile=-/etc/sysconfig/%N
EnvironmentFile=-/etc/systemd/system/k3s.service.env
KillMode=process
Delegate=yes
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Restart=always
RestartSec=5s
ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service'
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s \
    server \
    '-hg' \

When I investigate the the help on the binary, i am unable to determine what -hg is supposed to do. When I look at the github page the k3s.service file looks different from the one that the script installed

brandond commented 1 year ago

Any extra args that you provide to the shell command when running the installer will be appended to the K3s command in the systemd unit. Did you perhaps happen to run something like:

curl -sfL https://get.k3s.io | sh - -hg