Throughout the K3s documentation, you will see some options that can be passed in as both command flags and environment variables. The below examples show how these options can be passed in both ways.


The option to allow writing to the kubeconfig file is useful for allowing a K3s cluster to be imported into Rancher. Below are two ways to pass in the option.

Using the flag --write-kubeconfig-mode 644:

$ curl -sfL | sh -s - --write-kubeconfig-mode 644

Using the environment variable K3S_KUBECONFIG_MODE:

$ curl -sfL | K3S_KUBECONFIG_MODE="644" sh -s -


If this command is not specified as a server or agent command, it will default to “agent” if K3S_URL is set, or “server” if it is not set.

The final systemd command resolves to a combination of this environment variable and script args. To illustrate this, the following commands result in the same behavior of registering a server without flannel:

curl -sfL | INSTALL_K3S_EXEC="--no-flannel" sh -s -
curl -sfL | INSTALL_K3S_EXEC="server --no-flannel" sh -s -
curl -sfL | INSTALL_K3S_EXEC="server" sh -s - --no-flannel
curl -sfL | sh -s - server --no-flannel
curl -sfL | sh -s - --no-flannel