Kubernetes Endpoints

Ivan (이반) Porta
The Startup

--

In my previous article, I defined services as objects with a static IP that forwards the requests to pods whose selector contains a label described in its YAML description.

However, a service does not link straight to pods. When Kubernetes processes a service description, and if the service selector matches a pod label, Kubernetes will automatically create an Endpoints object with the same name as the service, which stores the pod’s IP address and port. Consequently, when the service receives a request, its proxy will redirect it to one of those IPs and ports.

Relationships between services, endpoints and pods

In this example, I will deploy three pod replicas and a service in which the selector will contain one of the pod’s labels.

apiVersion: apps/v1
kind: Deployment
metadata:
name: training-deployment
spec:
selector:
matchLabels:
app: training
version: v1
replicas: 3
template:
metadata:
labels:
app: training
version: v1…

--

--

Ivan (이반) Porta
The Startup

Senior DevOps Engineer | Terraform Associate | Certified Argo Project Associate