// 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 `failure-domain.beta.kubernetes.io/zone` that can be easily used as the `topologyKey` value.
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: failure-domain.beta.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[].
