To migrate Kafka from ZooKeeper to KRaft, upgrade every broker to Kafka 3.9.x first and pin inter.broker.protocol.version=3.9. Next, start a KRaft controller quorum with zookeeper.metadata.migration.enable=true, roll the brokers into migration mode, roll them again as KRaft brokers, and finalize by removing the migration flag from the controllers. Only then can you do a normal rolling upgrade to Kafka 4.x. There is no in-place jump from a ZooKeeper cluster to 4.x: Kafka 4.0 removed ZooKeeper mode entirely, and 3.9 is the bridge release.

This guide follows the official KRaft operations docs for 3.9 step by step. It adds the gotchas, metrics and rollback limits that matter when you run it on a production cluster.

Why the 3.9 bridge is mandatory

The 3.9.0 release announcement called 3.9 "the final one in the 3.x line" and the last major release with ZooKeeper mode. Kafka 4.0.0 shipped on March 18, 2025, and its upgrade notes are blunt: "Clusters in ZooKeeper mode have to be migrated to KRaft mode before they can be upgraded to 4.0.x."

As of November 2026, the downloads page lists 4.4.0 (October 22, 2026), 4.3.2 and 4.2.2 as supported releases. Every 3.9.x release, including the final patch 3.9.2 (February 21, 2026), is archived. A ZooKeeper cluster is therefore running unsupported software. The migration is the only way back onto a supported line.

Phase Brokers Metadata owner ZooKeeper writes Can you revert?
Initial All ZK mode ZK controller Yes Nothing to revert
Initial metadata load ZK mode, migration enabled KRaft quorum copies from ZK Yes Yes
Hybrid Mixed ZK and KRaft KRaft controller Yes Yes
Dual-write All KRaft KRaft controller Yes (dual-write) Yes, with two rolls
Finalized All KRaft KRaft controller No No

Preflight checklist

Before you change anything, check these items. Each one comes from the documented limitations or from the 4.0 upgrade notes:

  • Software version. The docs require brokers on 3.9.1 or later, with inter.broker.protocol.version set to 3.9. Use 3.9.2 if you can. It adds alter.config.policy.kraft.compatibility.enable (KIP-1252), which fixes an AlterConfigPolicy inconsistency between ZK and KRaft modes.
  • No metadata version changes mid-migration. Changing the IBP (inter.broker.protocol.version) during the migration "may break the cluster". Set it once, before you start.
  • Unsupported features. JBOD with multiple log directories was only early access in 3.7 (KIP-858). During the migration, any log-directory failure on a multi-directory ZK broker shuts that broker down (KAFKA-16431). Repair disks before you begin.
  • Broker IDs. Each broker needs an explicit, non-negative broker.id that does not exceed reserved.broker.max.id, even if broker.id.generation.enable is on. Controller node.id values must not collide with any existing broker.id, because KRaft brokers and controllers share one ID namespace.
  • The ZooKeeper Security Migration Tool. If you ever ran it, the migration can stall on a malformed /migration znode (KAFKA-19480). The documented workaround is delete /migration in zookeeper-shell.sh.
  • Your 4.x prerequisites. Kafka 4.x brokers, Connect and tools need Java 17. Clients and Streams need Java 11. Brokers and clients must both be 2.1 or newer, because 4.0 removed old protocol API versions (KIP-896). Inventory non-Java clients (librdkafka, Sarama, kafka-python) now, not after the cluster is on 4.x.

Turn on migration logging on the controllers before you start. In 3.9 this still goes in log4j.properties:

log4j.logger.org.apache.kafka.metadata.migration=TRACE

Step 1: Get the cluster onto 3.9.x with a pinned IBP

Do a standard ZooKeeper-mode rolling upgrade to 3.9.2. Restart each broker on the new binaries with the old IBP. Then, after you verify the cluster, set the IBP to 3.9 and do one more roll:

# server.properties on every ZK broker, final state before migration
inter.broker.protocol.version=3.9

You can't downgrade below 2.1 once the IBP moves past it, and you can't change the IBP again until the migration is finalized. Treat this setting as frozen.

Step 2: Provision the KRaft controller quorum

The controllers must use the existing cluster ID. Read it from any broker's meta.properties, or from ZooKeeper:

bin/zookeeper-shell.sh zk1:2181 get /cluster/id

Run three dedicated controllers, or five if you need to survive two failures. The docs recommend against combined broker-and-controller nodes in production. They also estimate that 5 GB of RAM and 5 GB of metadata-log disk is enough for a typical cluster. Here is a controller config for migration, adapted from the official sample to three hosts:

# controller.properties (controller 3000; repeat with 3001, 3002)
process.roles=controller
node.id=3000
listeners=CONTROLLER://ctrl-0.example.com:9093
controller.listener.names=CONTROLLER
controller.quorum.bootstrap.servers=ctrl-0.example.com:9093,ctrl-1.example.com:9093,ctrl-2.example.com:9093

# Enable the migration
zookeeper.metadata.migration.enable=true

# ZooKeeper client configuration (same ensemble and chroot as the brokers)
zookeeper.connect=zk1:2181,zk2:2181,zk3:2181

# Listener the KRaft controller uses to send RPCs to ZK-mode brokers
inter.broker.listener.name=PLAINTEXT

Static or dynamic quorum

This choice is easy to get wrong. Kafka 3.9 introduced dynamic controller quorums (KIP-853). You configure them with controller.quorum.bootstrap.servers, not the older controller.quorum.voters. The docs say a quorum is formatted as dynamic only if controller.quorum.voters is absent and the software is 3.9 or newer. In 3.9 you cannot convert a static quorum to dynamic later. Kafka 4.1 added that upgrade path (kafka-features.sh ... upgrade --feature kraft.version=1, then swap the config key), but start dynamic and skip that step.

The recommended bootstrap is one standalone voter, with the others added afterwards via kafka-metadata-quorum.sh add-controller. To start all three at once, use --initial-controllers. The value must be identical on every controller:

# Run once, then distribute the values
CLUSTER_ID="<id from /cluster/id>"
C0=$(bin/kafka-storage.sh random-uuid)
C1=$(bin/kafka-storage.sh random-uuid)
C2=$(bin/kafka-storage.sh random-uuid)

# On each controller (same --initial-controllers string everywhere)
bin/kafka-storage.sh format --cluster-id "$CLUSTER_ID" \
  --initial-controllers "3000@ctrl-0.example.com:9093:$C0,3001@ctrl-1.example.com:9093:$C1,3002@ctrl-2.example.com:9093:$C2" \
  --config config/kraft/controller.properties

bin/kafka-server-start.sh config/kraft/controller.properties

To make formatting fail outright instead of silently producing a static quorum, add --feature kraft.version=1 on controllers only, never on brokers. Confirm the result before you touch any broker:

bin/kafka-features.sh --bootstrap-controller ctrl-0.example.com:9093 describe
bin/kafka-metadata-quorum.sh --bootstrap-controller ctrl-0.example.com:9093 describe --status

kraft.version with FinalizedVersionLevel: 1 means dynamic. Level 0, or a missing entry, means static.

Step 3: Put the ZK brokers into migration mode

Each broker now needs the migration flag and the information to reach the controllers. Here is the official sample, with your hostnames:

# ZK broker server.properties, migration mode
broker.id=0
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://broker-0.example.com:9092
listener.security.protocol.map=PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT

inter.broker.protocol.version=3.9

zookeeper.metadata.migration.enable=true
zookeeper.connect=zk1:2181,zk2:2181,zk3:2181

controller.quorum.bootstrap.servers=ctrl-0.example.com:9093,ctrl-1.example.com:9093,ctrl-2.example.com:9093
controller.listener.names=CONTROLLER

The controller listener name must also appear in listener.security.protocol.map. A missing entry is a common reason brokers fail to register. Roll the brokers one at a time. Once the last ZK broker restarts with this config, the migration starts on its own. The active controller logs this line at INFO when the metadata copy is complete:

Completed migration of metadata from Zookeeper to KRaft

At this point the KRaft controller is the cluster controller. It still sends UpdateMetadata and LeaderAndIsr RPCs to the brokers, which are still in ZK mode.

Step 4: Restart the brokers as KRaft brokers

Convert each broker's config. Replace broker.id with node.id and keep the same number. Add process.roles=broker, then remove the IBP, the migration flag and all ZooKeeper client settings. If you set control.plane.listener.name, remove it too.

# KRaft broker server.properties
process.roles=broker
node.id=0
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://broker-0.example.com:9092
listener.security.protocol.map=PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT

controller.quorum.bootstrap.servers=ctrl-0.example.com:9093,ctrl-1.example.com:9093,ctrl-2.example.com:9093
controller.listener.names=CONTROLLER

# Only if you use ACLs:
authorizer.class.name=org.apache.kafka.metadata.authorizer.StandardAuthorizer

The authorizer change is mandatory if you used kafka.security.authorizer.AclAuthorizer, which is ZooKeeper-backed. Keep two copies of each broker's properties file: the migration-mode version and the KRaft version. Compare them with a diff tool such as the code difference checker before every restart. Most failed rolls come from a leftover zookeeper.* key or a missing controller listener mapping.

When the last broker comes back in KRaft mode, the cluster is in dual-write. Every broker is KRaft, and the controller still mirrors metadata into ZooKeeper so a rollback stays possible.

Step 5: Finalize

Remove zookeeper.metadata.migration.enable and zookeeper.connect from each controller and restart the controllers one at a time. After that, the controller stops writing to ZooKeeper, and you can decommission the ensemble if nothing else uses it.

The docs note that "some users prefer to wait for a week or two before finalizing the migration". That's a reasonable soak period. You keep paying for ZooKeeper, but you keep a rollback path while KRaft runs real traffic, rebalances and broker restarts.

Metrics and logs to watch

All of these are JMX metrics on the KRaft controllers, as listed in the 3.9 monitoring docs. Graph them in whatever dashboards you already run. Our Grafana vs Datadog comparison covers the trade-offs if you are choosing one.

MBean What it tells you
kafka.controller:type=KafkaController,name=ZkMigrationState 4 = ZK (not started), 2 = PRE_MIGRATION (waiting for brokers), 1 = MIGRATION (metadata copied, some brokers still ZK), 3 = POST_MIGRATION (complete), 0 = NONE (born KRaft)
kafka.controller:type=KafkaController,name=MigratingZkBrokerCount Brokers registered with the controller that are not yet KRaft. Should reach 0 before you finalize
kafka.controller:type=KafkaController,name=ZkWriteBehindLag Records ZooKeeper is behind the metadata log during dual-write (active controller only)
kafka.controller:type=KafkaController,name=ZkWriteSnapshotTimeMs Time to reconcile a full snapshot into ZooKeeper
kafka.controller:type=KafkaController,name=ZkWriteDeltaTimeMs Time to write a metadata delta into ZooKeeper

Also alert on under-replicated and offline partitions throughout. A stuck PRE_MIGRATION almost always means one broker never restarted with the migration config, or it can't reach the controller listener.

Rollback limits

Rollback is possible up to, but not including, finalization. How much work it takes depends on the last step you fully completed:

Last completed step How to revert
Provisioned controllers Deprovision the KRaft quorum. Done
Brokers in migration mode Deprovision the quorum. In zookeeper-shell.sh, compare /controller_epoch with kraft_controller_epoch in /migration, and raise /controller_epoch above it if needed. Then delete /controller, get /migration, delete /migration. Remove the migration and controller-quorum configs from the brokers and roll them
Brokers in KRaft mode First roll: restore broker.id and zookeeper.connect and remove process.roles, but keep zookeeper.metadata.migration.enable=true. Then deprovision the quorum, do the same epoch and znode cleanup, remove the migration configs and roll a second time
Finalized Not possible

The controller-epoch check is new in the docs (KAFKA-20488, October 2026). If the KRaft epoch is higher than ZooKeeper's, a reverted ZK controller elected with a lower epoch can't change partition state. Do the epoch fix and delete /controller immediately after deprovisioning the quorum, because the cluster has no controller in that window.

After finalization: upgrading to Kafka 4.x

Once the cluster runs pure KRaft on 3.9, the 4.x upgrade notes cover "any version 3.3.x through 4.3.0" for 4.4.0, so you can go straight from 3.9 to the current release. Use the ordinary KRaft procedure:

  1. Upgrade the JVM to Java 17 or newer on brokers and controllers.
  2. Roll each node onto the 4.x binaries.
  3. Once behaviour checks out, finalize the feature level:
bin/kafka-features.sh --bootstrap-server broker-0.example.com:9092 upgrade --release-version 4.4

Things that break or change on the way:

  • Metadata downgrade is not supported once you finalize a 4.x metadata version with metadata changes.
  • Logging moved to Log4j2 in 4.0. Convert old log4j.properties files with the log4j-transform-cli tool.
  • Config files moved. The config/kraft/ directory is gone, and all sample configs now live in config/.
  • New defaults on finalize. The KIP-848 consumer rebalance protocol and KIP-890 transaction defense are enabled server-side when you finalize 4.0. Once groups use the new protocol, you can only downgrade to 3.4.1 or newer.
  • Removed configs. Removals include log.message.format.version/message.format.version and the old metrics.jmx.blacklist/whitelist.
  • 4.4 specifics. broker.id is deprecated in favour of node.id (KIP-1232, see the 4.4 upgrade notes). Storage directories are no longer forward-compatible: a broker must be the same version as, or newer than, the kafka-storage tool that formatted it.

Strimzi on Kubernetes

If you run Kafka with Strimzi, the operator drives these steps for you. Timing still matters. Strimzi 0.46.0 removed both ZooKeeper support and KRaft migration support, so you must migrate while on 0.45.x. Enable node pools (strimzi.io/node-pools: enabled) and create a controller-only KafkaNodePool. Then follow the Strimzi migration walkthrough:

kubectl annotate kafka my-cluster strimzi.io/kraft="migration" --overwrite
# watch .status.kafkaMetadataState: KRaftMigration -> KRaftDualWriting -> KRaftPostMigration
kubectl annotate kafka my-cluster strimzi.io/kraft="enabled" --overwrite   # finalize

Setting strimzi.io/kraft="rollback" before finalization reverts to ZooKeeper.

If the reason you're migrating is that Kafka's operational load is too high, compare this effort with a platform change. Our Redpanda vs Kafka guide covers that trade-off. Note that KRaft removes the separate ZooKeeper ensemble, which was the biggest operational gap between the two.

Frequently Asked Questions

Can I upgrade a ZooKeeper-based cluster directly to Kafka 4.x?

No. Kafka 4.0 and later only run in KRaft mode, and the upgrade notes require ZooKeeper clusters to migrate to KRaft first. Upgrade to 3.9.x (3.9.1 or later; 3.9.2 is the final patch), migrate, finalize, then roll to 4.x.

Should I use controller.quorum.voters or controller.quorum.bootstrap.servers?

Use controller.quorum.bootstrap.servers on 3.9. A quorum formatted without controller.quorum.voters on 3.9+ is dynamic (kraft.version=1), so you can add and remove controllers with kafka-metadata-quorum.sh. Static quorums couldn't be converted until Kafka 4.1, so a dynamic quorum saves you a future migration step.

How long does the ZooKeeper to KRaft migration take?

The metadata copy itself runs once the last broker enters migration mode. Most of the elapsed time goes to the two rolling restarts of every broker, plus any soak period before you finalize. The Kafka docs give no duration figures, so time a rehearsal on a staging cluster with production-like partition counts.

Can I roll back after the migration?

Yes, at any point before finalization. The steps depend on how far you got, and late-stage rollbacks need two broker rolls plus manual znode cleanup. Once you remove zookeeper.metadata.migration.enable from the controllers and restart them, there is no path back to ZooKeeper.

Do my clients need to change for KRaft?

Not for the migration itself, because clients talk to brokers, not to ZooKeeper or the controllers. The 4.x upgrade afterwards is the risk. Brokers and clients must both be 2.1 or newer, and any tooling that still uses --zookeeper flags or reads ZooKeeper directly will stop working.

Conclusion

Migrating from ZooKeeper to KRaft is a fixed, well-documented sequence: 3.9.x with a frozen IBP, a dynamic controller quorum, a migration-mode roll, a KRaft roll and a deliberate finalize. The risky parts are configuration drift between rolls, broker ID collisions, and finalizing before KRaft has run real traffic. Watch ZkMigrationState and MigratingZkBrokerCount, rehearse the rollback on staging, and soak in dual-write before you remove ZooKeeper for good. After that, upgrading to Kafka 4.4 is a routine rolling upgrade, apart from the Java 17 and client-version checks.