Writing three availability zones into the Kafka config does not mean the pods land that way. If the controller majority sits in one zone, an anti-affinity selector matches no pods, or the operator shares a node with a broker, a single zone or a single node can stop the cluster. I ran into each of these while moving a KRaft-mode Kafka, run by Strimzi on a production Kubernetes cluster, onto a dedicated node pool. The original goal was to cut cross-zone transfer cost, and the controller placement changed that plan.
Controller quorum
Risk
- A KRaft controller quorum holds only while a majority is alive: two out of three
- Without quorum, reads and writes through existing leaders continue, but metadata changes such as electing new leaders or changing the ISR (In-Sync Replicas) stop
What happened
- The arm machines I used (GCP C4A) were not offered in some zones of the region, so the nodes lived in only two zones
- With two zones, one zone always holds a majority, whatever the placement. I judged that spreading brokers would not raise the number of zone failures the cluster survives. So, to cut transfer cost, I moved the consumers toward one zone first
- Before moving brokers and controllers, I looked up where the controllers were. In every region the controller majority was already in that zone, and in two regions all three were. Consolidating would keep that placement as it was
- I stopped consolidating and decided to spread Kafka across three zones. I also reverted the consumer change. The revert restarted no pods and left consumer lag unchanged
- Three zones bring back cross-zone traffic on replication, produce, and consume. I chose to pay that transfer cost for availability
What to check
- Look up the zone of the node each controller pod runs on. A zone spread set as a preferred rule guarantees nothing
- No zone should hold a controller majority
- Before consolidating placement to save cost, check the controllers first
Broker rack
Risk
- If Kafka does not know each broker’s zone, it ignores zones when assigning replicas. With several brokers per zone, a partition’s replicas can end up in one zone
- With two zones, replication factor 3 and
min.insync.replicas=2put two replicas in one zone. Losing that zone stops writes
What happened
- Using a third zone required nodes in it. The arm machines were not offered there, so I built a dedicated Kafka node pool on x86 machines with one node per zone
- I set each broker’s rack from the node’s zone label. In Strimzi this is
rack.topologyKeyset totopology.kubernetes.io/zoneon the Kafka resource - The same change added the broker-side setting for follower fetching (
RackAwareReplicaSelector). The consumer side came later, separately
What to check
- Whether the number of zones with nodes is at least the replication factor
- Whether every broker has
broker.rack. Query the broker config directly - Whether existing topics have replicas across three racks. Rack applies only to future assignments. Partitions already packed into one zone need a reassignment tool to move
Pod scheduling
Risk
- Even with zone-spread rules, if all pods land on one node, that node takes the brokers and controllers down together
What happened
- In one cluster, three brokers, three controllers, and the operator all ran on a single node. Each node pool had a required zone anti-affinity rule
- The selector was the cause. The rule matched
strimzi.io/name=<cluster>-kafka-broker, but Strimzi labels every Kafka podstrimzi.io/name=<cluster>-kafkaregardless of node pool. Zero pods matched, so the rule blocked nothing. To tell node pools apart, select onstrimzi.io/pool-name - I tried to add a node in the new zone, but the arm machine could not be created because of a stockout (
GCE_STOCKOUT). I switched to an x86 machine and added amd64 to the node arch rule - The disk behind a PV (PersistentVolume) is tied to a zone, so a pod cannot simply move to another zone. I took snapshots and restored them in the other zone. I moved the non-leader controllers first and the leader last, so the quorum lost only one member at a time
- The controllers’ hostname anti-affinity was a preferred rule. With only two zones, a required zone spread leaves the third controller Pending. So the zone spread was preferred, and the hostname spread became preferred with it. As a result, one region had two controllers on one node. Once every zone had a node, I made it required
- Finally I set a required rule that places Kafka pods only on
role=kafkanodes. Several regions share one manifest, so I setstrimzi.io/pause-reconciliationon the Kafka resources and lifted it one region at a time - The required rule has a cost. If a Kafka node is lost, that zone’s broker and controller stay Pending until node auto-repair finishes. Meanwhile the cluster holds on with a quorum of two out of three and an ISR of two. With
min.insync.replicas=2, losing one more stops writes
What to check
- Query pods with the exact anti-affinity selector. If
kubectl get pod -l <selector>returns zero pods, the rule does nothing - The node and zone of each pod. Check the outcome, not the rule
- Whether the controllers’ hostname anti-affinity is required
- The zone of each PV and the zone of the node that will receive its pod
- Whether the machine type is offered in every zone you plan to use, and which machine to switch to on a stockout
Strimzi operator
Risk
- In Strimzi, the operator is what recreates broker and controller pods. Without it, a deleted Kafka pod does not come back
- If the operator shares a node with a broker, draining that node takes both down
What happened
- During a node replacement, most broker gaps were around a minute. Only the broker on the operator’s node was empty for about six minutes. Broker recreation waited until the operator came back up on another node
- Under-replicated partitions rose during that time and returned to zero within ten minutes each time
- I ran two operators. Leader election was already on, so only the one holding the lease works. When its node drains, the other takes over the lease. I gave the operators a required hostname anti-affinity between them
- The nodes the operators could use had no spare room. So I set the rollout to take one pod down before bringing a new one up (
maxSurge 0,maxUnavailable 1). A PDB (PodDisruptionBudget) withminAvailable 1kept both from leaving at once - On 2-vCPU nodes the CPU requests left the operator Pending. Of 1930m allocatable, 193m was left, 7m short of the 200m request. Actual usage over seven days peaked around 55m, so I lowered the requests to 50m
What to check
- Whether the operator runs on a different node from the brokers, with at least two replicas and leader election on
- Whether broker gaps in node replacement logs are even. If one broker’s gap is much longer, look at where the operator was
- On small nodes, compare the sum of requests with allocatable. Set requests to match peak actual usage
Follower fetching
Risk
- Follower fetching cuts cross-zone traffic on the consume path by letting a consumer read from a follower in its own zone
- The cost is delay. A follower receives data and the high watermark later than the leader. If the follower falls behind, the delay grows
What happened
- I added the broker setting first and the consumer-side
client.racklater. Each consumer reads its node’s zone from cloud metadata and setsclient.rackfrom it - I reverted the
client.racksetting once, choosing to prioritize low consumer lag - I put it back the same day, for two reasons. Broker ISR dropouts had been zero since midday, and I judged that the extra delay of reading from a follower was acceptable for these consumers. I accepted that delay in exchange for lower transfer cost
- After the rollout, every consumer had its rack set, the client’s preferred replica switching warning showed zero times, and service metrics were the same as or better than in the period without rack
What to check
- Whether
client.rackis set to the actual zone, from consumer logs or config. If the metadata lookup fails, the consumer reads from the leader without a rack - Broker ISR dropouts and under-replicated partitions. If followers fall behind often, consumers reading from them are the first to lag
- The count of the client’s preferred replica switching warnings
- For lag-sensitive consumers, compare lag before and after over the same time of day
Summary
Spreading across three zones works only when the controller majority, broker rack, pod selectors, and operator placement all follow. If any one of them ends up in one place, a single zone or a single node can stop the cluster. So after every rule change I looked up the node and zone each pod landed on and checked the outcome.
References
- Kafka Cross-Zone Transfer Cost: transfer cost on the produce, replication, and consume paths, how follower fetching works, two-zone placement, and controller quorum
- Kafka Fundamentals and KRaft Mode: replication, ISR, high watermark, and how KRaft works