How to Install and Setup K3s Kubernetes with IPv6
Posted July 14, 2024
IPv6 is Internet Protocol (IP). It identifies devices on a network and routes traffic across the Internet. IPv4 has limited address space and Internet Protocol version 6 was created. This guide teaches you IPv6 configuration and adds its support to K3s Kubernetes. The guide will focus on Enabling IPv6 in K3s.
Enabling IPv6 in K3s lets your cluster communicate using IPv6 addresses with modern networking environments. You will learn:
- Enabling IPv6.
- K3s Cluster configuration.
- Configururing K3s for Dual Stack (IPv4 and IPv6).
- Verifying K3s IPv6 connectivity.
- Deploying a test app to K3s.
In our previous guide, we discussed Enabling/Disable IP (ipv4) Forwarding On Ubuntu. Lites dive in here and set up IPv6 while using K3s.
Why IPv6 with K3s
IPv6 support in K3s gives:
- A larger address space as IPv6 uses 128-bit addresses and not like IPv4’s 32-bit addresses.
- You get IPv6 header unlike to IPv4.
- IPv6 security is based on IPsec (Internet Protocol Security) in mind.
- You get both stateful and stateless address configurations.
- IPv6 has multicast and anycast included.
- No need for NAT.
Enabling IPv6 for K3s Kubernetes
We now understand the basics of IPv6. We must also ensure IPv6 is enabled. First, ensure you are at the root of your computer with this command:
sudo su -
Go to the machine you intend K3s installed and use the following command to verify IPv6 is Enabled:
sysctl -a | grep ipv6
Check your output and look for net.ipv6.conf.all.disable_ipv6 = 0
that confirms IPv6 is enabled.
If you don’t get this entry, you need to edit /etc/sysctl.conf
and add the following:
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
Apply the changes with the sudo sysctl -p
command.
How to Install K3s with IPv6 Support
The Kubernetes configuration lets you add K3s Network Options. You use Flannel Options. Flannel will give us a layer of 3 network fabrics that Kubernetes uses to create CNI (Container Network Interface)
A default K3s uses ipv4. Now, K3s uses the --flannel-ipv6-masq
CLI Flag to add rules to IPv6. This flag will add IPv6 Flannel and will need to run during the K3s installation process.
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -s - --flannel-ipv6-masq
Run the kubectl command to confirm K3s node is ready:
kubectl get node
Your K3s will henceforth use IPv6.