Kubernetes internet access with two network interfaces

2/16/2019

I'm new in kubernetes and I have a question about kubernetes network. In my setup each node has two interfaces. the first interface (eth0) is in private range (for example 172.20.12.10) and the second has a public address.

auto eth0 
iface eth0 inet static
    address 172.20.12.10
    netmask 255.255.0.0
    network 172.20.0.0
    broadcast 172.16.255.255
    dns-nameservers 8.8.8.8
auto eth1
iface eth1 inet static
address x.x.x.x
gateway y.y.y.y 

apparently kubernetes network configurations depends on node default gateway so above node network configuration doesn't work correctly.

my question is : how can I access internet in my containers?

-- Milux
containers
kubernetes

1 Answer

2/18/2019

The --apiserver-advertise-address argument for kubeadm init can be used to make k8s use an interface different than the default network interface of the nodes:

--apiserver-advertise-address string
    The IP address the API Server will advertise it's listening on.
    Specify '0.0.0.0' to use the address of the default network interface.

Also, add a flag to /etc/systemd/system/kubelet.service.d/10-kubeadm.conf that specifies the private IP of the worker node:

--node-ip=<private-node-ip>

Finally, when you run kubeadm join on the worker nodes, make sure you provide the private IP of the API server.

More info is in:

-- Vikram Hosakote
Source: StackOverflow