minikube --vm-driver=none when it is on the vms NodePort service can't be accessable from host machine

Created on 11 Nov 2017  路  5Comments  路  Source: kubernetes/minikube

Is this a BUG REPORT or FEATURE REQUEST? (choose one):
BUG REPORT

Please provide the following details:

Environment:

Minikube version (use minikube version):v0.23.0

  • OS (e.g. from /etc/os-release):Debian GNU/Linux 9 (stretch)
  • VM Driver (e.g. cat ~/.minikube/machines/minikube/config.json | grep DriverName):none
  • ISO version (e.g. cat ~/.minikube/machines/minikube/config.json | grep -i ISO or minikube ssh cat /etc/VERSION):

What happened:
minikube ip is always return 127.0.0.1 that NodePort type service can't be accessble from host machine when minikube runs on vms.

What you expected to happen:
when it runs on vms node ip should be routable from host machine

Most helpful comment

I've found that issue is in docker iptables rules. You can add this rule to your vm:

sudo iptables -A DOCKER -j ACCEPT

With this, kubernetes services exposed with NodePort and external ip inside vm becomes available from host machine.

All 5 comments

The none driver is not for running inside VMs. To run a cluster inside a VM, you should let minikube manage the VM lifecycle by using one of the hypervisor drivers (kvm, virtualbox, etc.)

I've found that issue is in docker iptables rules. You can add this rule to your vm:

sudo iptables -A DOCKER -j ACCEPT

With this, kubernetes services exposed with NodePort and external ip inside vm becomes available from host machine.

Better way is to uncomment line net.ipv4.ip_forward=1 in /etc/sysctl.conf and reboot.

That's true, I am resolved previously

sudo iptables -P FORWARD ACCEPT

Another way is to run an ssh tunnel. In my case, I have an http web service with NodePort 30003, and I make it available on port 80 externally by running:

sudo ssh -v -i ~/.ssh/id_rsa -N -L 0.0.0.0:80:localhost:30003 ${USER}@$(hostname)
Was this page helpful?
0 / 5 - 0 ratings