// This module is included in the following assemblies:
//
// assembly-cruise-control-concepts.adoc

[id='proc-deploying-cruise-control-{context}']
= Deploying Cruise Control

Cruise Control is configured using the `cruiseControl` property in the `Kafka` resource.
Once configured, you can deploy a Cruise Control instance to your {ProductName} cluster by creating or updating the `Kafka` resource.

For an overview of the `Kafka` resource, see the xref:ref-sample-kafka-resource-config-deployment-configuration-kafka[sample Kafka YAML configuration].

You can configure `cruiseControl` properties as part of a deployment or redeployment of a Kafka cluster.
Deploy one instance of Cruise Control per Kafka cluster.

This procedure uses the following example file provided with {ProductName}:

* `examples/cruise-control/cruise-control-topic.yaml`

This creates a `strimzi.cruisecontrol.metrics` topic in your Kafka cluster, which collects information from the Cruise Control Metrics Reporter for use in generating rebalance proposals.
You do not need to interact with this topic after Cruise Control is deployed.

.Prerequisites

* A Kubernetes cluster
* A running Cluster Operator

.Procedure

. Create the Cruise Control metrics topic in your Kafka cluster:
+
[source,shell,subs="attributes+"]
----
kubectl apply -f examples/cruise-control/cruise-control-topic.yaml
----

. Edit the `cruiseControl` property of the `Kafka` resource.
+
The properties you can configure are shown in this example configuration:
+
[source,yaml,subs="attributes+"]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  # ...
  cruiseControl:
    capacity: <1>
      networkIn: 10000KB/s
      networkOut: 10000KB/s
      # ...
    config: <2>
      default.goals: >
         com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal,
         com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaCapacityGoal
         # ...
      goals: {}
      cpu.balance.threshold: 1.1
      metadata.max.age.ms: 300000
      send.buffer.bytes: 131072
      # ...
    resources: <3>
      requests:
        cpu: 200m
        memory: 64Mi
      limits:
        cpu: 500m
        memory: 128Mi
    logging: <4>
        type: inline
        loggers:
          cruisecontrol.root.logger: "INFO"
    template: <5>
      pod:
        metadata:
          labels:
            label1: value1
        securityContext:
          runAsUser: 1000001
          fsGroup: 0
        terminationGracePeriodSeconds: 120
    readinessProbe: <6>
      initialDelaySeconds: 15
      timeoutSeconds: 5
    livenessProbe: <7>
      initialDelaySeconds: 15
      timeoutSeconds: 5
# ...
----
<1> Specifies capacity limits for broker resources. For more information, see xref:capacity_configuration[Capacity configuration].
<2> Defines the Cruise Control configuration, including default and enabled optimization goals. You can provide any xref:ref-cruise-control-configuration-{context}[standard configuration option] apart from those managed directly by {ProductName}.
<3> CPU and memory resources reserved for Cruise Control. For more information, see xref:assembly-resource-limits-and-requests-deployment-configuration-kafka[].
<4> Defined loggers and log levels added directly (inline) or indirectly (external) through a ConfigMap. A custom ConfigMap must be placed under the log4j.properties key. Cruise Control has a single logger called cruisecontrol.root.logger. You can set the log level to INFO, ERROR, WARN, TRACE, DEBUG, FATAL or OFF. For more information, see xref:logging_configuration[Logging configuration].
<5> xref:assembly-customizing-deployments-str[Customization of deployment templates and pods].
<6> xref:assembly-healthchecks-deployment-configuration-kafka[Healthcheck readiness probes].
<7> xref:assembly-healthchecks-deployment-configuration-kafka[Healthcheck liveness probes].

. Create or update the resource:
+
[source,shell,subs="+quotes"]
----
kubectl apply -f _kafka.yaml_
----

. Verify that Cruise Control was successfully deployed:
+
[source,shell,subs="+quotes"]
----
kubectl get deployments -l app.kubernetes.io/name=strimzi
----

.What to do next
After configuring and deploying Cruise Control, you can xref:proc-generating-optimization-proposals-{context}[generate optimization proposals]. 

.Additional resources

xref:type-CruiseControlTemplate-reference[].