// This assembly is included in the following assemblies:
//
// deploying/assembly-deploy-kafka-cluster.adoc

[id='assembly-kraft-mode-{context}']
= Using Kafka in KRaft mode

[role="_abstract"]
KRaft (Kafka Raft metadata) mode replaces Kafka's dependency on ZooKeeper for cluster management. 
KRaft mode simplifies the deployment and management of Kafka clusters by bringing metadata management and coordination of clusters into Kafka.

Kafka in KRaft mode is designed to offer enhanced reliability, scalability, and throughput.
Metadata operations become more efficient as they are directly integrated.
And by removing the need to maintain a ZooKeeper cluster, there's also a reduction in the operational and security overhead.

To deploy a Kafka cluster in KRaft mode, you must use `Kafka` and `KafkaNodePool` custom resources.
The `Kafka` resource using KRaft mode must also have the annotations `strimzi.io/kraft: enabled` and `strimzi.io/node-pools: enabled`.
For more details and examples, see xref:deploying-kafka-cluster-kraft-{context}[].

Through xref:config-node-pools-{context}[node pool configuration using `KafkaNodePool` resources], nodes are assigned the role of broker, controller, or both:

* *Controller* nodes operate in the control plane to manage cluster metadata and the state of the cluster using a Raft-based consensus protocol.
* *Broker* nodes operate in the data plane to manage the streaming of messages, receiving and storing data in topic partitions.
* *Dual-role* nodes fulfill the responsibilities of controllers and brokers.

Controllers use a metadata log, stored as a single-partition topic (`__cluster_metadata`) on every node, which records the state of the cluster. 
When requests are made to change the cluster configuration, an active (lead) controller manages updates to the metadata log, and follower controllers replicate these updates. 
The metadata log stores information on brokers, replicas, topics, and partitions, including the state of in-sync replicas and partition leadership. 
Kafka uses this metadata to coordinate changes and manage the cluster effectively.

Broker nodes act as observers, storing the metadata log passively to stay up-to-date with the cluster's state.
Each node fetches updates to the log independently.

NOTE: The KRaft metadata version used in the Kafka cluster must be supported by the Kafka version in use. 
Both versions are managed through the `Kafka` resource configuration.
For more information, see xref:con-config-kafka-kraft-{context}[].

In the following example, a Kafka cluster comprises a quorum of controller and broker nodes for fault tolerance and high availability. 

.Example cluster with separate broker and controller nodes
image::kraft-single-role-quorum.png[KRaft quorums for broker and controller]

In a typical production environment, use dedicated broker and controller nodes. 
However, you might want to use nodes in a dual-role configuration for development or testing.

You can use a combination of nodes that combine roles with nodes that perform a single role.
In the following example, three nodes perform a dual role and two nodes act only as brokers. 

.Example cluster with dual-role nodes and dedicated broker nodes
image::kraft-dual-role-quorum.png[KRaft cluster with nodes that combine roles]

== KRaft limitations

Currently, the KRaft mode in Strimzi has the following major limitations:

* Scaling of KRaft controller nodes up or down is not supported.

NOTE: If you are using JBOD storage, you can xref:ref-jbod-storage-str[change the volume that stores the metadata log]. 

//migrating to KRaft
include::../../modules/deploying/proc-deploy-migrate-kraft.adoc[leveloffset=+1]