minikube上无法访问公开的服务

时间:2018-08-28 13:43:44

标签: kubernetes hyper-v minikube

我只是在Windows10机器+ Hyper V.中的minikube的帮助下启动kubernetes,如下所示,但已部署并暴露了nginx容器,但无法通过minikube ip或minikube服务器内部访问部署的应用程序。

            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

1 个答案:

答案 0 :(得分:2)

nginx dockerfile公开了端口80,但是您的pod使用的是端口8090。使用正确的端口80运行部署应该对其进行修复:

kubectl run nginx --image=nginx --port=80