Environment Variables
As mentioned in the Quick-Start Guide, you can use the installation script available at https://get.k3s.io to install K3s as a service on systemd and openrc based systems.
The simplest form of this command is as follows:
curl -sfL https://get.k3s.io | sh -
When using this method to install K3s, the following environment variables can be used to configure the installation:
Environment Variable | Description |
---|---|
|
If set to true will not download K3s hash or binary. |
|
By default will create symlinks for the kubectl, crictl, and ctr binaries if the commands do not already exist in path. If set to 'skip' will not create symlinks and 'force' will overwrite. |
|
If set to true will not enable or start K3s service. |
|
If set to true will not start K3s service. |
|
Version of K3s to download from Github. Will attempt to download from the stable channel if not specified. |
|
Directory to install K3s binary, links, and uninstall script to, or use |
|
If set to true will not write files to |
|
Directory to install systemd service and environment files to, or use |
|
Command with flags to use for launching K3s in the service. If the command is not specified, and the |
|
Name of systemd service to create, will default to 'k3s' if running k3s as a server and 'k3s-agent' if running k3s as an agent. If specified the name will be prefixed with 'k3s-'. |
|
Type of systemd service to create, will default from the K3s exec command if not specified. |
|
If set to true will continue if k3s-selinux policy is not found. |
|
If set to true will skip automatic installation of the k3s RPM. |
|
Channel URL for fetching K3s download URL. Defaults to https://update.k3s.io/v1-release/channels. |
|
Channel to use for fetching K3s download URL. Defaults to "stable". Options include: |
This example shows where to place aforementioned environment variables as options (after the pipe):
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL=latest sh -
Environment variables which begin with K3S_
will be preserved for the systemd and openrc services to use.
Setting K3S_URL
without explicitly setting an exec command will default the command to "agent".
When running the agent, K3S_TOKEN
must also be set.
Version Gate
Available as of October 2024 releases: v1.28.15+k3s1, v1.29.10+k3s1, v1.30.6+k3s1, v1.31.2+k3s1. |
K3s will now use PATH
to find alternative container runtimes, in addition to checking the default paths used by the container runtime packages. In order to use this feature, you must modify the K3s service’s PATH environment variable to add the directories containing the container runtime binaries.
It’s recommended that you modify one of this two environment files:
-
/etc/default/k3s # or k3s-agent
-
/etc/sysconfig/k3s # or k3s-agent
This example will add the PATH
in /etc/default/k3s
:
echo PATH=$PATH >> /etc/default/k3s
|