<p>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.</p>

<pre><code>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 
</code></pre>

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

<p>my question is : how can I access internet in my containers?</p>

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

<pre><code>--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.
</code></pre>

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

<pre><code>--node-ip=&lt;private-node-ip&gt;
</code></pre>

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

<p>More info is in:</p>

<ul>
<li><a href="https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/#using-internal-ips-in-your-cluster" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/#using-internal-ips-in-your-cluster</a></li>
<li><a href="https://github.com/kubernetes/kubernetes/issues/33618#issuecomment-250082421" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/33618#issuecomment-250082421</a></li>
</ul>
