14

I am trying to switch my local dev environment to run in minikube. I have all the container images built and I have all the YAML configs and I have all the services I need running and I can access them using the URL returned from minikube service web --url (web is the name of my front facing nginx server). But there is one thing that I have not been able to figure out. The project I am working on requires smart external devices communicating with the backend. I have a few devices sitting on my bench, connected to the local LAN, but I cannot figure out how to expose services running inside minikube to the outside, i.e. so a device can connect to a service using my laptop's external IP. Is there a standard way of doing this?

Edit: I have attempted to configure an ingress for my service. Here is my ingress config.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: web
spec:
  backend:
    serviceName: web
    servicePort: 80

The web service is accessible via minikube service web command and is exposed as type NodePort. All I get is "default backend 404" when I try to access the ingress. On the other hand, even if it did work, I would still have a problem, since ingress is exposing the service on the VM internal subnet and is not accessible from outside of the host machine. I am starting to consider running a proxy or accelerator of some sort to forward things from the host to the minikube vm. Still need to have ingress running to have a persistent endpoint for the proxy.

Mad Wombat
  • 14,490
  • 14
  • 73
  • 109

2 Answers2

4

There are multiple ways. But i found out solution this way.

~ →   $ minikube status
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

Here we can connect with the service using 192.168.99.100 and nodeport. Say for Dashboard with node port 30000 the url will be: http://192.168.99.100:30000/

one can get the service port by using below commands:

~ →   $ kubectl get svc --all-namespaces
Vikash Singh
  • 884
  • 8
  • 11
  • 6
    I asked this question about a year ago, so I don't have the same setup ready. But I don't think your solution works. Minikube runs everything in a VM .So even though the service has NodePort, the port it maps to is on the virtual machine, not the physical machine. Which is exactly what your output says `pointing to minikube-vm at 192.168.99.100`. The minikube VM is not accessible from outside of the machine it runs on. – Mad Wombat Sep 07 '18 at 20:54
2

Use the Minikube Ingress add-on, for example, see this blog post how to set it up and use it.

Michael Hausenblas
  • 13,162
  • 4
  • 52
  • 66
  • 1
    This doesn't _exactly_ do what the poster asked, since (unless someone modified minikube) it will only listen on the virtualbox "hostonly" network, which does exactly what it says: is only accessible to the host. It should certainly be possible to use the virtualbox "bridged" network to have minikube acquire a LAN ip, but it for sure does not do that by default – mdaniel Sep 12 '17 at 16:24
  • You're correct @MatthewLDaniel and maybe it's worth pointing out that one can use for example the solution shown in: https://stackoverflow.com/questions/39850819/kubernetes-minikube-external-ip-does-not-work if access from outside the machine is required. – Michael Hausenblas Sep 12 '17 at 16:49
  • Yes, the connecting device is external to the machine running minikube. – Mad Wombat Sep 12 '17 at 18:26
  • I have been reading up on ingresses. First, all my attempts to follow the kube docs and the medium post have failed. I can access my service using `minikube service` command, but not through the ingress. And as mentioned in the above comments, ingress still runs inside the minikube vm and is still inaccessible from outside the dev system. – Mad Wombat Sep 12 '17 at 21:54
  • @MichaelHausenblas your link points to a question, not an answer. Any idea which of these solution works for accessing ingress from LAN instead of directly from the localhost? – cglacet Feb 08 '22 at 14:54