Home > front end >  Change KAFKA_CFG_NUM_PARTITIONS value for a Kafka Topic in kubernetes configuration
Change KAFKA_CFG_NUM_PARTITIONS value for a Kafka Topic in kubernetes configuration

Time:07-01

Currently my application has bitnami container for kafka. I want to change the number of partitions in a topic to three. But I don't know where should I do that. When I go to minikube dashboard, I see that there is a KAFKA_CFG_NUM_PARTITIONS. But I don't know where to define that in my project. I have below files

  1. Chart.yaml which has

    apiVersion: v2 name: infra type: application sources: - https:/examplePorject dependencies: - name: kafka version: 14.x.x respository: https://charts.bitnami.com/bitnami

  2. values.yaml kafka: url: infra-kafka-0.infra-headless:9092

  3. statefulset.yaml

I found that there is a property environment and that defines KAFKA_CFG_NUM_PARTITIONS inside of it.

CodePudding user response:

Apparently, this ENV variable KAFKA_CFG_NUM_PARTITIONS sets the server config num.partitions: https://docs.confluent.io/platform/current/installation/configuration/broker-configs.html#brokerconfigs_num.partitions

Which is the default number of partitions that auto created topics will have.

To increase the number of partitions of an existing topic, you can use the kafka-topics tool:

./bin/kafka-topics.sh --alter --bootstrap-server <kafka>:9092 --topic <topic-name> --partitions <new-num-partitions>

CodePudding user response:

Yes, Pod or Statefulset is where you can edit env vars, but it'll probably also be done in the Helm values file. But that's not going to edit any existing topics

If you want to edit a topic partitions from Kubernetes resources, you'd need to use an Operator such as Strimzi that reads kind: KafkaTopic resource definitions

Otherwise, you'll need to use kafka-topics CLI, as the other answer shows

  • Related