Skip to content

feat: fall back to EndpointSlice-based node discovery for selectorless services#25

Open
sircthulhu wants to merge 1 commit intoIntreecom:masterfrom
sircthulhu:feat/endpointslice-fallback
Open

feat: fall back to EndpointSlice-based node discovery for selectorless services#25
sircthulhu wants to merge 1 commit intoIntreecom:masterfrom
sircthulhu:feat/endpointslice-fallback

Conversation

@sircthulhu
Copy link

Summary

When --dynamic-node-selector is enabled (the default), RobotLB currently requires spec.selector on LoadBalancer Services to discover target nodes via pod lookup. Services without a selector produce a ServiceWithoutSelector error.

This PR adds a fallback: when a Service has no selector, RobotLB reads EndpointSlice resources (by the standard kubernetes.io/service-name label) and extracts nodeName from each ready endpoint to determine target nodes.

Context

Cozystack is a cloud platform that runs tenant Kubernetes clusters as KubeVirt virtual machines. When a tenant creates a LoadBalancer Service inside their cluster, kubevirt cloud-controller-manager creates a corresponding Service in the management cluster without a selector and manages EndpointSlice resources directly — this is a deliberate design decision needed to correctly support externalTrafficPolicy: Local (see cloud-provider-kubevirt#330).

This means RobotLB cannot provision Hetzner Cloud Load Balancers for tenant services on Cozystack clusters deployed on Hetzner Robot infrastructure. With this change, RobotLB seamlessly handles both selector-based and selectorless services.

Changes

  • src/main.rs: Added get_nodes_from_endpointslices() function that discovers target nodes from EndpointSlice resources. Modified get_nodes_dynamically() to fall back to this function when selector is absent or empty.
  • helm/values.yaml: Added RBAC permission for discovery.k8s.io/endpointslices (get, list, watch).

…s services

When a Service has no spec.selector (e.g. services created by kubevirt
cloud-controller-manager which manages EndpointSlices directly), the
dynamic node selector now falls back to discovering target nodes from
EndpointSlice resources instead of returning an error.

This enables RobotLB to work with LoadBalancer services where an
external controller manages EndpointSlices, such as tenant Kubernetes
clusters running on KubeVirt with externalTrafficPolicy: Local.

Assisted-By: Claude AI
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant