[英]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个
pods
的ReplicationController
:
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.