10.9. Switching between Topic Operator modes
You can switch between topic management modes when upgrading or downgrading Streams for Apache Kafka, or when using the same version of Streams for Apache Kafka, as long as the mode is supported for that version.
Switching from bidirectional to unidirectional topic management mode
Enable the
UnidirectionalTopicOperatorfeature gate.The Cluster Operator deploys the Entity Operator with the Topic Operator in unidirectional topic management mode.
The internal topics that support the Topic Operator running in bidirectional topic management mode are no longer required, so you can delete the
KafkaTopicresources to manage them:oc delete $(oc get kt -n <namespace_name> -o name | grep strimzi-store-topic) \ && oc delete $(oc get kt -n <namespace_name> -o name | grep strimzi-topic-operator)This command deletes the internal topics, which have names starting
strimzi-store-topicandstrimzi-topic-operator.The internal topics for storing consumer offsets and transaction states must be retained in Kafka. So, you must first discontinue their management by the Topic Operator before deleting the
KafkaTopicresources.Discontinue management of the topics:
oc annotate $(oc get kt -n <namespace_name> -o name | grep consumer-offsets) strimzi.io/managed="false" \ && oc annotate $(oc get kt -n <namespace_name> -o name | grep transaction-state) strimzi.io/managed="false"By annotating the
KafkaTopicresources withstrimzi.io/managed="false", you indicate that the Topic Operator should no longer manage those topics. In this case, we are adding the annotation to resources for managing the internal topics with names startingconsumer-offsetsandtransaction-state.When their management is discontinued, delete the
KafkaTopicresources (without deleting the topics inside Kafka):oc delete $(oc get kt -n <namespace_name> -o name | grep consumer-offsets) \ && oc delete $(oc get kt -n <namespace_name> -o name | grep transaction-state)
Switching from unidirectional to bidirectional topic management mode
Disable the
UnidirectionalTopicOperatorfeature gate.The Cluster Operator deploys the Entity Operator with the Topic Operator in bidirectional topic management mode.
The internal topics required by the Topic Operator running in bidirectional topic management mode are created.
Check whether finalizers are being used to control topic deletion. If
KafkaTopicresources are using finalizers, ensure that you do one of the following after making the switch:- Remove all finalizers from topics.
Disable the finalizers by setting the
STRIMZI_USE_FINALIZERSenvironment variable tofalsein the Topic Operatorenvconfiguration.Use the same configuration for a Topic Operator running in a Streams for Apache Kafka-managed cluster or as a standalone deployment.
Disabling topic finalizers in a Streams for Apache Kafka-managed cluster
apiVersion: kafka.strimzi.io/v1beta2 kind: Kafka metadata: name: my-cluster spec: # ... entityOperator: topicOperator: {} userOperator: {} template: topicOperatorContainer: env: - name: STRIMZI_USE_FINALIZERS value: "false" # ...Disabling topic finalizers in a standalone deployment
apiVersion: apps/v1 kind: Deployment metadata: name: strimzi-topic-operator spec: template: spec: containers: - name: STRIMZI_USE_FINALIZERS value: "false" # ...The Topic Operator does not use finalizers in bidirectional mode. If they are retained after making the switch from unidirectional mode, you won’t be able to delete
KafkaTopicand related resources.
After switching between between Topic Operator modes, try creating a topic to make sure the operator is running correctly. For more information, see 第 10.4 节 “Configuring Kafka topics”.