:_mod-docs-content-type: PROCEDURE

// Module included in the following assemblies:
//
// assembly-cruise-control-concepts.adoc

[id='proc-approving-optimization-proposal-{context}']

= Running an optimized cluster rebalance

[role="_abstract"]
You can approve an xref:con-optimization-proposals-{context}[optimization proposal] generated by Cruise Control when its status is `ProposalReady`.
Cruise Control then rebalances the Kafka cluster based on the configured optimization goals and the latest cluster state.

Perform the following steps to approve an optimization proposal and run a cluster rebalance.

CAUTION: *This action triggers a cluster rebalance.*
The optimization proposal is a snapshot of the expected impact of the rebalance operation on the Kafka cluster.
When you approve a proposal, Cruise Control re-evaluates the cluster state and may recompute the optimization before executing the rebalance.

Before you approve an optimization proposal, do the following:

* Refresh the proposal in case it has become out of date.
* Carefully review the xref:contents-optimization-proposals[contents of the proposal].

.Prerequisites

* You have xref:proc-generating-optimization-proposals-{context}[generated an optimization proposal] from Cruise Control.

* The `KafkaRebalance` custom resource status is `ProposalReady`.

.Procedure

. Unless the optimization proposal is newly generated, check that it is based on current information about the state of the Kafka cluster.
To do so, annotate the `KafkaRebalance` resource to refresh the optimization proposal and make sure it uses the latest cluster metrics:
+
[source,shell]
----
kubectl annotate kafkarebalance <kafka_rebalance_resource_name> strimzi.io/rebalance="refresh"
----

. Wait for the status of the optimization proposal to change to `ProposalReady`:
+
[source,shell]
----
kubectl get kafkarebalance -o wide -w -n <namespace>
----
+
--
`PendingProposal`:: A `PendingProposal` status means the rebalance operator is polling the Cruise Control API to check if the optimization proposal is ready.
`ProposalReady`:: A `ProposalReady` status means the optimization proposal is ready for review and approval.
--
+
When the status changes to `ProposalReady`, the optimization proposal is ready for review and approval.

. Annotate the `KafkaRebalance` resource to approve the optimization proposal:
+
[source,shell]
----
kubectl annotate kafkarebalance <kafka_rebalance_resource_name> strimzi.io/rebalance="approve"
----

. The Cluster Operator detects the annotated resource and instructs Cruise Control to rebalance the Kafka cluster.

. Wait for the status of the optimization proposal to change to `Ready`:
+
[source,shell]
----
kubectl get kafkarebalance -o wide -w -n <namespace>
----
+
--
`Rebalancing`:: A `Rebalancing` status means the rebalancing is in progress.
`Ready`:: A `Ready` status means the rebalance is complete.
`NotReady`:: A `NotReady` status means an error occurred--see xref:proc-fixing-problems-with-kafkarebalance-{context}[Fixing problems with a `KafkaRebalance` resource].
--
+
When the status changes to `Ready`, the rebalance is complete.
+
To use the same `KafkaRebalance` custom resource to generate another optimization proposal, apply the `refresh` annotation to the custom resource.
This moves the custom resource to the `PendingProposal` or `ProposalReady` state. You can then review the optimization proposal and approve it, if desired.

[role="_additional-resources"]
.Additional resources
* xref:con-optimization-proposals-{context}[]
* xref:proc-stopping-cluster-rebalance-{context}[]
