<p>Recently I decided to set up a k8s cluster on a few VM's.<br />
I worked with K8s in the past but it's a long time since.<br />
One of the things I want to run in the cluster is a web server with Nginx.</p>
<p>I have 3 VM's 1 master, 2 workers. They have each an external and internal IP.</p>
<p>I was wondering how I should set up k8s.<br />
So I would want to use the external IP as my cluster IP but the nodes should communicate with the internal network.</p>
<p>How do I need to configure this?<br />
I guess I need one of these options of the <code>kubeadm init</code> command but I am not sure?</p>
<pre><code>--control-plane-endpoint
--apiserver-advertise-addres
</code></pre>
<p>If Someone could explain with an example that would be great!</p>

Bram Breda
<p>I hope i understood you correctly, if not please update me.</p>
<blockquote>
<p>So I would want to use the external IP as my cluster IP but the nodes should communicate with the internal network.</p>
</blockquote>
<p>First of all your external IP need to be</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
....
type: LoadBalancer
</code></pre>
<blockquote>
<p>but the nodes should communicate with the internal network</p>
</blockquote>
<p>For this purpose, you should use <code>StaefulSet</code> instead of deployment.</p>
<p>The main difference from your perspective (in order to answer your question) is the <code>StatefulSet</code> attaches a unique FQDN to your pod and this address is guaranteed to be &quot;attached&quot; to the pod when you reschedule it.</p>
<p>So you should have something like this:</p>
<ul>
<li>nginx - Exposed via LoadBalancer (external IP)</li>
<li>apps  - StatefulSet apps that have a unique IP and the Nginx can communicate with them using this IP.</li>
</ul>
<hr />
<p><a href="https://i.stack.imgur.com/NrVGy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NrVGy.png" alt="enter image description here" /></a></p>
