Add a primary (write) Service routing to pod-0
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful

Secondaries reject RFC2136/nsupdate writes, but the read Service round-
robins across all pods. Add an optional per-cluster write endpoint that
targets only the primary pod (ordinal 0) via the StatefulSet pod-name
label. Reads keep using the all-pods Service.

- api: BindCluster.spec.primaryService (*ClusterServiceSpec) — ClusterIP
  for in-cluster writers (external-dns) or LoadBalancer for external
- reconcilePrimaryService creates <cluster>-primary selecting pod-0 when
  set, deletes it when unset
- regenerate CRDs + install.yaml
This commit is contained in:
2026-07-04 22:29:55 +10:00
parent e0bd3973ed
commit 28ae6538cb
6 changed files with 148 additions and 9 deletions
+9 -1
View File
@@ -105,10 +105,18 @@ type BindClusterSpec struct {
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
// Service controls how the cluster is exposed.
// Service controls how the cluster is exposed for reads (all pods).
// +optional
Service ClusterServiceSpec `json:"service,omitempty"`
// PrimaryService, when set, creates an additional Service routing only to the
// primary pod (ordinal 0) — the write endpoint for RFC2136/nsupdate, since
// secondaries reject updates. Reads still use Service (all pods). Use
// ClusterIP for in-cluster writers (e.g. external-dns) or LoadBalancer for
// external writers.
// +optional
PrimaryService *ClusterServiceSpec `json:"primaryService,omitempty"`
// NodeSelector for the BIND pods.
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
+5
View File
@@ -301,6 +301,11 @@ func (in *BindClusterSpec) DeepCopyInto(out *BindClusterSpec) {
}
in.Resources.DeepCopyInto(&out.Resources)
in.Service.DeepCopyInto(&out.Service)
if in.PrimaryService != nil {
in, out := &in.PrimaryService, &out.PrimaryService
*out = new(ClusterServiceSpec)
(*in).DeepCopyInto(*out)
}
if in.NodeSelector != nil {
in, out := &in.NodeSelector, &out.NodeSelector
*out = make(map[string]string, len(*in))