How to connect to minikube services from outside

9/12/2017

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
kubernetes
minikube

2 Answers

9/12/2017

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

-- Michael Hausenblas
Source: StackOverflow

9/5/2018

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
Source: StackOverflow