1

My end goal is to be able to access exposed Kubernetes services running on on my host from another host.

I am doing development in minikube and have tried using an Ingress controller. I am able to get this working on the device itself, as per the directions here Setting up ingress on minikube. However, I want to be able to access my exposed services from a different computer, as in curl http://host.ip:8000, where host.ip is the actual public IP address of the device, not that of the minikube VM or that of an internal network created on the device; and port 8000 is that of the exposed Kubernetes service.

This does not seem like such an odd edge case, so I am surprised I not been able to find any useful information out there on how ****EASILY**** do this.

Here is my local functioning ingress controller, for completeness's sake:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nlp-adapt
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  backend:
    serviceName: default-http-backend
    servicePort: 8000
  rules:
  - host: myminikube.info
    http:
      paths:
      - path: /
        backend:
          serviceName: echoserver
          servicePort: 8080
  - host: test.nlp
    http:
      paths:
      - path: /nlptab
        backend:
          serviceName: nlptab 
          servicePort: 8000
horcle_buzz
  • 175
  • 3
  • 10
  • minikube isn't meant for this. Though I can think of a few circumstances in which it would be helpful. Almost any other Kubernetes deployment would be fine. Of course, you can always port forward from your computer. – Michael Hampton Jul 26 '18 at 18:07
  • Yes, I unfortunately realize this. This is all purely proof of concept at this point. In any case, I *just* found a workable solution, here https://github.com/kubernetes/minikube/issues/877 ... – horcle_buzz Jul 26 '18 at 18:23

1 Answers1

1

Usually, Minikube runs inside a virtual machine. And it is necessary to expose port outside of the virtual machine additionally to exposing it outside of Kubernetes to make an application available on the host IP.

Here is the example:

  1. Expose Ingress outside of Kubernetes:

    kind: Service
    apiVersion: v1
    metadata:
      name: ingress-nginx
    spec:
      type: NodePort
      selector:
        app: ingress-nginx
      ports:
        - port: 80
          nodePort: 31080
          name: http
    
  2. Expose the 31080 port outside the Virtual machine:

    ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L 31080:0.0.0.0:8000
    

After that, the application shared by Ingress will be available on http://host.ip:8000

It is not the only way to expose an application. For example, when using VirtualBox as a hypervisor, you can also use the VirtualBox NAT port forwarding feature to allow access to services exposed through NodePorts from outside. As mentioned in link provided by @horcle_buzz

Artem Golenyaev
  • 253
  • 1
  • 7
  • Hi, yes, I figured this out from github issues link I posted yesterday. However, since you added the detail about the Ingress controller, I have to accept this as THE answer. – horcle_buzz Jul 27 '18 at 15:05