如何通过ClusterIP访问Kubernetes服务 [英] How can I access the Kubernetes service through ClusterIP

查看:520
本文介绍了如何通过ClusterIP访问Kubernetes服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用三个VM(Master – 10.x.x.4,Node1 – 10.x.x.150,Node2 – 10.x.x.160)创建Kubernetes集群.

I am trying to create Kubernetes cluster using three VMs(Master – 10.x.x.4, Node1 – 10.x.x.150, Node2 – 10.x.x.160).

通过以下链接,我能够成功创建留言簿应用程序: http://kubernetes. io/v1.0/examples/guestbook/.我对frontend-service.yaml进行的一项更改是:使用NodePort.我可以使用节点IP和端口号(10.x.x.150:30724或10.x.x.160:30724)访问前端服务.因此一切都按预期工作,但我无法使用ClusterIP地址(在我的情况下为10.x.x.79)访问前端服务.

I was able to create the guestbook application successfully following this link: http://kubernetes.io/v1.0/examples/guestbook/. Only one change I made to frontend-service.yaml: to use NodePort. I can access the frontend service using nodes IP and port number(10.x.x.150:30724 or 10.x.x.160:30724). So everything is working as expected but I am not able to access the frontend service using ClusterIP address(in my case 10.x.x.79).

我对NodePort的理解是,可以通过群集IP以及群集每个节点上的端口访问该服务.如何通过ClusterIP访问服务,而不必访问每个节点?我在这里想念什么吗?

My understanding of NodePort is that the service can be accessed through cluster IP and also on a port on each node of the cluster. How can I access the service through ClusterIP so that I don’t have to access the each node? Am I missing something here?

服务和广告连播详细信息

$ sudo kubectl描述服务前端

Name:                   frontend
Namespace:              default
Labels:                 name=frontend
Selector:               name=frontend
Type:                   NodePort
IP:                     10.x.x.79
Port:                   <unnamed>       80/TCP
NodePort:               <unnamed>       30724/TCP
Endpoints:              172.x.x.13:80,172.x.x.14:80,172.x.x.11:80
Session Affinity:       None

No events.

$ sudo kubectl描述pod frontend-2b5us

Name:                           frontend-2b5us
Namespace:                      default
Image(s):                       gcr.io/google_samples/gb-frontend:v3
Node:                           10.x.x.150/10.x.x.150
Labels:                         name=frontend
Status:                         Running
Reason:
Message:
IP:                             172.x.x.11
Replication Controllers:        frontend (3/3 replicas created)
Containers:
  php-redis:
    Image:              gcr.io/google_samples/gb-frontend:v3
    State:              Running
      Started:          Fri, 30 Oct 2015 04:00:40 -0500
    Ready:              True
    Restart Count:      0

我尝试搜索,但没有找到确切问题的任何解决方案,但我确实找到了类似GCE的类似问题.

I tried to search but would not find any solution for my exact problem but I did find similar problem that looks like for GCE.

为什么我不能访问我的Kubernetes服务通过其IP?

推荐答案

您尝试从何处访问clusterIP? clusterIP(默认情况下)仅可在集群内使用.这是一个虚拟IP,没有路由.

From where are you trying to access clusterIP? The clusterIP (by default) only works from within the cluster. It is a virtual IP, not routed.

这篇关于如何通过ClusterIP访问Kubernetes服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆