Change Kubernetes network route to internet

1.2k views Asked by At

Do you know how to configure default network route for Kubernetes to reach internet? My cluster nodes (Ubuntu 18.04 with netplan) have 2 IP exposed on internet. When I installed Kubernetes, first IP was the default route, I changed default route to the second IP on system. But pods in Kubernetes continue to use first one to go on internet. Its don't use system configuration. I have Kubernetes 1.17.5 with Canal network deployed with Rancher. I don't find if I should change a configuration or edit iptables of docker0 to tell Kubernetes which route to use.

1

There are 1 answers

1
kool On

You can change default network interface by adding IP address to --apiserver-advertise-address flag in kubeadm init.

The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.

When you join nodes to your cluster make sure you add correct API server IP address

 kubeadm join --apiserver-advertise-address <ip-address-used-in-init> [any additional flags]