How to work with the Kafka CLI and KafScale
The Kafka CLI
Apache Kafka ships shell scripts in its bin/ directory: kafka-topics.sh, kafka-console-producer.sh, kafka-console-consumer.sh, kafka-consumer-groups.sh, kafka-configs.sh, kafka-get-offsets.sh and more. They use the same Java client as Kafka applications. Most Kafka operators reach for them first. You get them from the Apache Kafka download or the apache/kafka container image.
Before you start
- A KafScale v2.2.0 cluster with the proxy enabled. Clients connect to the proxy at
proxy.advertisedHostandproxy.advertisedPortfrom your Helm values. - The Apache Kafka CLI. This guide was tested with Apache Kafka 4.3.1 against KafScale v2.2.0 with 2 brokers and 2 proxy replicas.
Set the proxy address once:
export BOOTSTRAP=kafka.example.com:9092
The examples call the scripts by name. In the container image, they live in /opt/kafka/bin/.
Try it yourself
1. Create a topic
kafka-topics.sh --bootstrap-server "$BOOTSTRAP" --create --topic orders
Created topic orders.
You can leave out --partitions and --replication-factor. The partition count comes from KAFSCALE_AUTO_CREATE_PARTITIONS (1 if unset or not positive). The replication factor is 1, because S3 provides durability. You can still pass both:
kafka-topics.sh --bootstrap-server "$BOOTSTRAP" --create --topic orders-eu \
--partitions 3 --replication-factor 1
At create time you can set retention.ms, retention.bytes and segment.bytes with --config:
kafka-topics.sh --bootstrap-server "$BOOTSTRAP" --create --topic orders-cfg \
--config retention.ms=86400000 --config segment.bytes=1048576
Any other key is rejected with INVALID_CONFIG. KafScale has no log compaction, so cleanup.policy=compact fails:
Error while executing topic command : cleanup.policy=compact is not supported; KafScale has no log compaction:
List, add partitions, delete and describe:
kafka-topics.sh --bootstrap-server "$BOOTSTRAP" --list
kafka-topics.sh --bootstrap-server "$BOOTSTRAP" --alter --topic orders --partitions 4
kafka-topics.sh --bootstrap-server "$BOOTSTRAP" --delete --topic orders-eu
kafka-topics.sh --bootstrap-server "$BOOTSTRAP" --describe --topic orders
--describe shows one broker, node 0, as leader and only replica for every partition. That is the proxy view of the cluster. See how tools see a KafScale cluster.
Topic: orders TopicId: yk5ucW1hSq-T8fYwvVyjUA PartitionCount: 4 ReplicationFactor: 1 Configs:
Topic: orders Partition: 0 Leader: 0 Replicas: 0 Isr: 0 Elr: N/A LastKnownElr: N/A
Topic: orders Partition: 1 Leader: 0 Replicas: 0 Isr: 0 Elr: N/A LastKnownElr: N/A
Topic: orders Partition: 2 Leader: 0 Replicas: 0 Isr: 0 Elr: N/A LastKnownElr: N/A
Topic: orders Partition: 3 Leader: 0 Replicas: 0 Isr: 0 Elr: N/A LastKnownElr: N/A
2. Produce and consume
Produce keyed records, one key:value per line:
printf 'a:1\nb:2\nc:3\n' | kafka-console-producer.sh --bootstrap-server "$BOOTSTRAP" \
--topic orders --reader-property parse.key=true --reader-property key.separator=:
Consume them as a group, with keys and partitions:
kafka-console-consumer.sh --bootstrap-server "$BOOTSTRAP" --topic orders \
--group orders-reader --from-beginning --max-messages 3 \
--formatter-property print.key=true --formatter-property print.partition=true
Partition:0 a 1
Partition:0 b 2
Partition:2 c 3
Processed a total of 3 messages
Kafka CLI 4.x also prints a note about the KIP-848 consumer protocol first. You can ignore it.
Kafka CLI versions before 4.0 use --property instead of --reader-property and --formatter-property.
The default Java producer uses idempotence, and KafScale supports it. Transactions are not supported.
3. Check the consumer group
kafka-consumer-groups.sh --bootstrap-server "$BOOTSTRAP" --list
kafka-consumer-groups.sh --bootstrap-server "$BOOTSTRAP" --describe --group orders-reader
Consumer group 'orders-reader' has no active members.
GROUP TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID
orders-reader orders 0 2 2 0 - - -
orders-reader orders 1 0 0 0 - - -
orders-reader orders 2 1 1 0 - - -
orders-reader orders 3 0 0 0 - - -
Reset the offsets. Run with --dry-run first, then with --execute. The group must have no active members:
kafka-consumer-groups.sh --bootstrap-server "$BOOTSTRAP" --group orders-reader \
--topic orders --reset-offsets --to-earliest --dry-run
kafka-consumer-groups.sh --bootstrap-server "$BOOTSTRAP" --group orders-reader \
--topic orders --reset-offsets --to-earliest --execute
GROUP TOPIC PARTITION NEW-OFFSET
orders-reader orders 0 0
orders-reader orders 1 0
orders-reader orders 2 0
orders-reader orders 3 0
--to-earliest, --to-latest, --to-offset, --to-datetime and --by-duration all work. The date based ones use the record timestamps. The time is in the tool’s local time zone unless you add an offset such as Z:
kafka-consumer-groups.sh --bootstrap-server "$BOOTSTRAP" --group orders-reader \
--topic orders --reset-offsets --to-datetime 2026-12-02T20:11:00.000 --dry-run
For an empty partition, or one with no record at or after that time, the tool prints Falling back to latest known offset and uses the log end offset.
Delete the group:
kafka-consumer-groups.sh --bootstrap-server "$BOOTSTRAP" --delete --group orders-reader
4. Read offsets
kafka-get-offsets.sh --bootstrap-server "$BOOTSTRAP" --topic orders
orders:0:2
orders:1:0
orders:2:1
orders:3:0
The output is topic:partition:offset. Without --time you get the latest offsets. Add --time earliest for the first ones. To look up a time, pass it in milliseconds since the epoch:
kafka-get-offsets.sh --bootstrap-server "$BOOTSTRAP" --topic orders \
--time "$(( $(date +%s) - 3600 ))000"
orders:0:0
orders:2:0
You get the first offset whose record timestamp is at or after that time. If no record qualifies, KafScale returns no offset for that partition, so the tool leaves it out. Here partitions 1 and 3 are empty.
5. Read and change topic configs
Read the configs with --all. Without it, the tool only lists overrides:
kafka-configs.sh --bootstrap-server "$BOOTSTRAP" --describe \
--entity-type topics --entity-name orders --all
All configs for topic orders are:
cleanup.policy=delete sensitive=false synonyms={DEFAULT_CONFIG:cleanup.policy=delete}
compression.type=producer sensitive=false synonyms={DEFAULT_CONFIG:compression.type=producer}
message.timestamp.type=CreateTime sensitive=false synonyms={DEFAULT_CONFIG:message.timestamp.type=CreateTime}
min.insync.replicas=1 sensitive=false synonyms={DEFAULT_CONFIG:min.insync.replicas=1}
retention.bytes=-1 sensitive=false synonyms={DEFAULT_CONFIG:retention.bytes=-1}
retention.ms=-1 sensitive=false synonyms={DEFAULT_CONFIG:retention.ms=-1}
segment.bytes=4194304 sensitive=false synonyms={DEFAULT_CONFIG:segment.bytes=4194304}
A topic has seven configs: cleanup.policy, compression.type, message.timestamp.type, min.insync.replicas, retention.ms, retention.bytes and segment.bytes. The first four are fixed, so you can’t change them.
Change a config, then remove the override again:
kafka-configs.sh --bootstrap-server "$BOOTSTRAP" --alter \
--entity-type topics --entity-name orders --add-config retention.ms=604800000
kafka-configs.sh --bootstrap-server "$BOOTSTRAP" --alter \
--entity-type topics --entity-name orders --delete-config retention.ms
Each change prints Completed updating config for topic orders. While the override is set, --describe without --all shows it:
Dynamic configs for topic orders are:
retention.ms=604800000 sensitive=false synonyms={DYNAMIC_TOPIC_CONFIG:retention.ms=604800000, DEFAULT_CONFIG:retention.ms=-1}
Changing one of the fixed configs fails with InvalidConfigurationException, for example cleanup.policy=compact is not supported; KafScale has no log compaction.
The change is stored in etcd, so every broker shows it. It does not delete any records. Setting retention.ms only stores the value. To expire data, put an S3 lifecycle rule on the topic prefix.
Broker configs are read only. A request for a broker config reaches the broker with that ID, including node 0.
Connect with mTLS
When the proxy has mTLS enabled, every tool needs the CA certificate and a client certificate. SASL is not supported.
Put the client certificate and its private key into one PEM file, and the settings into a properties file. Keep both readable only by you. Never pass key material or passwords on the command line:
umask 077
cat client.crt client.key > client.pem
cat > client.properties <<'PROPS'
security.protocol=SSL
ssl.truststore.type=PEM
ssl.truststore.location=/path/to/ca.crt
ssl.keystore.type=PEM
ssl.keystore.location=/path/to/client.pem
PROPS
chmod 600 client.pem client.properties
The key in client.pem must be an unencrypted PKCS#8 key (BEGIN PRIVATE KEY). If your key is encrypted, add ssl.key.password to the properties file with an editor. Keep hostname verification on. The proxy certificate must name the host in BOOTSTRAP.
Pass the file with --command-config to every tool, including the console producer and consumer:
kafka-topics.sh --bootstrap-server "$BOOTSTRAP" --command-config client.properties --list
printf 'one\ntwo\n' | kafka-console-producer.sh --bootstrap-server "$BOOTSTRAP" \
--command-config client.properties --topic secure-events
kafka-console-consumer.sh --bootstrap-server "$BOOTSTRAP" --command-config client.properties \
--topic secure-events --from-beginning --max-messages 2
kafka-consumer-groups.sh --bootstrap-server "$BOOTSTRAP" --command-config client.properties --list
Kafka CLI versions before 4.0 use --producer.config and --consumer.config for the console tools.
Check what the cluster supports
kafka-broker-api-versions.sh --bootstrap-server "$BOOTSTRAP"
APIs marked UNSUPPORTED are not implemented. The overview explains what each gap means for tools.