Managing Kafka topics

Editing a Kafka topic

You can modify the configuration of a Kafka topic by using the CLI to customize it.

By using the CLI

You can edit a Kafka topic by using the CLI as follows:

  1. Log in to your Kubernetes cluster as a cluster administrator by setting your kubectl context.
  2. Run the following command to initialize the Event Streams CLI on the cluster:

    kubectl es init
    
  3. Run the following command to edit the configuration of a topic:

    kubectl es topic-update --name <topic-name> --config KEY[=VALUE]
    

    For example, to update a topic called my-topic to have min.insync.replicas as 2:

    kubectl es topic-update --name my-topic --config min.insync.replicas=2
    

    Note: To view all configuration options you can set for topics, run the following help command. For more information about the available configuration options, see creating topics.

    kubectl es topic-update --help
    

Setting topic partitions

Event Streams 11.5.1 icon To optimize data distribution, scalability, and performance, you can configure the number of partitions for a Kafka topic by using the UI or CLI.

Notes:

  • If you are a SCRAM user, you require specific access and permissions to set topic partitions. For more information, see managing access.
  • You cannot set topic partitions when the topic is in any of the following states: Unmanaged, Paused, Pending, or Updating.

By using the UI

To set the number of partitions for Kafka topics by using the UI:

  1. Log in to the Event Streams UI from a supported web browser (see how to determine the login URL for your Event Streams UI).
  2. Click Topics in the primary navigation.
  3. Select a topic from the list, then click Overflow menu icon Overflow menu > Set topic partitions to set the partitions.

By using the CLI

To set the number of partitions for Kafka topics by using the CLI:

  1. Log in to your Kubernetes cluster as a cluster administrator by setting your kubectl context.
  2. Run the following command to initialize the Event Streams CLI on the cluster:

    kubectl es init
    
  3. Run the following command to set the number of topic partitions:

    kubectl es topic-partitions-set -n <topic-name> -p <partition-count>
    

    For example, to update a topic called my-topic to have 5 partitions:

    kubectl es topic-partitions-set -n my-topic -p 5
    

Setting topic replicas

Event Streams 11.5.2 icon To ensure data durability and high availability, you can update the replication factor for a Kafka topic by using the UI or CLI.

Notes:

  • If you are a SCRAM user, you require specific access and permissions to set topic replicas. For more information, see managing access.
  • You cannot set topic replicas when the topic state is not displayed and when the topic is in any of the following states: Unmanaged, Paused, Pending, or Updating.

    In some cases, a topic might not have a custom resource when created directly in Kafka or through Kafka Connect. In these situations, the topic state is not available in the UI and CLI, and you cannot set topic replicas.

  • The Set topic replicas option is only available for topics that have a custom resource defined.

Prerequisite

To set the replication factor, your Event Streams instance must have Cruise Control enabled. For more information, see enabling and configuring Cruise Control.

By using the UI

To set the replication factor for Kafka topics by using the UI:

  1. Log in to the Event Streams UI from a supported web browser (see how to determine the login URL for your Event Streams UI).
  2. Click Topics in the primary navigation.
  3. Select a topic from the list, then click Overflow menu Overflow menu > Set topic replicas to set the replication factor.

By using the CLI

To set the replication factor for Kafka topics by using the CLI:

  1. Log in to your Kubernetes cluster as a cluster administrator by setting your kubectl context.
  2. Run the following command to initialize the Event Streams CLI on the cluster:

    kubectl es init
    
  3. Run the following command to set the replication factor:

    kubectl es topic-replicas-set [--name] <topic-name> --replicas <replica-count>
    

    For example, to update a topic called my-topic to have 3 replicas:

    kubectl es topic-replicas-set --name my-topic --replicas 3
    

Deleting a Kafka topic

To delete a Kafka topic, complete the following steps:

By using the UI

  1. Log in to the Event Streams UI from a supported web browser (see how to determine the login URL for your Event Streams UI).
  2. Click Topics in the primary navigation.
  3. Click Topic Delete button in the Overflow menu overflow menu of the topic you want to delete. The topic is deleted and is removed from the list of topics.

By using the CLI

  1. Log in to your Kubernetes cluster as a cluster administrator by setting your kubectl context.
  2. Run the following command to initialize the Event Streams CLI on the cluster:

    kubectl es init
    
  3. Run the following command to delete a topic:

    kubectl es topic-delete --name <topic-name>