feat: migrate from Endpoints to EndpointSlice API#1309
Draft
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the ingress controller from the deprecated
EndpointsAPI toEndpointSliceAPI.The
EndpointsAPI is deprecated in favor ofEndpointSlice.Changes:
model/endpoint_slices.gowithAggregateEndpointSlicesfunction that converts EndpointSlices to EndpointSubset formatEndpointSliceinstead ofEndpointskubernetes.io/service-nameconditions.Ready=truediscovery.k8s.io/endpointslicespermissionsRelated issues
Checklist
improvement/bug/ etc)