简体   繁体   English

端点 IP 与服务 IP

[英]Endpoint IP vs Service IP

I created a POD and exposed it as service using following command:我创建了一个 POD 并使用以下命令将其公开为服务:

kubectl run nginx --image=nginx --restart=Never --port=80 --expose

When i execute following commands i get two different IP addresses.当我执行以下命令时,我得到两个不同的 IP 地址。 What are the below IP addressed represents?下面提到的 IP 代表什么? Which IP should be used by other services while calling my service in the cluster.在集群中调用我的服务时,其他服务应该使用哪个 IP 。

master $ kubectl get ep nginx

NAME    ENDPOINTS      AGE

nginx   10.40.0.1:80   11m

master $ kubectl get svc nginx

NAME    TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE

nginx   ClusterIP   10.103.78.253   <none>        80/TCP    12m

The IP in the endpoints of a service is the IP of the backend pods selected by the selector of the service matching with labels on the pods..If there are more than one replica of the pod there will be more than one IP in the endpoints.服务的端点中的 IP 是服务的选择器选择的后端 pod 的 IP 与 pod 上的标签匹配。如果 pod 的副本超过一个,那么端点中将有多个 ZA42619BAED . The IP in ClusterIP is a virtual IP is what should be used for calling a service.The service forward(with load balancing) any request coming via the clusterIP to POD IPs present in the endpoints. ClusterIP 中的 IP 是一个虚拟 IP 应该用于调用服务。服务转发(具有负载平衡)来自 clusterIP 的任何请求到端点中存在的 POD IP。

From the docs here .这里的文档。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM