K8s v1.33!! ENDPOINTS (Deprecated) vs ENDPOINTSLICE

Sangam GhimireSangam Ghimire
3 min read

With the K8s v1.33 ENDPOINTs are now deprecated! Though, it may never fully go away!

Let’s Begin from first!|

What are Endpoints?
In Kubernetes, Endpoints is an older resource type used to keep track of the IP addresses and ports of the Pods that are associated with a specific Service. When you create a Service, Kubernetes automatically creates a corresponding Endpoints object that lists all the Pods currently matching the Service’s selector. This Endpoints object is continuously updated by the control plane, whenever Pods are added, removed, or their states change, ensuring that the Service always has an accurate list of its backend Pods.

Example: Create a Service and Pod

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: my-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
---
apiVersion: v1
kind: Pod
metadata:
  name: my-pod-1
  labels:
    app: my-app
spec:
  containers:
    - name: my-container
      image: nginx
      ports:
        - containerPort: 8080
---
apiVersion: v1
kind: Pod
metadata:
  name: my-pod-2
  labels:
    app: my-app
spec:
  containers:
    - name: my-container
      image: nginx
      ports:
        - containerPort: 8080

Once applied, Endpoints object automatically created that looks something like this:

apiVersion: v1
kind: Endpoints
metadata:
  name: my-service
subsets:
  - addresses:
      - ip: 10.244.0.5
      - ip: 10.244.0.6
    ports:
      - port: 8080
        protocol: TCP

And, If you delete my-pod-1, the IP 10.244.0.5 will be removed from the Endpoints list.
Also, If you add a new Pod with the same label app: my-app, its IP will be appended automatically.

Now, Let’s talk about.

What are EndpointSlices?

EndpointSlices store the IP addresses, ports, and other metadata for the Pods behind a Service, just like Endpoints.

  • Instead of keeping all endpoints in one big object (as Endpoints does), Kubernetes splits them into multiple smaller slices, each holding up to 100 endpoints by default (limit can be configured) .

  • This makes them more efficient for large Services with hundreds or thousands of Pods.

Why EndpointSlices?

EndpointSlices is a newer and more scalable approach introduced to address the limitations of the Endpoints resource. EndpointSlices allow for more efficient management of network endpoints and support larger scale clusters by splitting the endpoints into multiple smaller resources.

Endpoints objects can become very large for Services with many Pods.
Which sometimes causes a huge hassle:

  • Updating a huge Endpoints object means sending large chunks of data across the cluster, which can slow things down.
  • EndpointSlices reduce update size and frequency, improving performance and scalability.

    Example of an EndpointSlice in Action:

      apiVersion: discovery.k8s.io/v1
      kind: EndpointSlice
      metadata:
        name: my-service-abc123
        labels:
          kubernetes.io/service-name: my-service
      addressType: IPv4
      ports:
        - name: http
          protocol: TCP
          port: 8080
      endpoints:
        - addresses:
            - 10.244.0.5
          conditions:
            ready: true
          topology:
            kubernetes.io/hostname: node-1
        - addresses:
            - 10.244.0.6
          conditions:
            ready: true
          topology:
            kubernetes.io/hostname: node-2
        - addresses:
            - 10.244.0.7
          conditions:
            ready: true
          topology:
            kubernetes.io/hostname: node-1
    
      apiVersion: v1
      kind: Service
      metadata:
        name: my-service
      spec:
        selector:
          app: my-app
        ports:
          - protocol: TCP
            port: 80
            targetPort: 8080
      ---
      apiVersion: v1
      kind: Pod
      metadata:
        name: my-pod-1
        labels:
          app: my-app
      spec:
        containers:
          - name: my-container
            image: nginx
            ports:
              - containerPort: 8080
      ---
      apiVersion: v1
      kind: Pod
      metadata:
        name: my-pod-2
        labels:
          app: my-app
      spec:
        containers:
          - name: my-container
            image: nginx
            ports:
              - containerPort: 8080
      ---
      apiVersion: v1
      kind: Pod
      metadata:
        name: my-pod-3
        labels:
          app: my-app
      spec:
        containers:
          - name: my-container
            image: nginx
            ports:
              - containerPort: 8080
    
      kubectl get endpointslices
    
      NAME                   ADDRESSTYPE   PORTS   ENDPOINTS                         AGE
      my-service-abc123      IPv4          8080    10.244.0.5,10.244.0.6,10.244.0.7   1m
    

    If you had 250 Pods for the same Service:

    • Endpoints: 1 single huge object with 250 entries.

    • EndpointSlices: 3 separate objects (first two holding 100 endpoints, last one holding 50).

This means:

  • Smaller object updates → less network overhead inside the cluster.

  • kube-proxy and other consumers can watch smaller chunks as now they have

    • Less data to watch/update in the API server

    • Lower CPU & network load during Pod churn

    • Better scaling in clusters with hundreds or thousands of Services

  • Better performance in large deployments.

Nothing better than the K8s Docs!
Here is the link: https://kubernetes.io/docs/concepts/services-networking/endpoint-slices/

0
Subscribe to my newsletter

Read articles from Sangam Ghimire directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sangam Ghimire
Sangam Ghimire