Skip to content

feat: migrate from Endpoints to EndpointSlice API#1309

Draft
wasaga wants to merge 6 commits intomainfrom
feat/migrate-endpoints-to-endpointslice
Draft

feat: migrate from Endpoints to EndpointSlice API#1309
wasaga wants to merge 6 commits intomainfrom
feat/migrate-endpoints-to-endpointslice

Conversation

@wasaga
Copy link
Contributor

@wasaga wasaga commented Jan 24, 2026

Summary

Migrates the ingress controller from the deprecated Endpoints API to EndpointSlice API.

The Endpoints API is deprecated in favor of EndpointSlice.

Changes:

  • Adds model/endpoint_slices.go with AggregateEndpointSlices function that converts EndpointSlices to EndpointSubset format
  • Updates controller to watch EndpointSlice instead of Endpoints
  • Fetches EndpointSlices using label selector kubernetes.io/service-name
  • Only includes endpoints where conditions.Ready=true
  • Deduplicates addresses across multiple slices (handles rolling updates)
  • Updates RBAC to grant discovery.k8s.io/endpointslices permissions

Related issues

Checklist

  • reference any related issues
  • updated docs
  • updated unit tests
  • updated UPGRADING.md
  • add appropriate tag (improvement / bug / etc)
  • ready for review

The Endpoints API is deprecated in favor of EndpointSlice which provides
better scalability for large services and supports dual-stack networking.

This change:
- Adds model/endpoint_slices.go with AggregateEndpointSlices function
  that converts EndpointSlices to the existing EndpointSubset format
- Updates the ingress controller to watch EndpointSlice resources
  instead of Endpoints
- Uses label selector kubernetes.io/service-name to fetch slices
- Only includes endpoints with conditions.Ready=true
- Deduplicates addresses across multiple slices (handles rolling updates)
- Updates RBAC to grant discovery.k8s.io/endpointslices permissions

The route generation code (pomerium/ingress_to_route.go) remains unchanged
due to the adapter pattern preserving the EndpointSubset structure.
@wasaga wasaga added the enhancement New feature or request label Jan 24, 2026
The dependency tracking system was looking up dependencies by the
EndpointSlice's name (e.g., "service-slice"), but dependencies were
registered under the Service name. This caused EndpointSlice changes
to not trigger Ingress reconciliation.

Fix: When an EndpointSlice changes, extract the service name from the
"kubernetes.io/service-name" label and look up dependencies by the
Service instead.

Also adds an integration test to verify EndpointSlice updates trigger
reconciliation.
Map iteration order in Go is non-deterministic. When converting the
subsetsByPort map to a slice, the order of subsets could vary between
runs with identical input, potentially causing unnecessary reconciliation
churn.

Fix: Sort subsets by port name, port number, and protocol before returning.
When listing EndpointSlices returns an empty result, log an info message
to help operators debug potential issues such as:
- Missing RBAC permissions on discovery.k8s.io/endpointslices
- Timing race where EndpointSlice controller hasn't created slices yet
- Label selector mismatch
Add tests for edge cases:
- Slice with empty Endpoints array (can happen during rolling deployments)
- Same port number with different protocols (e.g., DNS on TCP/UDP port 53)
- Multiple slices with different ports (large services split across slices)

These tests also verify the deterministic ordering introduced in the
previous commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant