10.6. Managing KafkaTopic resources without impacting Kafka topics
This procedure describes how to convert Kafka topics that are currently managed through the KafkaTopic resource into non-managed topics. This capability can be useful in various scenarios. For instance, you might want to update the metadata.name of a KafkaTopic resource. You can only do that by deleting the original KafkaTopic resource and recreating a new one.
By annotating a KafkaTopic resource with strimzi.io/managed=false, you indicate that the Topic Operator should no longer manage that particular topic. This allows you to retain the Kafka topic while making changes to the resource’s configuration or other administrative tasks.
You can perform this task if you are using unidirectional topic management.
Prerequisites
Procedure
Annotate the
KafkaTopicresource in OpenShift, settingstrimzi.io/managedtofalse:oc annotate kafkatopic my-topic-1 strimzi.io/managed="false"Specify the
metadata.nameof the topic in yourKafkaTopicresource, which ismy-topic-1in this example.Check the status of the
KafkaTopicresource to make sure the request was successful:oc get kafkatopics my-topic-1 -o yamlExample topic with a
ReadystatusapiVersion: kafka.strimzi.io/v1beta2 kind: KafkaTopic metadata: generation: 124 name: my-topic-1 finalizer: strimzi.io/topic-operator labels: strimzi.io/cluster: my-cluster spec: partitions: 10 replicas: 2 # ... status: observedGeneration: 1241 topicName: my-topic-1 conditions: - type: Ready status: True lastTransitionTime: 20230301T103000Z- 1
- Successful reconciliation of the resource means the topic is no longer managed.
The value of
metadata.generation(the current version of the deployment) mustmatch status.observedGeneration(the latest reconciliation of the resource).You can now make changes to the
KafkaTopicresource without it affecting the Kafka topic it was managing.For example, to change the
metadata.name, do as follows:Delete the original
KafkTopicresource:oc delete kafkatopic <kafka_topic_name>-
Recreate the
KafkTopicresource with a differentmetadata.name, but usespec.topicNameto refer to the same topic that was managed by the original
-
If you haven’t deleted the original
KafkaTopicresource, and you wish to resume management of the Kafka topic again, set thestrimzi.io/managedannotation totrueor remove the annotation.