3

I've set up a minikube cluster for development purpose inside a VM.
I've deployed few services and an ingress controller (the minikube one) to be able to access it without using NodePorts.
Inside my VM, I can access my services as usual with curl http://hello-world.info or another one. Everything works fine.

But when I'm outside of my VM, I can't access it even if I'm on the same network. I tried from my hosting server, from my laptop and outside with a VPN.
The cluster IP is well listed in my addresses inside the VM (ip a), but not accessible outside of it (e.g: ping xxx).
How can I access my cluster services on another machine inside the same network ?

My VM's IP is set to static (ubuntu-server 20.XX.XX) with netplan at 192.168.1.128 and my cluster IP is 192.168.49.2. My DHCP server is allowed to distribute IPs only between 192.168.1.101-254.

Thanks :).

DataHearth
  • 484
  • 6
  • 20
  • How is the VM connected to the outside world? Does it use NAT? Is it bridged to a real adapter? – Malt Mar 30 '21 at 15:17
  • Don't know if that answer your question, but the VM is using a network bridge (br0) with a virtio-net driver. – DataHearth Mar 30 '21 at 15:29
  • @DataHearth Hello, could you please tell which `--driver` you are using with minikube? Do I assume correctly that is a `virtualbox` driver? – Dawid Kruk Mar 31 '21 at 09:39
  • @DawidKruk I'm using the docker driver :). After some research, the virtualbox driver seems a little less restrictive for me. So I'll maybe give it a try. – DataHearth Apr 01 '21 at 10:06
  • Speaking from my own experience, the easiest way to expose `minikube` to your `LAN` is with either `virtualbox` or `none` driver. There are also other options outside of `minikube` that should be easier. It all depends on your requirements. I've already answered similar question, have you seen them by any chance [1](https://stackoverflow.com/questions/62559281/expose-kubernetes-cluster-to-internet/62697373#62697373), [2](https://stackoverflow.com/questions/66378335/starting-minikube-with-docker-driver-and-bind-it-to-host-network/66419813#66419813) (specifically the part of `--driver=none`)? – Dawid Kruk Apr 02 '21 at 11:17
  • @DawidKruk thanks for the tips. That was my problem in this case. I used the docker driver by default because I wasn’t aware of that « issue ». That’s, in my case, a better option to use the other drivers you listed than docker :). You can post it as an answer . Thanks buddy – DataHearth Apr 03 '21 at 12:44

1 Answers1

3

Personally I haven't found a way to expose minikube instance with --driver=docker on LAN.

As a workaround to expose your minikube instance on LAN you can either --driver:

  • --driver=virtualbox
  • --driver=none

Being specific to the exposing your Kubernetes cluster to LAN, I would also consider checking out other Kubernetes solutions like (you could run them on bare-metal or run them in a vbox vm with bridged networking:


--driver=virtualbox:

Citing part of my own answer some time ago:

As I previously mentioned: When you create your minikube instance with Virtualbox you will create below network interfaces:

  • NAT- interface which will allow your VM to access the Internet. This connection cannot be used to expose your services
  • Host-only-network-adapter - interface created by your host which allows to communicate within the interface. It means that your host and other vm's with this particular adapter could connect with each other. It's designed for internal usage.

You can read more about Virtualbox networking here:

I've managed to find a workaround to allow connections outside your laptop/pc to your minikube instance. You will need to change network interface in settings of your minikube instance from Host-only-network-adapter to Bridged Adapter (2nd adapter). This will work as another device was connected to your physical network. Please make sure that this bridged adapter is used with Ethernet NIC. Minikube should change IP address to match the one used in your physical one.

You will also need to change your .kube/config as it will have the old/wrong IP address!

After that you should be able to connect to your Ingress resource by IP accessible in your physical network.

-- Stackoverflow.com: Answers:: Expose Kubernetes cluster to Internet


--driver=none

You can also run minikube with --driver=none but there are some caveats to this method which you can read more about by following this docs (tl;dr you are running your minikube directly on your host):


Additional resources:

Dawid Kruk
  • 8,982
  • 2
  • 22
  • 45