feat(zrpc): migrate kube resolver from Endpoints to EndpointSlice API
Motivation
Kubernetes is gradually deprecating the legacy core/v1 Endpoints API in favor of the newer discovery/v1 EndpointSlice API.
Compared with Endpoints, EndpointSlice objects:
- Scale horizontally—each slice covers a subset of endpoints, avoiding the single-object size limit.
- Reduce API-server churn—only slices that change are updated.
- Provide topology and readiness metadata that can be leveraged for smarter routing.
To keep go-zero up-to-date with upstream best practices and to prevent future breakage as clusters disable the old API, we need to adopt EndpointSlice.
What this PR does
-
Event Path Migration
- Replaces all
core/v1 Endpointstypes withdiscovery/v1 EndpointSlicein the kube resolver. - Adjusts event-handler logic to iterate over
EndpointSlice.Endpoints[].Addresses[].
- Replaces all
-
Informer Updates
- Swaps the informer factory from
Core().V1().Endpoints()toDiscovery().V1().EndpointSlices(). - Uses the recommended label selector
kubernetes.io/service-name=<svc>.
- Swaps the informer factory from
-
Initial Sync & Port Resolution
- Lists existing
EndpointSliceobjects for the target service at startup. - Resolves
svc.Portfrom the first available slice port when the user omits it.
- Lists existing
-
Constants & Clean-ups
- Renames
nameSelector→serviceSelectorfor clarity. - Adds explicit error reporting when no matching slices are found.
- Renames
Impact
- Transparent to callers – existing
zrpcresolver API remains unchanged. - Better scalability & performance – large services no longer hit the 1000-endpoint hard limit.
- Future-proof – compatible with clusters that have disabled the legacy
EndpointsAPI. - RBAC change required – controllers using this resolver must be granted
get, list, watchonEndpointSlices(discovery.k8s.iogroup).
No other functional regressions are expected. All unit tests pass against Kubernetes ≥1.21 (the minimum version that GA-supports EndpointSlice).
Codecov Report
:x: Patch coverage is 47.82609% with 24 lines in your changes missing coverage. Please review.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| zrpc/resolver/internal/kubebuilder.go | 0.00% | 24 Missing :warning: |
:loudspeaker: Thoughts on this report? Let us know!
Thanks for your contribution!
This PR will be merged in v1.9.0