<p>I created a Kubernetes Cluster using kubadm and the private IP of the server so all the nodes could reach it withing the cloudprovider network. I am using 4 nodes in DigitalOcean. </p>

<pre><code>kubctl-s-2vcpu-4gb-nyc3-01-master:~# kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://10.132.113.68:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
</code></pre>

<p>The command I used to initialize the cluster is:</p>

<pre><code>kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.132.113.68 --kubernetes-version stable-1.8
</code></pre>

<p>I am trying to connect to this cluster using kubectl from my local computer. The admin.conf file has the private IP:</p>

<pre><code>apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS********S0tLQo=
    server: https://10.132.113.68:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
</code></pre>

<p>I have tried setting up the proxy in the master <code>kubectl proxy</code> and making an SSH tunnel to the server:</p>

<pre><code>ssh -L 8001:127.0.0.1:8001 -N -i test.pem root@104.236.XX.209
</code></pre>

<p>I can login into the Kubernetes Dashboard from my computer, but can't execute <code>kubectl</code> commands:</p>

<pre><code>$kubectl -s localhost:8001 get nodes
Unable to connect to the server: read tcp 127.0.0.1:62394-&gt;127.0.0.1:8001: read: connection reset by peer
</code></pre>

<p>Where <code>ssh -L ... </code> ends, <code>sshuttle</code> starts :): it creates local tcp &quot;catch-all&quot; DNATing via the ssh dest node, ie will forward <strong>every</strong> tcp connection in the specified <em>CIDR</em>.</p>
<p>Try it out:</p>
<ul>
<li><p>In one terminal (to ease later ^C):</p>
<p><code>sshuttle -e 'ssh -vi test.pem' -r root@104.236.XX.209 10.132.113.68/32</code></p>
</li>
<li><p>From other terminal, just do the <code>kubectl ...</code> as you would do if locally run from your initial <code>kubeadm</code> node.</p>
</li>
<li><p>Profit :)</p>
</li>
</ul>
<p>--jjo</p>
