// Module included in the following assemblies:
//
// assembly-node-scheduling.adoc

[id='proc-configuring-node-affinity-{context}']
= Configuring node affinity in Kafka components

.Prerequisites

* An {ProductPlatformName} cluster
* A running Cluster Operator

.Procedure

. Label the nodes where {ProductName} components should be scheduled.
+
ifdef::Kubernetes[]
On {KubernetesName} this can be done using `kubectl label`:
[source,shell,subs=+quotes]
kubectl label node _your-node_ node-type=fast-network
+
endif::Kubernetes[]
On {OpenShiftName} this can be done using `oc label`:
+
[source,shell,subs=+quotes]
oc label node _your-node_ node-type=fast-network
+
Alternatively, some of the existing labels might be reused.
. Edit the `affinity` property in the resource specifying the cluster deployment.
For example:
+
[source,yaml,subs=attributes+]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
spec:
  kafka:
    # ...
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
            - matchExpressions:
              - key: node-type
                operator: In
                values:
                - fast-network
    # ...
  zookeeper:
    # ...
----

. 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_
