How to deploy K3S cluster on RancherOS nodes connected via a Zerotier network.
SSH_KEY='ssh-rsa XXX'
REGION='au'
NET_IFACE='zt0' # zerotier interface name.
NETWORK_ID='zerotier-network-id' # zerotier network configured via https://my.zerotier.com
CLUSTER_SECRET='super-secret-cluster-key' # random k3s cluster secret (must be same for all nodes)
I'm deploying via Vultr and using their metadata service to set node details. If you're not using Vultr pls update with equivalent or manually set.
# Vultr metadata service
V4_PRIVATE_IP=`wget -qO- http://169.254.169.254/v1/interfaces/1/ipv4/address`
V4_PUBLIC_IP=`wget -qO- http://169.254.169.254/current/meta-data/public-ipv4`
INSTANCE_ID=`wget -qO- http://169.254.169.254/current/meta-data/instance-id`
HOSTNAME=`wget -qO- http://169.254.169.254/current/meta-data/hostname`
Make master-deploy.sh public available (@ least temporarily ) then update and use a ipxe script bellow to boot rancherOS and install using master-deploy.sh
#!ipxe
# Location of your shell script.
set cloud-config-url http://<url-to-master-deploy.sh>ros-cc-zt-k3s-server.sh
set base-url http://releases.rancher.com/os/latest
kernel ${base-url}/vmlinuz rancher.cloud_init.datasources=[cmdline] cloud-config-url=${cloud-config-url}
initrd ${base-url}/initrd
boot
After a few minuets check your Zerotier network. you will see a new member awaiting auth.
The k3s server and node are stuck in a wait loop until Zerotier interface is initiated and IP available
Helpful tip. If u want to manually control IP address. Set IP before ticking Auth
SSH into your new node, you can find the kubeconfig here /opt/k3s-config/kubeconfig.yaml
You will need to update server: https://0.0.0.0:6443
with your ZeroTier IP or public IP
You should now be able to see the master node when running kubectl get nodes
This time use worker-deploy.sh
follow steps 1 & 2 above.
Make sure you use the same
CLUSTER_SECRET
and setMASTER_IP
to the ZT IP address of the master node.
a few minuets after you authorise the new node in ZT you should see it when running kubectl get nodes