Skip to content

Don't explicitly specify server/agent in k3s install command #808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lhp-nemlig
Copy link
Contributor

The K3S install script will autodetect based on K3S_URL, whether or the node is a server or agent node and insert in the (systemd unit file, or whatever is relevant for your OS) command.

Specifying explicitly runs the risk of having server/agent specified twice in the k3s command which would happen if INSTALL_K3S_EXEC='--flannel-backend=none' was set for that specific server installation.
In that case the K3S install script does not realize that the user has already specified server/agent and will therefore add a duplicate server/agent definition.

Therefore, let the k3s install script handle the detection.

@larssb
Copy link
Contributor

larssb commented May 8, 2025

the script can be found here: https://get.k3s.io/

See:

setup_env() {
    # --- use command args if passed or create default ---
    case "$1" in
        # --- if we only have flags discover if command should be server or agent ---
        (-*|"")
            if [ -z "${K3S_URL}" ]; then
                CMD_K3S=server
            else
                if [ -z "${K3S_TOKEN}" ] && [ -z "${K3S_TOKEN_FILE}" ]; then
                    fatal "Defaulted k3s exec command to 'agent' because K3S_URL is defined, but K3S_TOKEN or K3S_TOKEN_FILE is not defined."
                fi
                CMD_K3S=agent
            fi
        ;;
        # --- command is provided ---
        (*)
            CMD_K3S=$1
            shift
        ;;
    esac

We got issues with this fact ... apparently K3s previously must've ignored more than one server command in its commandline. But, on version 1.32.4 this is more strict ... at least ... having two server commands makes the value to --server be ignored/overlooked and therefore a control-plane node tried introduced to the cluster does NOT try to join the cluster based on the value to the --server parameter.

Thank you @karmab

@karmab
Copy link
Owner

karmab commented May 10, 2025

I dont understand how detection would work in the worker case where both K3S_URL and K3S_TOKEN are set

@lhp-nemlig
Copy link
Contributor Author

@karmab If K3S_URL is not set then it is always assumed to be a "server". If K3S_URL is set then it is always assumed to be an "agent".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants