<p>I have multiple k8s cluster in private network which I can access only through a jumpbox/bastion host.</p>
<p>For example below are my k8s clusters:</p>
<p>k8s-c3 with endpoint ip 192.168.220.3</p>
<p>k8s-c4 with endpoint ip 192.168.220.4</p>
<p>k8s-c5 with endpoint ip 192.168.220.5</p>
<p>What I have been able to do is:
Create a ssh tunnel to 1 endpoint at a time eg:  <code>ssh -i /root/.ssh/id_rsa -4 -fNT -L 6443:192.168.220.3:6443 user@1.2.3.4</code> and use kubectl command from my local machine.</p>
<p>What I want to do is:
Create a ssh tunnel to my bastion host for port 6443 for all the 3 destinations mentioned above and use kubectl config use-context to switch and connect to different clusters from my local machine.</p>
<p>Is this possible? If so how?
If not possible using ssh what other alternatives do I have? Would really appreciate sample code example.</p>
<p>Thanks</p>

Ali Nahid
<p>The ssh tunnel allows to open more than one tunnel in the same command, to multiple machines.
The gotcha here  is that you would have to use different ports, and change in the kubectl config file the ports you are tunneling.</p>
<p>The command would have multiple <code>-L</code>:</p>
<pre><code>-L 6443:192.168.220.3:6443 -L 6444:192.168.220.4:6443 -L 6445:192.168.220.5:6443
</code></pre>
<p>And each <code>cluster</code> entry in the <code>.kube/config</code> file should have the server with the correct port (6443, 6444 or 6445).</p>
<p>I'm sorry that I cannot test this right now, but in theory, that's how I would do.</p>
