Skip to content

orchestratord: use leader election and run multiple operator replicas#37806

Draft
alex-hunt-materialize wants to merge 1 commit into
MaterializeInc:mainfrom
alex-hunt-materialize:orchestratord-leader-election
Draft

orchestratord: use leader election and run multiple operator replicas#37806
alex-hunt-materialize wants to merge 1 commit into
MaterializeInc:mainfrom
alex-hunt-materialize:orchestratord-leader-election

Conversation

@alex-hunt-materialize

Copy link
Copy Markdown
Contributor

Motivation

Rolling out orchestratord updates causes short downtime of the CRD conversion webhook when running a single replica. Running multiple replicas fixes that, but requires that only one replica reconciles at a time.

Changes

  • Run each of orchestratord's controllers (materialize, balancer, console) under k8s-controller's new lease-based leader election (Add lease-based leader election k8s-controller#51). Each controller holds a coordination.k8s.io/v1 Lease in the operator's namespace; standby replicas keep serving the conversion webhook while waiting on the lease. When a replica loses a leadership lease it exits and lets Kubernetes restart it, so no in-flight reconciliation outlives the lease.
  • Helm chart: default to 2 operator replicas, create a PodDisruptionBudget when running more than one replica (operator.podDisruptionBudget values), and grant the operator get/create/update on leases in coordination.k8s.io.

Testing

  • New leader-failover workflow in test/orchestratord/mzcompose.py, enabled in the Nightly pipeline. It verifies that all controller leases are held by operator pods, that leadership fails over both when the leader pod is deleted and after a rolling restart of the operator deployment, and that reconciliation completes after each failover.
  • New helm-unittest coverage for the PodDisruptionBudget template.

Blocked on

Draft until MaterializeInc/k8s-controller#51 merges and is released: this PR does not build against the released k8s-controller 0.11.0. Once the library is released, the k8s-controller version bump in Cargo.toml/Cargo.lock will be added here.

🤖 Generated with Claude Code

Run each of orchestratord's controllers (materialize, balancer, console)
under k8s-controller's lease-based leader election, so that multiple
replicas of orchestratord can run while only one replica reconciles each
controller at a time. The other replicas keep serving the conversion
webhook, which avoids webhook downtime during operator rollouts and node
drains. When a replica loses a leadership lease it exits and lets
Kubernetes restart it, so no in-flight reconciliation outlives the lease.

Helm chart changes: default to 2 operator replicas, create a
PodDisruptionBudget when running more than one replica, and grant the
operator get/create/update on coordination.k8s.io leases.

Add a leader-failover workflow to test/orchestratord that verifies the
leases are held by operator pods, that leadership fails over when the
leader pod is deleted and after a rolling restart of the operator
deployment, and that reconciliation completes after both. Enable it in
the Nightly pipeline.

NOTE: this requires a k8s-controller release with leader election
support. The dependency bump lands separately once the library is
released.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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