// 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 {ProductPlatformName} cluster nodes.
The label is used by {ProductPlatformName} when scheduling the Kafka broker pods to nodes.
If the {ProductPlatformName} 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

* An {ProductPlatformName} cluster
* A running Cluster Operator

.Procedure

. Consult your {ProductPlatformName} administrator regarding the node label that represent 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.
+
ifdef::Kubernetes[]
On {KubernetesName} this can be done using `kubectl apply`:
[source,shell,subs=+quotes]
kubectl apply -f _your-file_
+
endif::Kubernetes[]
On {OpenShiftName} this can be done using `oc apply`:
+
[source,shell,subs=+quotes]
oc 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[].
