How to Migrate from Endpoints to EndpointSlices in Kubernetes: A Step-By-Step Guide

Posted by

Kubernetes 1.33+ marks the official deprecation of the legacy Endpoints API in favor of EndpointSlices. Migrating early not only future-proofs your clusters but also delivers significant performance and scalability benefits for modern cloud-native workloads. In this blog post, you’ll learn what EndpointSlices are, why this migration matters, and how to conduct a clean, safe transition for your automation, controllers, and YAML manifests.

Why Migrate to EndpointSlices?

  • Performance: EndpointSlices dramatically reduce API server load and client watch bandwidth, especially in large clusters. For clusters with thousands of endpoints, this can cut Kube-Proxy CPU use by up to 30% and shrink network payloads by almost half12.
  • Advanced Features: New networking features—like dual-stack IP support, advanced traffic policies, and port-based splitting—are only available through EndpointSlices, not the old Endpoints API23.
  • Deprecation: From Kubernetes v1.33, using Endpoints will generate warnings, and future conformance criteria might drop mandatory Endpoints—even as the resource itself lingers for backward compatibility2.

What’s Different? Endpoints vs. EndpointSlices

FeatureEndpoints (Deprecated)EndpointSlices (Current)
Resource per service1 per Service1–many per Service
Dual-stack supportNoYes, separate slices per IP type
Maximum endpoints objectNo enforced cap100 endpoints per slice (default)
Extensible data modelLimitedRich: zone, topology, conditions
Controller managementEndpointsControllerEndpointSliceController

Migration Planning: Key Steps

1. Audit Your Cluster for Endpoints Usage

  • Inspect your CI/CD scripts, custom controllers, and YAMLs for any use of or writes to the Endpoints API object (v1.Endpoints).
  • Search for client library calls like CoreV1().Endpoints() in Go or equivalent in other languages12.
  • Run: textkubectl get endpoints --all-namespaces to see active legacy Endpoints.

2. Understand EndpointSlices

  • Each Service can now have several EndpointSlice objects, distinguished by address family (IPv4/IPv6), ports, or endpoint count.
  • Query EndpointSlices: textkubectl get endpointslice -l kubernetes.io/service-name=<service> Unlike Endpoints, slice names are autogenerated with unique suffixes and linked by label12.

3. Update Automation and Controller Code

  • YAML Example (Endpoints → EndpointSlice conversion):
    Old (Endpoints): textapiVersion: v1 kind: Endpoints metadata: name: myservice subsets: - addresses: - ip: 10.0.0.1 ports: - port: 80
    New (EndpointSlice): textapiVersion: discovery.k8s.io/v1 kind: EndpointSlice metadata: generateName: myservice- labels: kubernetes.io/service-name: myservice addressType: IPv4 endpoints: - addresses: ["10.0.0.1"] nodeName: node-1 conditions: ready: true ports: - name: http protocol: TCP port: 80 Key highlights:
    • Use addressType (IPv4 or IPv6)
    • Add kubernetes.io/service-name label for slice linkage
    • Each slice maxes at 100 endpoints by default for scalability13

4. Configure Feature Gates

  • Ensure your cluster has the following enabled:
    • EndpointSlice
    • EndpointSliceProxying
  • These should be set in your API server and controller manager for your test/staging clusters before moving to production rollout1.

5. Test Migration in a Safe Environment

  • Deploy test workloads (ideally with multi-port and dual-stack settings) and monitor:
    • Service resolution
    • Traffic routing
    • Proxy/Firewall behavior
  • Inspect metrics and logs for any issues with discovery or endpoint reachability.

6. Gradually Roll Over to EndpointSlices

  • Start with non-critical services.
  • Monitor and validate using both legacy and new resources.
  • Once validated, fully cut over remaining services and scripts.
  • Remove any Endpoints-specific handlers or backward compatibility layers.

7. Update Documentation and Communicate Changes

  • Inform your platform and developer teams about updated query patterns, resource types, and any necessary code shifts.
  • Update runbooks, troubleshooting docs, and onboarding guides.

Best Practices for a Smooth EndpointSlice Migration

  • Always test in a staging environment first.
  • Use up-to-date client libraries: Many libraries now support EndpointSlices out of the box.
  • Employ robust monitoring to catch regressions related to service discovery.
  • Leverage gradual rollout strategies, such as canary deployments, to minimize risks with critical workloads41.
  • Automate audits to detect and prevent legacy Endpoints usage post-migration.

Frequently Asked Questions

Will my Services stop working during the migration?
No; as long as you test thoroughly before full cutover and keep cluster feature gates set correctly, your Services will seamlessly migrate, especially if you avoid deleting legacy Endpoints until ready2.

Can I manage EndpointSlices manually?
Yes, but rely on the Kubernetes control plane where possible. For custom slices, always respect label conventions and endpoint splitting rules35.

Is the Endpoints API going away?
Deprecation means you should migrate, but the resource will persist for backward compatibility—however, future features require EndpointSlices2.

Conclusion

Migrating to EndpointSlices is a vital step in preparing your Kubernetes clusters for scale, efficiency, and the future. With careful planning, incremental rollouts, and automation, the transition can be smooth and risk-free. Start updating your tooling, educate your team, and leverage EndpointSlices today for a more robust, cloud-native platform.