Skip to content

Commit fef5548

Browse files
authored
docs(affinity): updates the pod scheduling section to use node pools (#11803)
Signed-off-by: prmellor <pmellor@redhat.com>
1 parent fc9a02c commit fef5548

9 files changed

+333
-190
lines changed

documentation/assemblies/configuring/assembly-scheduling.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
= Configuring pod scheduling
77

88
[role="_abstract"]
9-
To avoid performance degradation caused by resource conflicts between applications scheduled on the same Kubernetes node, you can schedule Kafka pods separately from critical workloads.
10-
This can be achieved by either selecting specific nodes or dedicating a set of nodes exclusively for Kafka.
9+
To optimize the resilience and performance of your Kafka cluster, you can control how its pods are scheduled across Kubernetes nodes.
10+
Pod scheduling strategies can help you to achieve the following:
11+
12+
* Increase fault tolerance by spreading Kafka pods across different nodes.
13+
* Avoid resource contention by separating pods from critical workloads.
14+
* Maintain resource availability by assigning Kafka pods to nodes with sufficient capacity.
1115

1216
include::../../modules/configuring/ref-affinity.adoc[leveloffset=+1]
1317

documentation/assemblies/configuring/assembly-storage.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ include::../../modules/configuring/con-considerations-for-data-storage.adoc[leve
3737

3838
//KRaft storage
3939
include::../../modules/configuring/con-config-storage-kraft.adoc[leveloffset=+1]
40-
include::../../modules/configuring/proc-managing-storage-node-pools.adoc[leveloffset=+2]
41-
include::../../modules/configuring/proc-managing-storage-affinity-node-pools.adoc[leveloffset=+2]
40+
include::../../modules/configuring/con-config-storage-kraft-metadata.adoc[leveloffset=+1]
41+
include::../../modules/configuring/proc-managing-storage-node-pools.adoc[leveloffset=+1]
42+
include::../../modules/configuring/proc-managing-storage-affinity-node-pools.adoc[leveloffset=+1]
4243
//tiered storage
4344
include::../../modules/configuring/ref-storage-tiered.adoc[leveloffset=+1]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Module included in the following assemblies:
2+
//
3+
// assembly-storage.adoc
4+
5+
[id='con-storing-metadata-log-{context}']
6+
= Configuring KRaft metadata log storage
7+
8+
In KRaft mode, each node (including brokers and controllers) stores a copy of the Kafka cluster's metadata log on one of its data volumes.
9+
By default, the log is stored on the volume with the lowest ID, but you can specify a different volume using the `kraftMetadata` property.
10+
11+
For controller-only nodes, storage is exclusively for the metadata log.
12+
Since the log is always stored on a single volume, using JBOD storage with multiple volumes does not improve performance or increase available disk space.
13+
14+
In contrast, broker nodes or nodes that combine broker and controller roles can share the same volume for both the metadata log and partition replica data, optimizing disk utilization.
15+
They can also use JBOD storage, where one volume is shared for the metadata log and partition replica data, while additional volumes are used solely for partition replica data.
16+
17+
Changing the volume that stores the metadata log triggers a rolling update of the cluster nodes, involving the deletion of the old log and the creation of a new one in the specified location.
18+
If `kraftMetadata` isn't specified, adding a new volume with a lower ID also prompts an update and relocation of the metadata log.
19+
20+
.Example JBOD storage configuration using volume with ID 1 to store the KRaft metadata
21+
[source,yaml,subs="attributes+"]
22+
----
23+
apiVersion: {KafkaApiVersion}
24+
kind: KafkaNodePool
25+
metadata:
26+
name: pool-a
27+
# ...
28+
spec:
29+
storage:
30+
type: jbod
31+
volumes:
32+
- id: 0
33+
type: persistent-claim
34+
size: 100Gi
35+
deleteClaim: false
36+
- id: 1
37+
type: persistent-claim
38+
size: 100Gi
39+
kraftMetadata: shared
40+
deleteClaim: false
41+
# ...
42+
----

documentation/modules/configuring/con-config-storage-kraft.adoc

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// assembly-storage.adoc
44

55
[id='con-config-storage-kraft-{context}']
6-
= Configuring Kafka storage in KRaft mode
6+
= Configuring storage types
77

88
[role="_abstract"]
99
Use the `storage` properties of the `KafkaNodePool` custom resource to configure storage for a deployment of Kafka in KRaft mode.
@@ -208,43 +208,4 @@ Volume IDs cannot be changed once JBOD volumes are created, though you can add o
208208
When adding a new volume to the to the `volumes` array under an `id` which was already used in the past and removed, make sure that the previously used `PersistentVolumeClaims` have been deleted.
209209

210210
Use Cruise Control to reassign partitions when adding or removing volumes.
211-
For information on intra-broker disk balancing, see xref:con-rebalance-{context}[].
212-
213-
[id='con-storing-metadata-log-{context}']
214-
== Configuring KRaft metadata log storage
215-
216-
In KRaft mode, each node (including brokers and controllers) stores a copy of the Kafka cluster's metadata log on one of its data volumes.
217-
By default, the log is stored on the volume with the lowest ID, but you can specify a different volume using the `kraftMetadata` property.
218-
219-
For controller-only nodes, storage is exclusively for the metadata log.
220-
Since the log is always stored on a single volume, using JBOD storage with multiple volumes does not improve performance or increase available disk space.
221-
222-
In contrast, broker nodes or nodes that combine broker and controller roles can share the same volume for both the metadata log and partition replica data, optimizing disk utilization.
223-
They can also use JBOD storage, where one volume is shared for the metadata log and partition replica data, while additional volumes are used solely for partition replica data.
224-
225-
Changing the volume that stores the metadata log triggers a rolling update of the cluster nodes, involving the deletion of the old log and the creation of a new one in the specified location.
226-
If `kraftMetadata` isn't specified, adding a new volume with a lower ID also prompts an update and relocation of the metadata log.
227-
228-
.Example JBOD storage configuration using volume with ID 1 to store the KRaft metadata
229-
[source,yaml,subs="attributes+"]
230-
----
231-
apiVersion: {KafkaApiVersion}
232-
kind: KafkaNodePool
233-
metadata:
234-
name: pool-a
235-
# ...
236-
spec:
237-
storage:
238-
type: jbod
239-
volumes:
240-
- id: 0
241-
type: persistent-claim
242-
size: 100Gi
243-
deleteClaim: false
244-
- id: 1
245-
type: persistent-claim
246-
size: 100Gi
247-
kraftMetadata: shared
248-
deleteClaim: false
249-
# ...
250-
----
211+
For information on intra-broker disk balancing, see xref:con-rebalance-{context}[].

documentation/modules/configuring/proc-dedicated-nodes.adoc

Lines changed: 74 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,56 @@
33
// assembly-scheduling.adoc
44

55
[id='proc-dedicated-nodes-{context}']
6-
= Setting up dedicated nodes and scheduling pods on them
6+
= Configuring pod scheduling for dedicated nodes
7+
8+
[role="_abstract"]
9+
You can dedicate a set of worker nodes exclusively to your Kafka brokers so that no other applications can compete with Kafka for resources on those nodes.
10+
11+
To configure dedicated worker nodes for Kafka pods in a specific pool, combine the following:
12+
13+
Taints:: Apply taints to worker nodes to prevent other pods from being scheduled on them.
14+
Tolerations:: Apply tolerations to Kafka pods to allow them to be scheduled on tainted nodes.
15+
Affinity:: Apply affinity to Kafka pods to schedule them on specifically labeled nodes.
16+
17+
This procedure provides configuration examples for the cluster-wide `Kafka` resource and the pool-specific `KafkaNodePool` resource.
18+
19+
NOTE: If you configure `KafkaNodePool.spec.template`, its settings replace `Kafka.spec.kafka.template` for that node pool.
20+
Properties are not merged.
21+
For more information, see xref:affinity-{context}[Scheduling strategies].
722

823
.Prerequisites
924

10-
* A Kubernetes cluster
11-
* A running Cluster Operator
25+
* xref:deploying-cluster-operator-str[The Cluster Operator must be deployed.]
26+
* Dedicated worker nodes without scheduled workloads
1227

1328
.Procedure
1429

15-
. Select the nodes which should be used as dedicated.
16-
. Make sure there are no workloads scheduled on these nodes.
17-
. Set the taints on the selected nodes:
30+
. Taint and label the dedicated worker nodes to prevent other pods from being scheduled on them and to identify them when scheduling the Kafka pods:
1831
+
19-
This can be done using `kubectl taint`:
20-
[source,shell,subs=+quotes]
21-
kubectl taint node _NAME-OF-NODE_ dedicated=Kafka:NoSchedule
22-
+
23-
. Additionally, add a label to the selected nodes as well.
32+
[source,shell]
33+
----
34+
kubectl taint node <name_of_node> dedicated=kafka:NoSchedule
35+
kubectl label node <name_of_node> dedicated=kafka
36+
----
37+
38+
. Configure `tolerations` and `nodeAffinity` in either your `Kafka` or `KafkaNodePool` custom resource to match the taint and label.
2439
+
25-
This can be done using `kubectl label`:
26-
[source,shell,subs=+quotes]
27-
kubectl label node _NAME-OF-NODE_ dedicated=Kafka
40+
--
41+
* To set a cluster-wide rule, edit the `affinity` property in `spec.kafka.template.pod` of your `Kafka` resource.
42+
* To set a pool-specific rule, edit the `affinity` property in `spec.template.pod` of your `KafkaNodePool` resource.
43+
--
2844
+
29-
. Edit the `affinity` and `tolerations` properties in the resource specifying the cluster deployment.
45+
In both cases, use `nodeSelectorTerms` with `matchExpressions` to specify the key-value label of the nodes you want to schedule pods on.
3046
+
31-
For example:
47+
This example applies a rule to a `Kafka` resource that assigns all its broker pods to run only on nodes that have been tainted and labeled with `dedicated=kafka`.
3248
+
49+
.Example cluster-wide affinity configuration for dedicated nodes
3350
[source,yaml,subs=attributes+]
3451
----
35-
apiVersion: {KafkaApiVersion}
52+
apiVersion: kafka.strimzi.io/v1beta2
3653
kind: Kafka
54+
metadata:
55+
name: my-cluster
3756
spec:
3857
kafka:
3958
# ...
@@ -42,7 +61,7 @@ spec:
4261
tolerations:
4362
- key: "dedicated"
4463
operator: "Equal"
45-
value: "Kafka"
64+
value: "kafka"
4665
effect: "NoSchedule"
4766
affinity:
4867
nodeAffinity:
@@ -52,12 +71,42 @@ spec:
5271
- key: dedicated
5372
operator: In
5473
values:
55-
- Kafka
56-
# ...
74+
- kafka
75+
# ...
5776
----
58-
59-
. Create or update the resource.
6077
+
61-
This can be done using `kubectl apply`:
62-
[source,shell,subs=+quotes]
63-
kubectl apply -f _<kafka_configuration_file>_
78+
This example applies a rule to a `KafkaNodePool` resource named `broker` that assigns its pods to run on dedicated nodes marked with `dedicated=broker-kafka`.
79+
+
80+
.Example node pool-specific affinity configuration for dedicated nodes
81+
[source,yaml,subs=attributes+]
82+
----
83+
apiVersion: {KafkaNodePoolApiVersion}
84+
kind: KafkaNodePool
85+
metadata:
86+
name: broker
87+
labels:
88+
strimzi.io/cluster: my-cluster
89+
spec:
90+
replicas: 3
91+
roles:
92+
- broker
93+
template:
94+
pod:
95+
tolerations:
96+
- key: "dedicated"
97+
operator: "Equal"
98+
value: "kafka"
99+
effect: "NoSchedule"
100+
affinity:
101+
nodeAffinity:
102+
requiredDuringSchedulingIgnoredDuringExecution:
103+
nodeSelectorTerms:
104+
- matchExpressions:
105+
- key: dedicated
106+
operator: In
107+
values:
108+
- broker-kafka
109+
# ...
110+
----
111+
112+
. Apply the changes to your custom resource configuration.

documentation/modules/configuring/proc-scheduling-based-on-other-pods.adoc

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,43 @@
33
// assembly-scheduling.adoc
44

55
[id='configuring-pod-anti-affinity-in-kafka-components-{context}']
6-
= Configuring pod anti-affinity in Kafka components
6+
= Configuring pod anti-affinity against other workloads
77

8-
Pod anti-affinity configuration helps with the stability and performance of Kafka brokers. By using `podAntiAffinity`, Kubernetes will not schedule Kafka brokers on the same nodes as other workloads.
9-
Typically, you want to avoid Kafka running on the same worker node as other network or storage intensive applications such as databases, storage or other messaging platforms.
8+
[role="_abstract"]
9+
To improve stability and performance, you can prevent Kafka pods from running on the same worker nodes as other resource-intensive applications, such as databases.
10+
Configure `podAntiAffinity` so that these workloads are scheduled on separate nodes.
11+
12+
This procedure provides configuration examples for the cluster-wide `Kafka` resource and the pool-specific `KafkaNodePool` resource.
13+
14+
NOTE: If you configure `KafkaNodePool.spec.template`, its settings replace `Kafka.spec.kafka.template` for that node pool.
15+
Properties are not merged.
16+
For more information, see xref:affinity-{context}[Scheduling strategies].
1017

1118
.Prerequisites
1219

13-
* A Kubernetes cluster
14-
* A running Cluster Operator
20+
* xref:deploying-cluster-operator-str[The Cluster Operator must be deployed.]
21+
* The other workloads in your cluster use consistent labels.
1522

1623
.Procedure
1724

18-
. Edit the `affinity` property in the resource specifying the cluster deployment.
19-
Use labels to specify the pods which should not be scheduled on the same nodes.
20-
The `topologyKey` should be set to `kubernetes.io/hostname` to specify that the selected pods should not be scheduled on nodes with the same hostname.
21-
For example:
25+
. Configure `podAntiAffinity` in either the `Kafka` or `KafkaNodePool` resource.
2226
+
23-
[source,yaml,subs=attributes+]
27+
--
28+
* To set a cluster-wide rule, edit the `affinity` property in `spec.kafka.template.pod` of your `Kafka` resource.
29+
* To set a pool-specific rule, edit the `affinity` property in `spec.template.pod` of your `KafkaNodePool` resource.
30+
--
31+
+
32+
In both cases, use a `labelSelector` to identify the application pods you want to keep separate from your Kafka pods and set the `topologyKey` to `"kubernetes.io/hostname"` to prevent pods from being placed on the same host.
33+
+
34+
This example applies a rule to a `Kafka` resource named `my-cluster` that prevents any of its broker pods from running on the same node as pods labeled `postgresql` and `mongodb`.
35+
+
36+
.Example cluster-wide anti-affinity configuration
37+
[source,yaml,subs="+attributes"]
2438
----
2539
apiVersion: {KafkaApiVersion}
2640
kind: Kafka
41+
metadata:
42+
name: my-cluster
2743
spec:
2844
kafka:
2945
# ...
@@ -37,14 +53,41 @@ spec:
3753
- key: application
3854
operator: In
3955
values:
40-
- postgresql
41-
- mongodb
56+
- postgresql
57+
- mongodb
4258
topologyKey: "kubernetes.io/hostname"
43-
# ...
59+
# ...
4460
----
45-
46-
. Create or update the resource.
4761
+
48-
This can be done using `kubectl apply`:
49-
[source,shell,subs=+quotes]
50-
kubectl apply -f _<kafka_configuration_file>_
62+
This example applies a rule to a `KafkaNodePool` resource named `broker` that prevents pods from that pool from running on the same node as pods labeled `postgresql` and `mongodb`.
63+
+
64+
.Example node pool-specific anti-affinity configuration
65+
[source,yaml,subs=attributes+]
66+
----
67+
apiVersion: {KafkaNodePoolApiVersion}
68+
kind: KafkaNodePool
69+
metadata:
70+
name: broker
71+
labels:
72+
strimzi.io/cluster: my-cluster
73+
spec:
74+
replicas: 3
75+
roles:
76+
- broker
77+
template:
78+
pod:
79+
affinity:
80+
podAntiAffinity:
81+
requiredDuringSchedulingIgnoredDuringExecution:
82+
- labelSelector:
83+
matchExpressions:
84+
- key: application
85+
operator: In
86+
values:
87+
- postgresql
88+
- mongodb
89+
topologyKey: "kubernetes.io/hostname"
90+
# ...
91+
----
92+
93+
. Apply the changes to your custom resource configuration.

0 commit comments

Comments
 (0)