K3s — IPv6 Only configuration
Hey, I have recently been working on setting up K3s cluster with IPv6 only configuration since following some requirements for a project. I just wanted to share or keep here my configuration of how I configure my K3s cluster that used only IPv6 for the master node, worker node and for the pod deployment.
I think it is better for me to start with how to custom K3s installation, from the documentation, there are few options that can be used to custom the installation and configuration. But for me, I think this is the easiest way to custom it. I defined the value that I wanted to send directly inside the “INSTALL_K3S_EXEC=” parameter. For example below I directly instruct the installation to configure IPv6 only by not defining IPv4 in the node IP, Cluster IP and Service IP.
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --node-ip 2001:BBB:111:111::1 --cluster-cidr 2001:cafe:42:0::/56 --service-cidr 2001:cafe:43:1::/112" sh -s -
So for the above configuration, the thing that you will need to modify is the --node-ip — “2001:bbb:111:111::1” which is the real IPv6 address for your server/instance. So you need to change it with your own IPv6 address. For the cluster and service cidr, you either can use and follow as mine or you can just modify as you like. Then, just wait for the installation to complete and you are good to go. That’s really easy.
Also for the worker node, and you wanted to ensure it is using only IPv6 below is the command you can used;
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="agent --server=https://[2001:BBB:111:111::1]:6443/ --node-ip 2001:CCC:222:222::1 --token=<your token>" sh -s -
You should notice that “INSTALL_K3S_EXEC=agent” instead of “INSTALL_K3S_EXEC=server”, since this is to be setup as workder node. Then for the configuration, you need to update is the address to your master node IP/address, as above my master IPv6 is “2001:BBB:111:111::1”, then i put as “https://[2001:BBB:111:111::1]:6443/”, i believe that if you configure AAA record for your domain, you can also use domain instead of IP for example “--server=https://k3s.mydomain.com:6443”. Nex for the --node-ip you need to update the IP into that server/instance IPv6 address as for me it is “2001:CCC:222:222::1”, you actually can get the IP by running the “ip addr” or “ifconfig” inside your server/instance. For the token, you need to get the token from your master node. The token can be found inside the master node under the file;
/var/lib/rancher/k3s/server/node-token
You can easily just use “cat /var/lib/rancher/k3s/server/node-token” to get the token and update the command. Normally the token would look like this
K1026cc50c14d04b4b7393f989846b4969e86527888e7c8879c031aa3da11466c8b
as basically the full command for the worker node installation would look like this;
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="agent --server=https://[2001:BBB:111:111::1]:6443/ --node-ip 2001:CCC:222:222::1 --token= K1026cc50c14d04b4b7393f989846b4969e86527888e7c8879c031aa3da11466c8b" sh -s -
So yes, more or less, that is, how you configure both master and worker node using K3s with IPv6 only configuration. Just add-ons below to illustrate how to verify your configuration.
Verify the node using the kubectl get nodes -o wide
command
Verify the pod created are using IPv6 address by using command kubectl get pod -A -o wide
it will return all the pod and shows the IP address as below.
GLHF, i hope this could help others who working with K3s and IPv6.
Notes: I have modified all the Node IP to the fake IP for privacy since it is actually public IP.