// This assembly is included in the following assemblies:
//
// deploying.adoc

[id='assembly-reassign-tool-{context}']
= Using the partition reassignment tool

[role="_abstract"]
When scaling a Kafka cluster, you may need to add or remove brokers and update the distribution of partitions or the replication factor of topics. 
To update partitions and topics, you can use the `kafka-reassign-partitions.sh` tool.

Neither the Strimzi Cruise Control integration nor the Topic Operator support changing the replication factor of a topic. 
However, you can change the replication factor of a topic using the `kafka-reassign-partitions.sh` tool.

The tool can also be used to reassign partitions and balance the distribution of partitions across brokers to improve performance.
However, it is recommended to use xref:cruise-control-concepts-str[Cruise Control for automated partition reassignments and cluster rebalancing]. 
Cruise Control can move topics from one broker to another without any downtime, and it is the most efficient way to reassign partitions.

It is recommended to run the `kafka-reassign-partitions.sh` tool as a separate interactive pod rather than within the broker container.
Running the Kafka `bin/` scripts within the broker container may cause a JVM to start with the same settings as the Kafka broker, which can potentially cause disruptions.
By running the `kafka-reassign-partitions.sh` tool in a separate pod, you can avoid this issue.
Running a pod with the `-ti` option creates an interactive pod with a terminal for running shell commands inside the pod.

.Running an interactive pod with a terminal 
[source,shell,subs="+quotes,attributes"]
----
kubectl run helper-pod -ti --image={DockerKafkaImageCurrent} --rm=true --restart=Never -- bash
----

include::../../modules/configuring/con-partition-reassignment.adoc[leveloffset=+1]

include::../../modules/configuring/proc-generating-reassignment-json-files.adoc[leveloffset=+1]

include::../../modules/configuring/proc-scaling-up-a-kafka-cluster.adoc[leveloffset=+1]

include::../../modules/configuring/proc-scaling-down-a-kafka-cluster.adoc[leveloffset=+1]

include::../../modules/configuring/proc-changing-topic-replicas.adoc[leveloffset=+1]
