How to bind flannel to different iface
1 min read
This is a short post on how to install k3s cluster with flannel binded to a different interface. This is useful when you have multiple network interfaces and you want to bind flannel to a specific one.
Master node install
- Change to root user
sudo -i
- Declare variables (it’s more readable than using the command directly)
export K3S_NODE_NAME=[node-name]export K3S_EXTERNAL_IP=[node-ip]
# change kubeconfig permissionexport K3S_KUBECONFIG_MODE=644
# install and specify desired interfacecurl -sfL https://get.k3s.io | sh -s - --flannel-iface=[interface-name]
# check statussystemctl status k3s
# print kubernetes tokencat /var/lib/rancher/k3s/server/node-token
-
Copy the token for the worker nodes
-
Copy the kubeconfig
less /etc/rancher/k3s/k3s.yaml
- Exit root user
exit
- Create a folder called
.kube
in your home directory and create a file calledkubeconfig
inside it
mkdir -p $HOME/.kube
touch $HOME/.kube/kubeconfig
-
Edit the file and paste the kubeconfig content
-
Edit this line and enter correct ip address:
server: https://[master-ip]:6443
Worker node Install
- Change to root user
sudo -i
- Declare variables (it’s more readable than using the command directly)
export K3S_NODE_NAME=[node-name]# change kubeconfig permissionexport K3S_KUBECONFIG_MODE="644"export K3S_EXTERNAL_IP=[node-ip]
export K3S_URL="https://[ip-of-master-node]:6443"export K3S_TOKEN=[copied-token]
# install and specify desired interfacecurl -sfL https://get.k3s.io | sh -s - --flannel-iface=[interface-name]
# check statussystemctl status k3s-agent
--flannel-iface=[interface-name]
is the flag that binds flannel to the specified interface.