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:
- Log in to your Kubernetes cluster as a cluster administrator by setting your
kubectl
context. -
Run the following command to initialize the Event Streams CLI on the cluster:
kubectl es init
-
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 havemin.insync.replicas
as2
: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
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
, orUpdating
.
By using the UI
To set the number of partitions for Kafka topics by using the UI:
- Log in to the Event Streams UI from a supported web browser (see how to determine the login URL for your Event Streams UI).
- Click Topics in the primary navigation.
- Select a topic from the list, then click 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:
- Log in to your Kubernetes cluster as a cluster administrator by setting your
kubectl
context. -
Run the following command to initialize the Event Streams CLI on the cluster:
kubectl es init
-
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 have5
partitions:kubectl es topic-partitions-set -n my-topic -p 5
Setting topic replicas
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
, orUpdating
.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:
- Log in to the Event Streams UI from a supported web browser (see how to determine the login URL for your Event Streams UI).
- Click Topics in the primary navigation.
- Select a topic from the list, then click 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:
- Log in to your Kubernetes cluster as a cluster administrator by setting your
kubectl
context. -
Run the following command to initialize the Event Streams CLI on the cluster:
kubectl es init
-
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 have3
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
- Log in to the Event Streams UI from a supported web browser (see how to determine the login URL for your Event Streams UI).
- Click Topics in the primary navigation.
- Click Topic Delete button in the 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
- Log in to your Kubernetes cluster as a cluster administrator by setting your
kubectl
context. -
Run the following command to initialize the Event Streams CLI on the cluster:
kubectl es init
-
Run the following command to delete a topic:
kubectl es topic-delete --name <topic-name>