I installed the Kubernetes (minikube) cluster on Linux Mint. Then I deploy the demo Example: Deploying WordPress and MySQL with Persistent Volumes.
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
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.
How to associate these ip addresses with 178.54.220.175 -> 192.168.1.10 -> 192.168.99.100:30375
If you use a minikube, this feature is disabled.
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.
Something like this (limited range, exposing the entire default NodePort range of 30000-32767 takes forever...):
for port in {30000..30100}; do VBoxManage controlvm minikube natpf1 "NodePort$port,tcp,,$port,,$port"; done
You can combine that with a reverse SSH tunnel to a VPS so anyone can have temporary access from the public internet:
R_ARGS=$(for port in {30000..30100}; do echo -n "-R $port:localhost:$port "; done)
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
To delete the VirtualBox port forward rules:
for port in {30000..30100}; do VBoxManage controlvm minikube natpf1 delete "NodePort$port"; done
The SSH forward method is easier though, and hypervisor agnostic I suppose, so thanks for that!
https://github.com/kubernetes/minikube/issues/877
https://cwienczek.com/reaching-minikube-from-your-machines-public-ip-aka-network-bridge/