Skip to main content
A follower is a deployment whose every node replicates a primary outside it, typically a deployment in another Kubernetes cluster or region. It is a warm standby: it holds a copy of the data and takes reads, but it never takes writes and never promotes a node of its own. You turn it on with spec.replication in the deployment body.
A follower is never promoted automatically. To take writes on its data, fence it and promote it.

What a follower guarantees

  • Every node, the one KubeBlocks shows as primary included, is a read-only replica of the source. Writes answer READONLY.
  • No node is ever promoted automatically: its replica priority stays 0, and the deployment’s own sentinels stop monitoring it.
  • The deployment’s own sentinels can’t point the replicas anywhere else. replica-read-only can’t be changed in config.server, and replica-priority can’t be set there at all: a value set now would stay after a promotion. REPLICAOF stays available, so you can still promote a node by hand in an emergency.
  • A switchover is refused with 409, since there is no primary to hand over from.
A fenced deployment gives the same guarantees and follows nothing. Its nodes keep their data and take no writes until you tell them otherwise. Fence a deployment when its source is gone, or to stop a former primary taking writes after a region outage.

Requirements

Fencing a deployment needs none of the external domain, the absence of TLS or a reachable source: a fenced deployment connects nowhere.

Create a follower

1

Copy the source's replication password

The follower authenticates to the source as the source’s replication account, kbreplicator by default. Its password is the source’s default account password. Copy it into a Secret in the follower’s namespace:
Leave passwordSecretRef out only for a source without a password: the check before create sends PING with no password then, so a source that asks for one answers 422. Name the Secret even when both deployments share a password.
2

Create the deployment with spec.replication

Point source.host at the source’s primary, by a DNS name the follower’s pods resolve, such as the source’s external DNS record. An IP address is refused, because the API can’t tell whether it is the follower’s own:
3

Check it replicates

Open the deployment’s Pods tab: a note says what the deployment follows, and no pod offers Switchover. Every node reports role slave in INFO replication, with master_host set to the source.
Before it creates anything, the Admin Server runs a short Job in the deployment’s namespace that sends PING to the source as the replication account. A source that doesn’t answer, or refuses the credentials, answers 422 on spec.replication.source with the reason. A Job that can’t run at all answers 503.
source.host names one node. Point it at a name that follows the source’s primary, or re-point the follower after the source fails over. A follower of a node that became a replica still replicates, through that replica.

Fence, re-point and follow again

Changing spec.replication restarts the follower’s nodes straight away, without waiting for the maintenance window: fencing during an outage can’t wait. In the Admin UI, a follower’s Pods tab offers Fence; it asks you to confirm first. Re-pointing and following again are done with the CLI or the API. A fenced deployment keeps source, so following again needs no address. A new source is checked like a create. You can also fence a deployment that runs as a primary, for example a former primary that comes back after a region outage while its standby has taken over. Its nodes keep their data and stop taking writes.
Following a source replaces the deployment’s data with the source’s, so a deployment that runs as a primary can’t start following straight away: fence it first. Writes it took that the source never received are lost when it follows. Back it up while it is fenced if you may need them.

Promote a follower

Promoting gives a fenced deployment a primary of its own: one of its nodes takes writes, the others replicate from it, and spec.replication goes away. It is how a standby takes over when its source is lost for good.
1

Fence the deployment

Or select Fence in the deployment’s Pods tab in the Admin UI.Wait until its nodes have restarted and the deployment is running again. A follower can’t be promoted: its nodes would resync from the source.
2

Fence the source too, if it still runs

In a planned move, or once a lost region comes back, fence the deployment you followed as well. Its sentinels know this deployment’s nodes as its replicas, and would turn the node you promote back into one whenever they can log in to it. Fencing the source makes them forget it: wait until its nodes have restarted and it is running again. Each node asks the sentinels as it starts, so check that none still monitors the source (SENTINEL MASTERS lists nothing on each). Skip this when the source is gone.
3

Promote it

Or POST /api/clusters/{name}/ops/promote, or Promote in the deployment’s Pods tab. It answers 202 with the operation’s name, and 409 for a deployment that isn’t fenced or is being promoted already.
4

Wait for it to finish

The operation runs on the node KubeBlocks shows as primary, node 0 unless it is down:
  1. Every node reports how much of the old source’s data it received. If another node received more, this one catches up from it first, for up to five minutes, so no write any node holds is lost.
  2. The node becomes a writable primary and the others replicate from it. With sentinels, they monitor it and fail it over from then on.
Once the operation succeeds, the Admin Server removes spec.replication. The nodes restart and follow the new primary. The operation shows in the Operations tab, and the audit log records both steps.
While a promotion runs, spec.replication can’t change. A promotion fails while a node doesn’t answer: that node may have received more of the old source’s data than any node that does, and it would lose that part once it follows the new primary. Bring the node back and promote again. If you can’t, and accept losing what only that node received, promote without it: add --allow-unreachable-pods to the CLI command, send {"allowUnreachablePods": true} in the API request’s body, or tick Promote even if a pod doesn’t answer in the dialog. The node follows the new primary when it restarts. A promotion that fails leaves the deployment fenced: the operation puts back what it changed, and spec.replication stays. Read the operation’s log for why, and for anything it couldn’t put back, before you promote it again. It fails rather than guess when a node answers with an error, or when a node promoted by hand is behind another.

Promote a node by hand

For an emergency when the promote operation can’t run, for example while the Admin Server is down. The deployment takes writes within seconds, but it stays fenced in its spec, so the API keeps treating it as fenced. Promote it with the operation afterwards: it accepts the node you promoted.
1

Fence the deployment

Wait until its nodes have restarted and the deployment is running again. Don’t skip this: a node of a follower that restarts later resyncs from the source and drops every write it took after you promoted it. A fenced node that restarts only stops taking writes and keeps its data.
2

Promote the node KubeBlocks shows as primary

That is node 0, or the next node while node 0 is down. The deployment’s primary Service already sends writes to it. Find it:
Then promote it, <primary-pod> being the name that printed:
3

Point every other node at it

For each of the other nodes, <other-pod>:
Until you promote it with the operation:
  • Anything that restarts a node fences it again: a node that moves, a restart, or a change applied in the maintenance window. If that node is the one you promoted, the deployment stops taking writes until you promote one again.
  • The node running as primary keeps the primary role and the primary Service, even if a node with a lower number comes back.
  • The sentinels don’t monitor the deployment, so nothing fails it over if the node you promoted goes down.
  • The Admin UI and API still show the deployment as fenced.

Restore a copy

Slower, but the copy is an ordinary deployment that the API fully manages.
  1. Fence the follower, so its data stops changing.
  2. Back it up.
  3. Restore the backup to a new deployment. A restore doesn’t copy spec.replication, so the new deployment starts as a primary and takes writes.
  4. Point your clients at the new deployment.
The new deployment holds what the follower had received when it was fenced. Writes the source took that never reached the follower aren’t in it.

Limits

  • spec.replication can’t be removed by an update: a deployment stops following by being fenced and promoted.
  • Sharded deployments can’t follow another.
  • TLS between the two Kubernetes clusters isn’t supported yet.