Exposed service not accessible on minikube

8/28/2018

I just started kubernetes with help of minikube in windows10 machine+Hyper V. deployed and exposed nginx container as followed but could not access the deployed application through minikube ip or inside the minikube server.

            C:\WINDOWS\system32>kubectl run nginx --image=nginx --port=8090
            deployment "nginx" created

            C:\WINDOWS\system32>kubectl expose deployment nginx --type="NodePort"
            service "nginx" exposed

            C:\WINDOWS\system32>minikube service list
            |-------------|----------------------|----------------------------|
            |  NAMESPACE  |         NAME         |            URL             |
            |-------------|----------------------|----------------------------|
            | default     | kubernetes           | No node port               |
            | default     | nginx                | http://10.16.234.206:30684 |
            | kube-system | kube-dns             | No node port               |
            | kube-system | kubernetes-dashboard | http://10.16.234.206:30000 |
            |-------------|----------------------|----------------------------|

            C:\WINDOWS\system32>minikube ssh "curl localhost:30684"
            curl: (7) Failed to connect to localhost port 30684: Connection refused

            $ curl "http://10.16.234.206:30684"
              curl: (7) Failed to connect to 10.16.234.206 port 30684: Connection refused
-- prabhakaran
hyper-v
kubernetes
minikube

1 Answer

8/28/2018

The nginx dockerfile exposes port 80, but your pod is using port 8090. Run the deployment using the right port 80 should fix it:

kubectl run nginx --image=nginx --port=80
-- hc6
Source: StackOverflow