<p>I installed the Kubernetes (minikube) cluster on Linux Mint. Then I deploy the demo <a href="https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/" rel="nofollow noreferrer">Example: Deploying WordPress and MySQL with Persistent Volumes</a>.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: wordpress
labels:
  app: wordpress
spec:
  ports:
    - port: 80
      nodePort: 30375
  selector:
    app: wordpress
    tier: frontend
  type: NodePort
  externalIPs:
    - 178.54.220.175
    - 192.168.1.10
</code></pre>

<p>How to access the Kubernetes service from the Internet if the external ip 178.54.220.175 is only in the router, host ip with Linux 192.168.1.10 and ip Kubernetes 192.168.99.100:30375.</p>

<p>How to associate these ip addresses with 178.54.220.175 -> 192.168.1.10 -> 192.168.99.100:30375</p>

Compozitor
<p>If you use a minikube, this feature is disabled.</p>

<p>When using VirtualBox as hypervisor, you can also use the VirtualBox NAT port forwarding feature to allow access to services exposed through NodePorts from outside.</p>

<p>Something like this (limited range, exposing the entire default NodePort range of 30000-32767 takes forever...):</p>

<pre><code>for port in {30000..30100}; do VBoxManage controlvm minikube natpf1 "NodePort$port,tcp,,$port,,$port"; done
</code></pre>

<p>You can combine that with a reverse SSH tunnel to a VPS so anyone can have temporary access from the public internet:</p>

<pre><code>R_ARGS=$(for port in {30000..30100}; do echo -n "-R $port:localhost:$port "; done)
</code></pre>

<hr>

<pre><code>autossh -M 0 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -o ServerAliveInterval=5 -o ServerAliveCountMax=3 user@examplevps.com -N $R_ARGS
</code></pre>

<p>To delete the VirtualBox port forward rules:</p>

<pre><code>for port in {30000..30100}; do VBoxManage controlvm minikube natpf1 delete "NodePort$port"; done
</code></pre>

<p>The SSH forward method is easier though, and hypervisor agnostic I suppose, so thanks for that!</p>

<p><a href="https://github.com/kubernetes/minikube/issues/877" rel="nofollow noreferrer">https://github.com/kubernetes/minikube/issues/877</a></p>

<p><a href="https://cwienczek.com/reaching-minikube-from-your-machines-public-ip-aka-network-bridge/" rel="nofollow noreferrer">https://cwienczek.com/reaching-minikube-from-your-machines-public-ip-aka-network-bridge/</a></p>
