Chapter 23. Using Cruise Control to reassign partitions on JBOD disks
If you are using JBOD storage and have Cruise Control installed with Streams for Apache Kafka, you can reassign partitions between the JBOD disks used for storage on the same broker. This capability also allows you to remove JBOD disks without data loss.
To reassign partitions, configure a KafkaRebalance resource in remove-disks mode and specify a list of broker IDs with corresponding volume IDs for partition reassignment. Cruise Control generates an optimization proposal based on the configuration and reassigns the partitions when approved manually or automatically.
Use the Kafka kafka-log-dirs.sh tool to check information about Kafka topic partitions and their location on brokers before and after moving them. Use an interactive pod to avoid running the tool within the broker container and causing any disruptions.
Prerequisites
- The Cluster Operator must be deployed.
- Cruise Control is deployed with Kafka.
- Kafka operates in KRaft mode and brokers use JBOD storage.
- More than one JBOD disk must be configured on the broker. For more information on configuring Kafka storage, see Section 10.5, “Configuring Kafka storage”.
In this procedure, we use a Kafka cluster named my-cluster, which is deployed to the my-project namespace with node pools and Cruise Control enabled.
Example Kafka cluster configuration
A node pool named pool-a is configured with three broker replicas that use three JBOD storage volumes. In the procedure, we show how partitions are reassigned from volume 1 and 2 to volume 0.
Example node pool configuration with JBOD storage
Procedure
Run a new interactive pod container using the Kafka image to connect to a running Kafka broker.
oc run --restart=Never --image=registry.redhat.io/amq-streams/kafka-39-rhel9:2.9.3 helper-pod -- /bin/sh -c "sleep 3600"
oc run --restart=Never --image=registry.redhat.io/amq-streams/kafka-39-rhel9:2.9.3 helper-pod -- /bin/sh -c "sleep 3600"Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this procedure, we use a pod named
helper-pod.(Optional) Check the partition replica data on broker 0 by opening a terminal inside the interactive pod and running the Kafka
kafka-log-dirs.shtool:oc exec -n myproject -ti my-cluster-pool-a-0 bin/kafka-log-dirs.sh --describe --bootstrap-server my-cluster-kafka-bootstrap:9092 --broker-list 0,1,2 --topic-list my-topic
oc exec -n myproject -ti my-cluster-pool-a-0 bin/kafka-log-dirs.sh --describe --bootstrap-server my-cluster-kafka-bootstrap:9092 --broker-list 0,1,2 --topic-list my-topicCopy to Clipboard Copied! Toggle word wrap Toggle overflow my-cluster-pool-a-0is the pod name for broker 0. The tool returns topic information for each log directory. In this example, we are restricting the information tomy-topicto show the steps against a single topic. The JBOD volumes used for log directories are mounted at/var/lib/kafka/data-<volume_id>/kafka-log<pod_id>.Example output data for each log directory
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
KafkaRebalanceresource inremove-disksmode, listing the brokers and volume IDs to reassign partitions from. Without specific configuration, the default rebalance goals are used.Example Cruise Control configuration
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this example,
my-rebalancereassigns partitions from volumes with IDs 1 and 2 on broker 0.(Optional) To approve the optimization proposal automatically, set the
strimzi.io/rebalance-auto-approvalannotation totrue:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Apply the
KafkaRebalanceconfiguration. If manually approving, wait for the status of the proposal to move to
ProposalReadybefore approving the changes.Check the summary of the changes in the
KafkaRebalancestatus:oc get kafkarebalance my-rebalance -n my-project -o yaml
oc get kafkarebalance my-rebalance -n my-project -o yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example summary of changes
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe summary only shows the changes after optimization, not the load before optimization.
Annotate the
KafkaRebalanceresource to approve the changes:oc annotate kafkarebalance my-rebalance strimzi.io/rebalance="approve"
oc annotate kafkarebalance my-rebalance strimzi.io/rebalance="approve"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Wait for the status of the proposal to change to
Ready. Use the Kafka
kafka-log-dirs.shtool again to verify data movement.In this example, the log directories for volumes 1 and 2 no longer have partitions assigned to them and volume 0 holds 6 partitions for
my-topic, indicating that the partitions have been successfully reassigned.Example output data following reassignment of partitions
Copy to Clipboard Copied! Toggle word wrap Toggle overflow