Create a K3s cluster (standalone or HA)

A lightweight, single-binary Kubernetes. Good for small teams and edge labs, with high availability on embedded etcd or PostgreSQL.

  1. Review the options
  2. Create the cluster
    1. Standalone (one master, optional workers)
    2. High availability
  3. Get the kubeconfig and verify
  4. Add utilities
  5. Tear down
  6. Learn more

Review the options

K3s reads k3sCluster in master.yaml; workers read worker.yaml (version, tlsSANs, nodeLabels, nodeTaints).

./scripts/setup.sh config --list k3s
Option Values
version K3s release, for example v1.36.5+k3s1
cni Flannel (default), Calico, Cilium
loadBalancer ServiceLB, MetalLB (IP pool)
ingress Traefik installed with Helm (the bundled K3s Traefik is disabled): ports, dashboard, Gateway API
highAvailability.dataStorage etcd or postgres (external database)
tlsSANs, nodeLabels, nodeTaints API certificate names, node labels and taints

Create the cluster

Standalone (one master, optional workers)

# master first
./scripts/setup.sh k3s setup --host k8s-master-machine
# then each worker
./scripts/setup.sh k3s setup --host k8s-worker-machine-1

High availability

Fill the HA section of the inventory (ha_master_init, ha_master_join, ha_worker), review k3sCluster.highAvailability in master.yaml, then bootstrap every node at once:

./scripts/setup.sh config edit
./scripts/setup.sh k3s ha-setup

Get the kubeconfig and verify

ssh vagrant@192.168.56.99 'sudo cat /etc/rancher/k3s/k3s.yaml' > ~/.kube/config
# use the master IP (your VPS IP on a VPS)
sed -i "s/127.0.0.1/192.168.56.99/g" ~/.kube/config

kubectl get nodes -o wide
kubectl get pods -A

Add utilities

./scripts/setup.sh k3s utils --list
./scripts/setup.sh k3s utils certmanager gitops ingress_test

See Utilities.

Tear down

# uninstalls K3s from every inventory node
./scripts/setup.sh k3s destroy
./scripts/setup.sh vagrant destroy # when you used VMs

Learn more


Back to top

Kubewekend is a learning and lab project: it is not hardened for production. Charts are served from this site: helm repo add kubewekend https://kubewekend.xeusnguyen.xyz