10.7. Enabling topic management for existing Kafka topics
This procedure describes how to enable topic management for topics that are not currently managed through the KafkaTopic resource. You do this by creating a matching KafkaTopic resource.
You can perform this task if you are using unidirectional topic management.
Prerequisites
Procedure
Create a
KafkaTopicresource with ametadata.namethat is the same as the Kafka topic.Or use
spec.topicNameif the name of the topic in Kafka would not be a legal OpenShift resource name.Example Kafka topic configuration
apiVersion: kafka.strimzi.io/v1beta2 kind: KafkaTopic metadata: name: my-topic-1 labels: strimzi.io/cluster: my-cluster spec: partitions: 10 replicas: 2In this example, the Kafka topic is named
my-topic-1.The Topic Operator checks whether the topic is managed by another
KafkaTopicresource. If it is, the older resource takes precedence and a resource conflict error is returned in the status of the new resource.Apply the
KafkaTopicresource:oc apply -f <topic_configuration_file>Wait for the operator to update the topic in Kafka.
The operator updates the Kafka topic with the
specof theKafkaTopicthat has the same name.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: 1 name: my-topic-1 labels: strimzi.io/cluster: my-cluster spec: partitions: 10 replicas: 2 # ... status: observedGeneration: 11 topicName: my-topic-1 conditions: - type: Ready status: True lastTransitionTime: 20230301T103000Z- 1
- Successful reconciliation of the resource means the topic is now managed.
The value of
metadata.generation(the current version of the deployment) mustmatch status.observedGeneration(the latest reconciliation of the resource).