Request icon
Script icon
If icon
SlackIncomingWebhook icon
Fail icon
LoopUntil icon
Set icon
Pause icon

Roll an etcd Cluster Member to New Infrastructure with a Health-Verified Promotion

Roll an etcd cluster member to new infrastructure via etcd's own learner mechanism, with verified promotion and read-back of the final state.

Categories
Infrastructure

Replacing an etcd cluster member (new hardware, an OS upgrade, a cloud migration) is dangerous to do by hand: add the replacement as a full voter too early and a cluster that was tolerating one failure can lose quorum outright if the new member is still empty when something else hiccups. etcd's own answer is the raft learner: a non-voting member that replicates the log without ever counting toward quorum, promoted to a full voter only once it has genuinely caught up. This blueprint drives that exact mechanism end to end - add as a learner, poll its real raft applied index against the cluster's committed index until it is caught up (removing the learner if it never does), promote only after a human approves, remove the old member, then read the membership list back to confirm the outcome instead of trusting the API calls' response codes.

How it works

  1. inspect_existing_members (io.kestra.plugin.core.http.Request) calls etcd's real v3 JSON gateway POST /v3/cluster/member/list.
  2. evaluate_old_member_exists (io.kestra.plugin.scripts.python.Script) refuses to proceed unless old_member_name is found and is itself a full voter, not a learner.
  3. evaluate_preflight_gate (io.kestra.plugin.core.flow.If) stops with a Slack alert and io.kestra.plugin.core.execution.Fail before anything is added if that check fails.
  4. add_learner_member calls POST /v3/cluster/member/add with IsLearner: true - confirmed from etcd's own MemberAddRequest and a real passing e2e test's exact request casing - the only mutation in this flow that can never cost the cluster quorum.
  5. poll_until_learner_caught_up (io.kestra.plugin.core.flow.LoopUntil) polls POST /v3/maintenance/status against the existing cluster and the new learner's own client URL, reading raftIndex and raftAppliedIndex - confirmed from etcd's StatusResponse. The learner's client URL is only reachable once the operator starts its etcd process with --initial-cluster-state=existing, which happens after add_learner_member registers it, so the inner script tolerates the learner being unreachable on early iterations instead of failing outright.
  6. evaluate_catchup_timeout_gate (io.kestra.plugin.core.flow.If) detects that the loop above exited on learner_catchup_max_wait rather than on reaching max_raft_index_lag, and removes the never-promoted learner via POST /v3/cluster/member/remove before failing, rather than leaving a stuck learner registered indefinitely.
  7. save_rolling_replacement_plan_kv (io.kestra.plugin.core.kv.Set) persists the captured plan before anything irreversible happens.
  8. pause_for_operator_approval (io.kestra.plugin.core.flow.Pause) waits indefinitely for a human to review the caught-up learner.
  9. promote_learner_to_voter calls POST /v3/cluster/member/promote, then remove_old_member calls POST /v3/cluster/member/remove - confirmed from etcd's own MemberPromoteRequest/MemberRemoveRequest.
  10. verify_final_membership reads the membership list back and evaluate_final_verification confirms the new member is a full voter (isLearner: false) and the old member's ID no longer appears at all, rather than trusting the promote/remove calls' HTTP status codes.
  11. evaluate_outcome alerts Slack with the specific verification failure if the final state does not match, or confirms the verified outcome if it does.
  12. The errors block alerts Slack separately if the flow itself fails outright, naming that a learner may already be sitting in the cluster unpromoted.

What you get

  • A member replacement that never risks quorum, because the new member only ever joins as a non-voting learner until it is proven caught up.
  • A real, computed readiness gate (raft applied index lag against the cluster's committed index), polled on an interval up to learner_catchup_max_wait instead of a single check or a fixed sleep.
  • Automatic cleanup of a learner that is never started or never catches up, instead of leaving an orphaned learner registered against the cluster.
  • A human approval gate between "the learner is caught up" and "the old member is gone for good."
  • A read-back verification of the final membership list, naming exactly which part failed (new member not a full voter, or old member still present) rather than trusting 200 OK responses.
  • A full KV audit record of the old and new member IDs and the lag at the moment of approval.

Who it's for

  • Platform and SRE teams rolling etcd clusters that back Kubernetes or their own services onto new infrastructure (cloud migration, instance type change, OS upgrade) without a maintenance window where quorum is at risk.
  • Anyone who has manually run etcdctl member add / member promote / member remove by hand and wants the same sequence with a real caught-up check and an audit trail instead of "wait a bit and hope."

Why orchestrate this with Kestra

etcd's HTTP API can add, promote, and remove members, but it has no concept of "wait until genuinely caught up," no approval gate between those calls, and no record of what was done and why. Kestra supplies the lag-based readiness gate as a first-class branch, the KV-backed audit record, the human approval pause, and a visible execution history proving the read-back verification actually happened, all driven off etcd's own real, documented API surface.

Prerequisites

  • An existing etcd v3 cluster reachable at cluster_client_url.
  • Do not start the new member's etcd process before running this flow. add_learner_member must register the member in the cluster first; only then can the operator start its etcd process with --initial-cluster-state=existing and this cluster's peer URLs (including itself) in --initial-cluster. new_member_client_url is unreachable until that process is started, which is expected and why poll_until_learner_caught_up tolerates it. This blueprint only drives the cluster-membership API calls, it does not provision or start the new infrastructure.
  • Network access from the Kestra worker to both cluster_client_url and new_member_client_url.

Secrets

  • ETCD_AUTH_TOKEN: an etcd v3 auth token sent as the Authorization header on every call in this flow. Leave unset if the target cluster has authentication disabled.
  • SLACK_WEBHOOK_URL: Slack incoming webhook used by every alert in this flow.
  • In Kestra OSS (no Enterprise secrets backend), secrets are supplied as environment variables prefixed SECRET_, base64-encoded, and read back in flows with {{ secret('NAME') }}.

Inputs

  • cluster_client_url (STRING, no default): client URL of any existing, healthy member.
  • new_member_peer_url / new_member_client_url (STRING, no default): the new member's peer and client URLs.
  • old_member_name (STRING, no default): the existing member's --name to be replaced and removed.
  • max_raft_index_lag (INT, default 10): maximum acceptable raft applied-index lag before promotion is allowed.
  • learner_catchup_max_wait (STRING, default PT30M): ISO-8601 duration to poll for the learner to become reachable and catch up before removing it and failing.

Outputs

  • outputs.new_member_id / outputs.verified: the new member's ID and whether the final membership read-back confirmed success.

Quick start

  1. Add the ETCD_AUTH_TOKEN (if auth is enabled) and SLACK_WEBHOOK_URL secrets.
  2. Run the flow manually. Once add_learner_member has executed, start the new member's etcd process with this cluster already listed in its --initial-cluster (including itself) and --initial-cluster-state=existing - poll_until_learner_caught_up is now waiting for exactly this.
  3. Confirm poll_learner_catch_up eventually reports caught_up: true within learner_catchup_max_wait (if it times out, the learner is removed automatically and the execution fails - check that the etcd process was actually started, then re-run from the top).
  4. Resume pause_for_operator_approval and confirm evaluate_final_verification reports verified: true.
  5. Decommission the old member's infrastructure only after verified: true is confirmed.

How to extend

  • Loop this flow over every member of a cluster, one at a time, to roll an entire cluster onto new infrastructure with each step gated on the previous one's verified completion.
  • Extend the preflight check to also refuse the roll if the cluster currently has any unhealthy member (via /v3/maintenance/status's errors field), since starting a roll on an already-degraded cluster compounds the risk.

Pitfalls

  • This blueprint does not start or provision the new member's etcd process. The operator must start it manually, with --initial-cluster-state=existing, after add_learner_member runs and while poll_until_learner_caught_up is waiting; this blueprint only drives the membership API calls and the promotion decision.
  • max_raft_index_lag: 0 may never be satisfied on a cluster under continuous write load, since the committed index keeps advancing while the comparison is being made. A small nonzero value (the default 10) tolerates that without meaningfully weakening the safety check.
  • learner_catchup_max_wait must comfortably exceed how long the new member takes to replicate the existing data set, not just how long it takes to start the etcd process. A value that is too short removes a learner that was still legitimately catching up.
  • This flow never auto-retries a failed promotion or removal. If evaluate_final_verification reports verified: false, the fix is to inspect /v3/cluster/member/list directly and resolve the specific gap by hand, not to re-run this flow blindly, since a partially-applied roll (for example a learner promoted but the old member removal failing) needs a human to confirm the cluster's actual state first.
  • Removing the old member here does not stop or decommission its etcd process. If that process keeps running after removal from the cluster's membership, it will log errors trying to participate in a cluster it is no longer a member of; stopping it is a separate, deliberate step outside this flow.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.