Use multipass instances to create your k3s cluster
This script will create a configurable amount of instances using multipass, install k3s server(s) (HA using embedded etcd), and add the agent instances to the cluster.
This is tested on MacOS and Ubuntu Linux 22.04.
Clone this repo, and run the script:
bash multipass-k3s.sh
This will (defaults):
NAME
)SERVER_CPU_MACHINE
), 10G disk (SERVER_DISK_MACHINE
) and 1G of memory (SERVER_MEMORY_MACHINE
) using Ubuntu focal (IMAGE
)SERVER_COUNT_MACHINE
)AGENT_COUNT_MACHINE
) with 1 CPU (AGENT_CPU_MACHINE
), 3G disk (AGENT_DISK_MACHINE
) and 512M of memory (AGENT_MEMORY_MACHINE
) using Ubuntu focal (IMAGE
)MERGE_KUBECONFIG
)sudo snap install multipass
wget https://raw.githubusercontent.com/superseb/multipass-k3s/master/multipass-k3s.sh
bash multipass-k3s.sh
curl -Lo /usr/local/bin/kubectl "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x /usr/local/bin/kubectl
kubectl --kubeconfig *-kubeconfig.yaml get nodes
The files that are created are:
$NAME-agent-cloud-init.yaml
$NAME-cloud-init.yaml
$NAME-kubeconfig.yaml
$NAME-kubeconfig-orig.yaml
$NAME-kubeconfig-backup.yaml
(if MERGE_KUBECONFIG
is set)$NAME-kubeconfig-merged.yaml
(if MERGE_KUBECONFIG
is set)You can clean up the instances by running multipass delete k3s-server-$NAME-1 --purge
and multipass delete k3s-agent-$NAME-{1,2,3}
or (WARNING this deletes and purges all instances): multipass delete --all --purge