Skip to content

Install k3s

Documentation Here

Control (Master) Node

Simple k3s single control/worker node

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

To work without sudo

Bash
sudo chown $USER. /etc/rancher/k3s/k3s.yaml

Standard Install

Bash
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--write-kubeconfig-mode=644" sh -s -

Note

    Will take all available IPs, but you can still use metallb

Without Traefik Ingress

Bash
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik" sh -s -

Without traefik and add kube config to be executable for user

Bash
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik --write-kubeconfig-mode=644" sh -s -

More install options

Server token

  • On the control node
Bash
sudo cat /var/lib/rancher/k3s/server/node-token

Install agent node (worker)

Bash
curl -sfL https://get.k3s.io | K3S_URL=https://master_IP_or_DNS:6443 K3S_TOKEN="KXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx::server:xxxxxxxxxxxxxxxxxxx" sh -

Uninstall

  • Master node
Bash
/usr/local/bin/k3s-uninstall.sh

Adding multiple master nodes | embedded etcd

  • Fist node must have --cluster-init in install command:

Optional:

--tls-san value (listener) Add additional hostname or IP as a Subject Alternative Name in the TLS cert

Bash
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik --write-kubeconfig-mode=644" sh -s - server  --cluster-init --tls-san=172.30.177.100
  • Second (and/or third...) master node:
Bash
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik --write-kubeconfig-mode=644" K3S_TOKEN="K102ee243c13888698548f1feb38ab9182ae184d414ecf40ed499f24b3dbb9884c8::server:b78223bfd649aee6a700156d09b21991" sh -s - server \
--server https://dev-master1.kafana.dev:6443 --tls-san=172.30.177.100
  • Add agent
Bash
curl -sfL https://get.k3s.io | K3S_TOKEN="K102ee243c13888698548f1feb38ab9182ae184d414ecf40ed499f24b3dbb9884c8::server:b78223bfd649aee6a700156d09b21991" sh -s - agent --server https://dev-master1.kafana.dev:6443