如何从同一集群上的另一个节点访问 kubernetes 节点上的服务?

How do I access a service on a kubernetes node from another node on the same cluster?

我的服务描述:

kubernetes describe service app-checklot --namespace=app-test-gl

Name:              app-checklot
Namespace:         app-test-gl
Labels:            app=app-checklot
                   chart=app-checklot-0.1.0
                   heritage=Tiller
                   release=chkl
Annotations:       <none>
Selector:          app=app-checklot,release=chkl
Type:              ClusterIP
IP:                10.99.252.76
Port:              https  11080/TCP
TargetPort:        11080/TCP
Endpoints:         85.101.213.102:11080,85.101.213.103:11080
Session Affinity:  None
Events:            <none>

我可以使用个人 ip 单独访问 pods:

http://85.101.213.102:11080/service
http://85.101.213.103:11080/service

还有使用IP的服务(这需要通过url从另一个节点配置):

http://10.99.252.76:11080/service

我想要的是使用 url 中的服务名称访问服务 (app-checklot) - 这样我就不必总是更新 url 了。这可能吗?如果是,怎么做?

是的,您的服务应该在集群内可用:

http://app-checklot.app-test-gl:11080/service

来自Documentation

For example, if you have a Service called "my-service" in a Kubernetes Namespace called "my-ns", a DNS record for "my-service.my-ns" is created. Pods which exist in the "my-ns" Namespace should be able to find it by simply doing a name lookup for "my-service". Pods which exist in other Namespaces must qualify the name as "my-service.my-ns". The result of these name lookups is the cluster IP.

另一项部署到 相同命名空间 的服务将能够调用 http://app-checklot/service