// Module included in the following assemblies:
//
// deploying/assembly_deploy-kafka-cluster.adoc

[id='deploying-the-topic-operator-using-the-cluster-operator-{context}']
= Deploying the Topic Operator using the Cluster Operator

[role="_abstract"]
This procedure describes how to deploy the Topic Operator using the Cluster Operator.
The Topic Operator can be deployed for use in either bidirectional mode or unidirectional mode.
To learn more about bidirectional and unidirectional topic management, see xref:ref-operator-topic-{context}[].

NOTE: Unidirectional topic management is available as a preview. 
Unidirectional topic management is not enabled by default, so you must xref:ref-operator-unidirectional-topic-operator-feature-gate-{context}[enable the `UnidirectionalTopicOperator` feature gate] to be able to use it.

You configure the `entityOperator` property of the `Kafka` resource to include the `topicOperator`.
By default, the Topic Operator watches for `KafkaTopic` resources in the namespace of the Kafka cluster deployed by the Cluster Operator.
You can also specify a namespace using `watchedNamespace` in the Topic Operator `spec`.
A single Topic Operator can watch a single namespace.
One namespace should be watched by only one Topic Operator.

If you use Strimzi to deploy multiple Kafka clusters into the same namespace, enable the Topic Operator for only one Kafka cluster or use the `watchedNamespace` property to configure the Topic Operators to watch other namespaces.

If you want to use the Topic Operator with a Kafka cluster that is not managed by Strimzi,
you must xref:deploying-the-topic-operator-standalone-{context}[deploy the Topic Operator as a standalone component].

For more information about configuring the `entityOperator` and `topicOperator` properties,
see xref:ref-kafka-entity-operator-str[Configuring the Entity Operator].

.Prerequisites

* xref:deploying-cluster-operator-str[The Cluster Operator must be deployed.]

.Procedure

. Edit the `entityOperator` properties of the `Kafka` resource to include `topicOperator`:
+
[source,yaml,subs="+quotes,attributes"]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  #...
  entityOperator:
    *topicOperator: {}*
    userOperator: {}
----
. Configure the Topic Operator `spec` using the properties described in the link:{BookURLConfiguring}#type-EntityTopicOperatorSpec-reference[`EntityTopicOperatorSpec` schema reference^].
+
Use an empty object (`{}`) if you want all properties to use their default values.

. Create or update the resource:
+
[source,shell,subs=+quotes]
kubectl apply -f _<kafka_configuration_file>_

. Check the status of the deployment:
+
[source,shell,subs="+quotes"]
----
kubectl get pods -n _<my_cluster_operator_namespace>_
----
+
.Output shows the pod name and readiness
[source,shell,subs="+quotes"]
----
NAME                        READY   STATUS    RESTARTS
my-cluster-entity-operator  3/3     Running   0
# ...
----
+
`my-cluster` is the name of the Kafka cluster.
+
`READY` shows the number of replicas that are ready/expected.
The deployment is successful when the `STATUS` displays as `Running`.
