Quick revision
The short answer
Kafka 4.0 can neither run with ZooKeeper nor migrate from it, so we first upgrade the 3.7 cluster to the 3.9 bridge release, including inter.broker.protocol.version. Then we provision a three-node KRaft controller quorum formatted with the existing cluster id and the migration flag, roll the brokers with the migration settings, watch the controller copy the metadata and enter dual-write mode, roll the brokers again into pure KRaft mode, and finally roll the controllers without the migration settings, after which ZooKeeper is no longer updated and rollback is impossible. Rollback works until that finalization, through manual steps that get harder once brokers run in KRaft mode, so we rehearse the whole path on staging before upgrading from 3.9 to 4.x.
What to remember
In this answer, we saw that Kafka 4.0 cannot run with or migrate from ZooKeeper, so we upgrade to the 3.9 bridge release first. We then provision a KRaft controller quorum with the existing cluster id in migration mode, roll the brokers so the metadata is copied and dual-written, roll them again into KRaft mode, and finalize by rolling the controllers without ZooKeeper. Rollback works until finalization, getting harder as brokers move to KRaft, so we rehearse the whole path on staging before going on to 4.x.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Kafka 4.0 can neither run with ZooKeeper nor migrate from it, so we first upgrade the 3.7 cluster to the 3.9 bridge release, including inter.broker.protocol.version. Then we provision a three-node KRaft controller quorum formatted with the existing cluster id and the migration flag, roll the brokers with the migration settings, watch the controller copy the metadata and enter dual-write mode, roll the brokers again into pure KRaft mode, and finally roll the controllers without the migration settings, after which ZooKeeper is no longer updated and rollback is impossible. Rollback works until that finalization, through manual steps that get harder once brokers run in KRaft mode, so we rehearse the whole path on staging before upgrading from 3.9 to 4.x.
Why this question is asked
Moving off ZooKeeper is the largest change most Kafka teams will make to a running cluster, and Kafka 4.0 makes it mandatory. The migration is well designed, with a long window in which we can turn back, but it has many steps and each one changes who owns the metadata. Interviewers ask this to see whether we know the actual path, not just that KRaft exists. In this answer, we will see why we go through 3.9, then walk through each phase with what we watch, and finish with exactly how far rollback reaches.
1Why We Go Through a Bridge Release
In Kafka 4.0, ZooKeeper support was removed completely, including the code that migrates from it. So a ZooKeeper cluster cannot be upgraded to 4.x directly. The migration has to happen on a 3.x release that understands both worlds, and 3.9 is the last and most complete of these bridge releases, so it is the normal choice.
The first phase is therefore an ordinary rolling upgrade of the 12 brokers from 3.7 to 3.9 while still on ZooKeeper. As for any ZooKeeper-era upgrade, we keep inter.broker.protocol.version at the old value while rolling, then raise it to 3.9 with a second roll once all brokers run the new binaries. Only then does the migration itself begin.
- Upgrade brokers 3.7 -> 3.9then set
inter.broker.protocol.version=3.9 - Start KRaft controllers in migration modeexisting cluster id
- Roll brokers with the migration flagmetadata copied, dual-write
- Roll brokers into KRaft mode
process.roles=broker - Finalize: roll controllers without ZooKeeperno rollback after this
- Upgrade 3.9 -> 4.xZooKeeper retired
6 steps in order. Play them, or step through them one at a time.
2Phase 1: Provision the Controller Quorum
We add three new KRaft controller nodes. They must belong to the same cluster, so we read the existing cluster id from ZooKeeper and format their storage with it. They are configured to talk to ZooKeeper and to run in migration mode.
We use the static controller.quorum.voters setting here; check the 3.9 notes for which quorum options the migration supports. When the controllers start, they form a quorum and wait, because migration begins only once every broker has registered with them.
3Phase 2: Brokers Join, Metadata Is Copied
We roll the 12 brokers, still in ZooKeeper mode, with new settings: zookeeper.metadata.migration.enable=true, the controller.quorum.voters list, controller.listener.names and the security mapping for the controller listener. Each restarted broker registers with the KRaft controllers.
When all brokers have registered, the active KRaft controller copies the metadata from ZooKeeper into its metadata log and takes over as the cluster's controller. From then on it runs in dual-write mode: every metadata change goes into the KRaft log and is also written back to ZooKeeper. We watch the ZkMigrationState metric on the controllers and the controller log for the message that the migration of metadata from ZooKeeper completed. Topic, ACL and config counts should match what ZooKeeper held before.
4Phase 3: Brokers Move to KRaft Mode
Next we roll the brokers again, this time into pure KRaft mode. Each broker's configuration drops all ZooKeeper settings and the migration flag and gains process.roles=broker and a node.id equal to its old broker.id. After restart, it gets its metadata only from the KRaft controllers.
During this phase we watch the usual rolling-restart gates, UnderReplicatedPartitions back to 0 before the next broker, and the controller quorum health. ZooKeeper still receives dual writes, which keeps the way back open, but each broker that has moved to KRaft mode makes the way back longer, because it would have to be reconfigured and restarted again.
5Phase 4: Finalize, and How Far Rollback Reaches
With every broker in KRaft mode, we roll the controllers one more time, removing zookeeper.metadata.migration.enable and zookeeper.connect. This finalizes the migration: the controllers stop writing to ZooKeeper, and ZooKeeper's copy of the metadata goes stale from that moment. After finalization there is no supported way back, so we do it only after the cluster has run well in KRaft mode for long enough to trust it.
| Phase | Rollback possible? | Effort |
|---|---|---|
| 3.9 upgrade, still ZooKeeper | Yes | Normal binary rollback |
| Controllers provisioned, brokers not yet | Yes | Stop the controllers |
| Dual-write, brokers in ZK mode | Yes | Documented manual steps |
| Some or all brokers in KRaft mode | Yes, harder | Extra broker roll back to ZK mode |
| Controllers finalized | No | ZooKeeper no longer updated |
Rollback before finalization is real but manual and documented step by step: roll the brokers back to ZooKeeper mode, remove the controllers, delete the controller znode so a ZooKeeper-mode broker becomes controller, and roll again without the migration settings. That is why we rehearse the full migration, including a rollback from the dual-write state, on a staging cluster first. Once production is finalized, ZooKeeper can be decommissioned and the cluster upgraded from 3.9 to 4.x with the ordinary KRaft rolling upgrade.
6Follow-up questions
Can we keep using ZooKeeper-based tools during the migration?
Tools that write to ZooKeeper directly must stop before the migration starts, because the KRaft controller becomes the source of truth. Everything should use the admin API through --bootstrap-server, which works before, during and after.
What should we watch most carefully in dual-write mode?
That the controller log shows the migration completed, that metadata counts match, that ZooKeeper writes keep succeeding, since a failure there blocks the way back, and the normal health signals: under-replication, offline partitions and controller quorum state.
Why not build a new KRaft cluster and replicate instead?
That is possible with MirrorMaker 2, but it forces every client to move and to translate offsets. The in-place migration keeps topics, offsets and client addresses unchanged, which is why it is usually the better path.
7Conclusion
In this answer, we saw that Kafka 4.0 cannot run with or migrate from ZooKeeper, so we upgrade to the 3.9 bridge release first. We then provision a KRaft controller quorum with the existing cluster id in migration mode, roll the brokers so the metadata is copied and dual-written, roll them again into KRaft mode, and finalize by rolling the controllers without ZooKeeper. Rollback works until finalization, getting harder as brokers move to KRaft, so we rehearse the whole path on staging before going on to 4.x.
Open with
Kafka 4.0 has no ZooKeeper support at all, including the migration code, so the path goes through a bridge release, normally 3.9. First I would roll the brokers from 3.7 to 3.9 on ZooKeeper and then raise inter.broker.protocol.version to 3.9 with a second roll.
Then, if they want more
Then I provision three KRaft controllers, formatted with the existing cluster id from ZooKeeper, with zookeeper.metadata.migration.enable true, the ZooKeeper connection and a static voters list. Next I roll the brokers, still in ZooKeeper mode, with the migration flag and the controller connection settings.
Once all brokers have registered, the active controller copies the metadata from ZooKeeper and runs in dual-write mode, writing to both. I watch the ZkMigrationState metric, the controller log for the completed migration and that topic and ACL counts match.
Then I roll the brokers again into pure KRaft mode, with process.roles broker, node.id equal to the old broker id and no ZooKeeper settings, using the usual gates on under-replicated partitions. Finally I roll the controllers without the migration flag and ZooKeeper settings, which finalizes it: ZooKeeper is no longer updated and rollback is impossible.
Before that, rollback is possible through documented manual steps that get harder once brokers run in KRaft mode. I would rehearse the whole thing, including a rollback, on staging, and only after finalizing upgrade 3.9 to 4.x.
About this answer
- Last updated
- 13 November 2026
- Versions it names
- Kafka 4.0
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Kafka documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Describe the hands-on path to KRaft: which version you go through, the phases of the...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-operations/cca1433869/