When we define labels for pods and selector for services to link pods to services, kubernetes creates endpoints with an IP addresses and a port number that get assigned to each pod that the service maps to.

There is an endpoint for each pod that has a label that matches the service label selector


Endpoints are a group of IP addresses and ports that a service forwards its requests to.
Endpoint get the IP address and the port number a pod is listening on.

For each endpoint the kube-proxy creates a iptables rule with the IP address of pod.
The kube-proxy is the process that allows communication with a pod that lives inside a node.

Remark:

Kubernetes uses the pod selector mentioned in the service Yaml file to create the endpoints that correspond to these selectors.
Endpoints are "decoupled" from services, so they can also be created manually.

Below is the Yaml configuration file of the endpoints:


The name of the endpoints needs to match the name of the service "service_1" in our example below:


Displaying endpoints:

We could display the endpoint in the kubernetes cluster using the below command:


Brando Sabatini and Ikbal C ©. Powered by Blogger.