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

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

= Approving an optimization proposal

You can approve an xref:con-optimization-proposals-{context}[optimization proposal] generated by Cruise Control, if its status is `ProposalReady`.
Cruise Control will then apply the optimization proposal to the Kafka cluster, reassigning partitions to brokers and changing partition leadership.

[CAUTION]
====
*This is not a dry run.* Before you approve an optimization proposal, you must:

* 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

Perform these steps for the optimization proposal that you want to approve:

. 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, refresh the optimization proposal to make sure it uses the latest cluster metrics:

.. Annotate the `KafkaRebalance` resource in Kubernetes with `refresh`:
+
[source,shell,subs="+quotes"]
----
kubectl annotate kafkarebalance _rebalance-cr-name_ strimzi.io/rebalance=refresh
----

.. Check the status of the `KafkaRebalance` resource:
+
[source,shell,subs="+quotes"]
----
kubectl describe kafkarebalance _rebalance-cr-name_
----

.. Wait until the status changes to `ProposalReady`.

. Approve the optimization proposal that you want Cruise Control to apply.
+
Annotate the `KafkaRebalance` resource in Kubernetes:
+
[source,shell,subs="+quotes"]
----
kubectl annotate kafkarebalance _rebalance-cr-name_ strimzi.io/rebalance=approve
----

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

. Check the status of the `KafkaRebalance` resource:
+
[source,shell,subs="+quotes"]
----
kubectl describe kafkarebalance _rebalance-cr-name_
----

. Cruise Control returns one of three statuses:

** Rebalancing: The cluster rebalance operation is in progress. 

** Ready: The cluster rebalancing operation completed successfully. The `KafkaRebalance` custom resource cannot be reused.

** NotReady: An error occurred--see xref:proc-fixing-problems-with-kafkarebalance-{context}[].  

.Additional resources

* xref:con-optimization-proposals-{context}[]

* xref:proc-stopping-cluster-rebalance-{context}[] 