Getting Started
K3s Homelab
Getting Started
This guild will help you build a five node, dual stack (ipv4 + ipv6) k3s cluster. The cluster will be configured with external load balancing.
This cluster will be built to be accessible from the outside world, completely over ipv6. This means that you can access your cluster from anywhere in the world, without the need for a VPN or port forwarding.
I am using ipv6 because my ISP provides me with a dynamic public ipv6 address, but no public ipv4 address.
This guide will assume these IPs and hostnames for the nodes.
- Master Nodes
- Worker Nodes
- Load Balancer Nodes
The load balancers will use
192.168.1.125as the virtual IP address that will be used to access the cluster.I’ll use debian-13 for all nodes.
Preparing Load Balancers
On
kube-lb-01,kube-lb-02, andkube-lb-03installhaproxyandkeepalivedpackages.Add these two files on
kube-lb-01,kube-lb-02, andkube-lb-03.
- Edit the
haproxy.cfgfile to point to the correct IP addresses of your master nodes. Thekeepalived.conffile should also be edited to point to the correct network interface and virtual IP address.
- Enable and start
haproxyandkeepalived
Installing k3s on master nodes
Generate a random token on
kube-01that will be used to join the other master nodes to the cluster.Install k3s on
kube-01with the--cluster-initflag and the token generated in the previous step.- The
--tls-sanflag is used to add the virtual IP address to the TLS certificate. This is necessary because we will be accessing the cluster using the virtual IP address.
- The
Get the full k3s token and store it somewhere. You will need this token to join the other master nodes and worker nodes to the cluster.
Install k3s on
kube-02andkube-03using the token in step 3 and the--serverflag pointing to the ip address ofkube-01.
Installing k3s on worker nodes
- Install k3s on
kube-04andkube-05using the token in step 3 and the--serverflag pointing to the virtual IP address of the load balancers.