If you initially created k3s cluster with one node and later want to scale it out to three nodes (since three is minimum size for quorum), operation itself is supposed to be simple operation, where you …

  • start using etcd (instead of embedded SQLite)
  • copy secret token from /var/lib/rancher/k3s/server/token on your existing node
  • open firewall on existing node for ports 2379/tcp, 2380/tcp, 6443/tcp and 10250/tcp (if you haven’t done it previously)

Once above steps have been done to cluster, write /etc/rancher/k3s/configuration.yaml into your new node and install local binaries with curl -sfL https://get.k3s.io | sh - (if you haven’t saved the installation file from your original instllation). Once that is done without error messages, your new node should show up with kubectl get nodes -o wide.

At least on my homelab, I managed to stumble on some extra steps, which I’ve described below.

Initial steps Link to heading

Start using etcd Link to heading

If your k3s cluster information is stored into sqlite instead of etcd, we have change configuratino so that all nodes are uptodate with configuration. Operation is surprising simple.

sudo systemctl stop k3s
# add following lines into your /etc/rancker/k3s/config.yaml if it doesn't already have them
# cluster-init: true
# etcd-snapshot-schedule-cron: "0 */6 * * *"
# etcd-snapshot-retention: 20
sudo systemctl start k3s

configuration.yaml for new node Link to heading

Once you have the token from existing cluster node, you can create /etc/rancher/k3s/configuration.yaml to your new node:

server: https://192.168.1.14:6443
token: "YOUR_NODE_TOKEN"

disable:
# and whatever things you've disabled. I originally had just traefik here

What else can go wrong? Link to heading

Right version of k3s Link to heading

By default, k3s installation script will install latest version of k3s, but when you add new node to your cluster, it should run same version with other nodes in your cluster. You can find your current version with k3s --version and instead of curl-sh, do something like INSTALL_K3S_VERSION="v1.36.4+k3s1" sh k3s_install.sh (assuming you saved the curled installation script into k3s_install.sh).

If you accidentally installed wrong version, easiest solution to fix situation is to uninstall k3s (/usr/local/bin/k3s-uninstall.sh) on new node and redo installation.

Memory cgroup Link to heading

If your new node is Raspberry Pi, your installation script might print:

[INFO] Failed to find memory cgroup, you may need to add “cgroup_memory=1 cgroup_enable=memory” to your linux cmdline (/boot/firmware/cmdline.txt on a Raspberry Pi)

At least on my Raspberry Pi, it really was simple as that. Just make sure that cmdline.txt has all the text on single line and reboot.

Longhorn Link to heading

If you are using longhorn in your k3s as service that providers persistent storage for pods, all your k3s nodes are going to require support for iscsi.

  • on Fedora, install iscsi-initiator-utils
  • on Debian, install open-iscsi

and systemctl enable --now iscsid.

Make sure that firewall allows port range 8000-8003 and 8472/udp traffic between nodes. I also defined into my nodes /etc/NetworkManager/conf.d/k3s.conf file that cni0 and flannel.1 are unmanaged devices.

Once these operations were done, longhorn started successfully, but new nodes were flipping between healthy and down in rapid fashion. I eventually had to upgrade longhorn from v1.11.3 to v1.12.2 to resolve issue.

Pihole Link to heading

My pihole configmap had deprecated DNSMASQ_LISTENING setting in it, which had to be replaced with FTLCONF_dns_listeningMode: ALL

I also had to edit /etc/pihole/pihole.toml file to fix incorrect information that I had in pihole configuration (kubectl exec vi /etc/pihole/pihole.toml) so that I was once again able to log into pihole’s web UI.

Services that use k3s as reverse proxy Link to heading

If you are using k3s as reverse proxy for HomeAssistant or other services, you might have to add all your k3s nodes IP addresses as well as the CIDRs of your k3s overlay networks (10.42.0.0/16 and 10.43.0.0/16), you have to add those to your services configurations.

sysctl settings to new nodes Link to heading

You might want to setup same sysctl setting into your new nodes that you have in your first node. On my particular inotify settings where the first ones where I managed to hit default limits, so I raised them by putting following settings into /etc/sysctl.d/99-k3s.conf:

fs.inotify.max_user_instances = 1024
fs.inotify.max_user_watches = 1048576

When your k3s cluster is just one node and it is attach on ethernet cable things are simple. On my cluster I stumbled on two issues: k3s servicelb vs. metallb and ARP addresses.

K3S ServiceLB and MetalLB where interfering each others, which caused issues on whose managing IP address ranges. At the end, I disabled K3S ServiceLB by adding it into list of disabled services as servicelb in all nodes /etc/rancher/3ks/configuration.yaml after which I had to restart k3s. Thankfully you can do it node by node and if you pause between them, your cluster can remain healthy through the whole process.

With ARP the problem was that my new node that was on WiFi (instead of ethernet cable) failed to advertise VIP. At the end I made following configutation into L2Advertisement:

spec:
  nodeSelectors:
    - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
            - raspberry
            - prodesk