无法在谷歌云上暴露外部IP

时间:2018-02-25 06:25:02

标签: kubernetes google-cloud-platform google-kubernetes-engine

我按照kubernetes-engine教程,在终端使用了本地gloud。看起来一切正常,但我无法在浏览器中看到外部的ip http://104.197.4.162/,正如教程所说。谢谢!

$ kubectl get service

NAME         TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)        AGE
hello-web    LoadBalancer   10.11.245.151   104.197.4.162   80:30135/TCP   1m

$ kubectl get pods

NAME                         READY     STATUS    RESTARTS   AGE
hello-web-7d4f9779bf-lw9st   1/1       Running   0          1m

$ kubectl描述svc hello-web

Name:                     hello-web
Namespace:                default
Labels:                   run=hello-web
Annotations:              <none>
Selector:                 run=hello-web
Type:                     LoadBalancer
IP:                       10.11.245.151
LoadBalancer Ingress:     104.197.4.162
Port:                     <unset>  80/TCP
TargetPort:               8080/TCP
NodePort:                 <unset>  30135/TCP
Endpoints:                10.8.0.6:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

$ curl 104.197.4.162:80

curl: (7) Failed to connect to 104.197.4.162 port 80: Connection refused

https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app

2 个答案:

答案 0 :(得分:1)

我认为您需要打开防火墙并通过实例外部IP地址和端口访问计算引擎实例中的部署。您可以使用curl ip:port进行检查。

答案 1 :(得分:0)

根据教程所说,我引用它:

  

注意:Kubernetes Engine会为服务分配外部IP地址   资源 - 而不是部署。如果你想找出外部IP   您可以为您的应用程序配置Kubernetes Engine   使用kubectl get service命令检查服务

$ kubectl get service
NAME         CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
hello-web    10.3.251.122    203.0.113.0     80:30877/TCP     3d
     

确定应用程序的外部IP地址后,   复制IP地址。将浏览器指向此URL(例如   http://203.0.113.0)检查您的应用程序是否可访问。

因此,您需要运行$ kubectl get service hello-web才能知道IP地址。