zbeedatm
zbeedatm

Reputation: 679

Access a demo service in remote Kubernetes cluster using ingress

I have a minikube installed on a Linux machine, and I tried following the Deploy Hello World App to get access to the demo service from outside (my browser).

$ kubectl get service web
NAME   TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
web    NodePort   10.103.184.174   <none>        8080:30068/TCP   17h
~$ minikube service web --url
http://192.168.49.2:30068

But when trying to access this url from my browser I'm getting:

Connection timeout. The server at 192.168.49.2 is taking too long to respond.

I tried doing port forwarding (on Linux machine), but it didn't help as well!

~$ kubectl port-forward svc/web 30068:8080

Note:: There is a ping to that ip from inside the linux machine, but no ping from outside.

What am I missing?

Upvotes: 1

Views: 1087

Answers (2)

konglee28
konglee28

Reputation: 51

This what I did to access minikube app remotely from another computer.

  • Remote terminal 1 and keep opening:
minikube tunnel --bind-address='0.0.0.0'
  • Remote terminal 2:
kubectl get all
curl localhost
  • local terminal 1 (create ssh tunnel to remote and also keep it opening)
ssh -L 8000:localhost:80 ssh_user@remote_server
  • Open browser in local to access http://localhost:8000

Upvotes: 0

Matt
Matt

Reputation: 8152

What am I missing?

What you are missing is the basics of networking knowledge. Your minikube is most likely running in a VM. This VM has assigned a virtual net interface with an IP address that is known only to the mentioned linux machine it's running on and no other device in your network is aware of it, and therefore has no idea where to send the packets. Connection timeout suggests that packets get dropped somewhere (most likely on a router but firewall can also be a cause in some cases).

What can you do to solve it?

Try starting minikube with --driver=none, so that minikube doesn't start in a vm and gets direct access to host's network interface an its IP address.

$ minikube start --driver=none

Other solution would be using kubectl port-forward. The way you used it is almost correct. You only forgot one thing: kubectl port-forward by default binds on loopback/localhost. You need to explicitly tell it to bind on all interfaces so that it can be accessed from the outside. Adding --address=0.0.0.0 should do the job, but remember to use ip of the linux machine, not the minikube to access the website.

$ kubectl port-forward svc/web 30068:8080 --address=0.0.0.0
Forwarding from 0.0.0.0:30068 -> 8080

Upvotes: 4

Related Questions