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.

Procedure

  1. Create a KafkaTopic resource with a metadata.name that is the same as the Kafka topic.

    Or use spec.topicName if 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: 2

    In this example, the Kafka topic is named my-topic-1.

    The Topic Operator checks whether the topic is managed by another KafkaTopic resource. If it is, the older resource takes precedence and a resource conflict error is returned in the status of the new resource.

  2. Apply the KafkaTopic resource:

    oc apply -f <topic_configuration_file>
  3. Wait for the operator to update the topic in Kafka.

    The operator updates the Kafka topic with the spec of the KafkaTopic that has the same name.

  4. Check the status of the KafkaTopic resource to make sure the request was successful:

    oc get kafkatopics my-topic-1 -o yaml

    Example topic with a Ready status

    apiVersion: 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: 1 
    1
    
      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) must match status.observedGeneration (the latest reconciliation of the resource).

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部