このコンテンツは選択した言語では利用できません。

Chapter 5. Using the Topic Operator


5.1. Topic Operator usage recommendations

  • Be consistent and always operate on KafkaTopic resources or always operate on topics directly. Avoid routinely using both methods for a given topic.
  • When creating a KafkaTopic resource:

    • Remember that the name cannot be changed later.
    • Choose a name for the KafkaTopic resource that reflects the name of the topic it describes.
    • Ideally the KafkaTopic.metadata.name should be the same as its spec.topicName. To do this, the topic name will have to be a valid Kubernetes resource name.
  • When creating a topic:

    • Remember that the name cannot be changed later.
    • It is best to use a name that is a valid Kubernetes resource name, otherwise the operator will have to modify the name when creating the corresponding KafkaTopic.

5.2. Creating a topic

This procedure describes how to create a Kafka topic using a KafkaTopic OpenShift resource.

Prerequisites

  • A running Kafka cluster.
  • A running Topic Operator.

Procedure

  1. Prepare a file containing the KafkaTopic to be created

    An example KafkaTopic

    apiVersion: kafka.strimzi.io/v1alpha1
    kind: KafkaTopic
    metadata:
      name: orders
      labels:
        strimzi.io/cluster: my-cluster
    spec:
      partitions: 10
      replicas: 2
    Copy to Clipboard Toggle word wrap

    Note

    It is recommended to use a topic name that is a valid OpenShift resource name. Doing this means that it is not necessary to set the KafkaTopic.spec.topicName property. In any case the KafkaTopic.spec.topicName cannot be changed after creation.

    Note

    The KafkaTopic.spec.partitions cannot be decreased.

  2. Create the KafkaTopic resource in OpenShift.

    On OpenShift this can be done using oc apply:

    oc apply -f your-file
    Copy to Clipboard Toggle word wrap

Additional resources

5.3. Changing a topic

This procedure describes how to change the configuration of an existing Kafka topic by using a KafkaTopic OpenShift resource.

Prerequisites

  • A running Kafka cluster.
  • A running Topic Operator.
  • An existing KafkaTopic to be changed.

Procedure

  1. Prepare a file containing the desired KafkaTopic

    An example KafkaTopic

    apiVersion: kafka.strimzi.io/v1alpha1
    kind: KafkaTopic
    metadata:
      name: orders
      labels:
        strimzi.io/cluster: my-cluster
    spec:
      partitions: 16
      replicas: 2
    Copy to Clipboard Toggle word wrap

    Tip

    You can get the current version of the resource using oc get kafkatopic orders -o yaml.

    Note

    Changing topic names using the KafkaTopic.spec.topicName variable and decreasing partition size using the KafkaTopic.spec.partitions variable is not supported by Kafka.

    Important

    Increasing spec.partitions for topics with keys will change how records are partitioned, which can be particularly problematic when the topic uses semantic partitioning.

  2. Update the KafkaTopic resource in OpenShift.

    On OpenShift this can be done using oc apply:

    oc apply -f your-file
    Copy to Clipboard Toggle word wrap

Additional resources

5.4. Deleting a topic

This procedure describes how to delete a Kafka topic using a KafkaTopic OpenShift resource.

Prerequisites

  • A running Kafka cluster.
  • A running Topic Operator.
  • An existing KafkaTopic to be deleted.

Procedure

  1. Delete the KafkaTopic resource in OpenShift.

    On OpenShift this can be done using oc:

    oc delete kafkatopic your-topic-name
    Copy to Clipboard Toggle word wrap
    Note

    Whether the topic can actually be deleted depends on the value of the delete.topic.enable Kafka broker configuration, specified in the Kafka.spec.kafka.config property.

Additional resources

トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat