// Module included in the following assemblies:
//
// assembly-kafka-rack.adoc

[id='proc-configuring-kafka-rack-awareness-{context}']
= Configuring rack awareness in Kafka brokers

Kafka rack awareness can be configured in the `rack` property of `Kafka.spec.kafka`.
The `rack` object has one mandatory field named `topologyKey`.
This key needs to match one of the labels assigned to the Kubernetes cluster nodes.
The label is used by Kubernetes when scheduling the Kafka broker pods to nodes.
If the Kubernetes cluster is running on a cloud provider platform, that label should represent the availability zone where the node is running.
Usually, the nodes are labeled with `topology.kubernetes.io/zone` label (or `failure-domain.beta.kubernetes.io/zone` on older Kubernetes versions) that can be used as the `topologyKey` value.
For more information about Kubernetes node labels, see {K8sWellKnownLabelsAnnotationsAndTaints}.
This has the effect of spreading the broker pods across zones, and also setting the brokers' `broker.rack` configuration parameter inside Kafka broker.

.Prerequisites

* A Kubernetes cluster
* A running Cluster Operator

.Procedure

. Consult your Kubernetes administrator regarding the node label that represents the zone / rack into which the node is deployed.
. Edit the `rack` property in the `Kafka` resource using the label as the topology key.
+
[source,yaml,subs=attributes+]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    # ...
    rack:
      topologyKey: topology.kubernetes.io/zone
    # ...
----
+
. Create or update the resource.
+
This can be done using `kubectl apply`:
[source,shell,subs=+quotes]
kubectl apply -f _your-file_

.Additional resources
* For information about Configuring init container image for Kafka rack awareness, see xref:assembly-configuring-container-images-deployment-configuration-kafka[].
