What is an 'endpoint' in Kubernetes?

后端 未结 6 1437
清歌不尽
清歌不尽 2021-01-31 07:22

I am new to Kubernetes and started reading through the documentation. There often the term \'endpoint\' is used but the documentation lacks an explicit definition.

What

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-31 07:58

    An endpoint is an object that gets IP addresses of individual pods assigned to it. The endpoint object is then in turn referenced by a kubernetes service, so that the service has a record of the internal IPs of pods in order to be able to communicate with them. We need endpoints as an abstraction layer because the 'service' in kubernetes acts as part of the orchestration to ensure distribution of traffic to pods (including only sending traffic to healthy pods). For example if a pod dies, a replacement pod will be generated, with a new IP address. Conceptually, the dead pod IP will be removed from the endpoint object, and the IP of the newly created pod will be added, so that the service is updated and 'knows' which pods to connect to.

    Read 'Exposing pods to the cluster', then 'Creating a Service' here - https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#exposing-pods-to-the-cluster

    An easy way to investigate and see the relationship is:

    • kubectl get pods - and observe the IP addresses of your pods
    • kubectl get ep - and observe the IP addresses assigned to your endpoint
    • kubectl describe service myServiceName - and observe the Endpoints associated with your service

    So no, the endpoint isn't anything to do with the IP of an individual node. I find it useful to understand the overall structure of kubernetes and the relationship between the cluster, nodes, services, endpoints and pods. This diagram summarises it nicely:

提交回复
热议问题