rpk cluster partitions transfer-leadership
Transfer partition leadership between brokers.
This command allows you to transfer partition leadership. You can transfer only one partition leader at a time.
To transfer partition leadership, use the following syntax:
rpk cluster partitions transfer-leadership foo --partition 0:2.
Here, the command transfers leadership for the partition kafka/foo/0
to broker 2. By default, it assumes the kafka namespace, but you can specify
an internal namespace using the {namespace}/ prefix.
Here is an equivalent command using different syntax:
rpk cluster partitions transfer-leadership --partition foo/0:2.
| Redpanda tries to balance leadership distribution across brokers by default. If the distribution of leaders becomes uneven as a result of transferring leadership across brokers, the cluster may move leadership back to the original brokers automatically. |
Examples
This section provides examples of how to use rpk cluster partitions transfer-leadership.
To transfer partition leadership for a partition 0 to a broker ID 2, run.
rpk cluster partitions transfer-leadership foo --partition 0:2
The --partition flag accepts a value <A>:<B>, where A is a topic-partition and B is the ID of the broker to which you want to transfer leadership. To specify a topic-partition, you can use just the partition ID (0) or also use the topic name together with the partition using the following syntax.
rpk cluster partitions transfer-leadership --partition test-topic/0:2
Flags
| Value | Type | Description |
|---|---|---|
|
string |
Output format ( |
|
string |
Topic-partition and target leader in the format |
Global flags
| Value | Type | Description |
|---|---|---|
|
string |
Redpanda or |
|
stringArray |
Override |
|
bool |
Ignore |
|
string |
|
|
bool |
Enable verbose logging. |