Repository navigation
feat(api): set trafficDistribution on the client Service - #376
Conversation
Clusters stretched across zones want clients of the <cluster>-client Service to prefer a member in their own zone. Add an optional clientService block with a trafficDistribution field whose allowed values mirror the core Service API. Unset leaves today's behaviour. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Set spec.trafficDistribution on <cluster>-client from spec.clientService and reconcile drift back to it. The field is only owned when the EtcdCluster sets it, so a value patched onto the Service by hand survives when the spec leaves it unset. The headless Service is never touched. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Controller tests for create, drift back to the spec, an unset field leaving a hand-set value alone, and the headless Service never being touched. envtest cases for the enum on spec.clientService and for the apiserver persisting the field on a Service. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Document the client Service, which fields the operator owns on it, and the new trafficDistribution setting for zone-local clients in clusters stretched across zones, including apiserver version requirements. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Kirill Ilin (sircthulhu)
left a comment
There was a problem hiding this comment.
LGTM, two minor comments inline.
This reverts commit eccc4fb, removing spec.clientService.trafficDistribution from the EtcdCluster API. The capability returns in the next commit as an annotation on the EtcdCluster, so the API does not change for now. Assisted-By: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
…otation The etcd-operator.cozystack.io/client-service-traffic-distribution annotation on an EtcdCluster sets spec.trafficDistribution on the <cluster>-client Service (PreferClose, PreferSameZone or PreferSameNode), so clients of a cluster stretched across zones prefer a nearby member. It stands in for a typed spec field without changing the API for now. The field is written with server-side apply under its own field manager, so removing the annotation clears it unless another manager also set it, and a value someone else set without the annotation is left alone. A value outside that set, one the apiserver rejects (PreferSameZone and PreferSameNode before 1.34) or one it drops (no support before 1.31) is reported as a Warning Event and leaves the field unset; the rest of the reconcile carries on. The headless Service is not touched. Builds on the controller tests and docs of #376 by Andrei Kvapil. Assisted-By: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
What
Adds an optional
spec.clientService.trafficDistributiontoEtcdCluster. When set, the operator writes it tospec.trafficDistributionof the<cluster>-clientService on create and reconciles drift back to it. Allowed values mirror the core Service API:PreferClose,PreferSameZone,PreferSameNode, validated by an enum on the CRD.Why
Clusters stretched across zones (e.g. two sites plus a witness) want clients to prefer an etcd member in their own zone. The client Service has a selector, so with
trafficDistribution: PreferClosethe EndpointSlice controller writes zone hints and proxies that honour them (kube-proxy, Cilium) keep traffic zone-local. Today this can only be done by patching the Service by hand, which survives reconcile but is lost when the Service is recreated.Behaviour
clientService, or notrafficDistributionin it) means no change from today: the operator does not touch the field, so a value set on the Service by hand is preserved.status.observed— the Service carries no consensus state, so a change applies on the next reconcile.clientServiceis a struct so further client-Service settings can land next to it.Compatibility
PreferCloseneeds Kubernetes 1.31+ (GA in 1.33);PreferSameZone/PreferSameNodeneed 1.34+. Documented on the field and indocs/concepts.md.Testing
trafficDistributionon a Service.make testpasses;make generate manifestsproduces no drift.Summary by CodeRabbit
PreferClose,PreferSameZone, andPreferSameNode.