简体   繁体   English

Google容器连接到服务

[英]Google container connect to service

I'm following a course on PluralSight where the course author puts a docker image onto kubernetes and then access it via his browser. 我正在PluralSight上学习一门课程,该课程的作者将docker映像放在kubernetes上,然后通过他的浏览器访问它。 I'm trying to replicate what he does but I cannot manage to reach the website. 我正在尝试复制他的工作,但是我无法访问该网站。 I believe I might be connecting to the wrong IP. 我相信我可能连接了错误的IP。

I have a ReplicationController that's running 10 pods : 我有一个运行10个podsReplicationController

rc.yml rc.yml

apiVersion: v1
kind: ReplicationController
metadata:
          name: hello-rc
spec:
        replicas: 10
        selector:
                app: hello-world
        template:
             metadata:
                labels:
                        app: hello-world
             spec:
                     containers:
                             - name: hello-pod
                               image: nigelpoulton/pluralsight-docker-ci:latest
                               ports:
                                       - containerPort: 8080

I then tried to expose the rc: 然后,我尝试公开rc:

kubectl expose rc hello-rc --name=hello-svc --target-port=8080 --type=NodePort


$ kubectl get services
NAME         CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-svc    10.27.254.160   <nodes>       8080:30488/TCP   30s
kubernetes   10.27.240.1     <none>        443/TCP          1h

My google container endpoint is : 35.xxx.xx.xxx and when running kubectl describe svc hello-svc the NodePort is 30488 我的谷歌容器端点是: 35.xxx.xx.xxx ,运行kubectl describe svc hello-svc ,NodePort是30488

Thus I try to access the app at 35.xxx.xx.xxx:30488 but the site can't be reached. 因此,我尝试通过35.xxx.xx.xxx:30488访问该应用程序,但无法访问该站点。

If you want to access your service via the NodePort port, you need to open your firewall for that port (and that instance). 如果要通过NodePort端口访问服务,则需要为该端口(和该实例)打开防火墙。

A better way is to create a service of type LoadBalancer ( --type=LoadBalancer ) and access it on the IP Google will give you. 更好的方法是创建类型为LoadBalancer(-- --type=LoadBalancer )的服务,然后通过Google提供的IP对其进行访问。

Do not forget to delete the load balancer when you are done. 完成后,请不要忘记删除负载均衡器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Cloud Container:无法连接到mongodb服务 - Google Cloud Container: Can not connect to mongodb service 如何将 Google Cloud Run Container 连接到 OpenVPN? - How to connect Google Cloud Run Container to OpenVPN? kubectl无法连接到Google容器引擎 - kubectl can't connect to Google Container Engine 如何从Google Container Engine连接Google Cloud SQL? - How to connect Google Cloud SQL from Google Container Engine? Google Kubernetes Engine 服务无法连接到 Snowflake - Google Kubernetes Engine Service Unable To Connect To Snowflake 从计算引擎实例连接到容器服务clusterip - Connect to container service clusterip from compute engine instance 将 Kubernetes 服务帐号连接到 Google Cloud 服务帐号 - Connect Kubernetes service account to Google Cloud service account 连接到在Google Container Engine(node.js)上创建的Kubernetes apiserver - Connect to Kubernetes apiserver created on Google Container Engine (node.js) 如何在Google容器引擎上运行的Kubernetes中连接到IPv6地址? - How to connect to IPv6 addresses in Kubernetes running on Google Container Engine? 使用Java App从Container Engine连接到Google Cloud SQL - Connect to Google Cloud SQL from Container Engine with Java App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM