Skip to content

About

Every Apache Kafka command you actually need — Makefile-driven cheat sheet for Kafka 4.x / KRaft

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

Kafka Cheat Code

Every Apache Kafka command you actually need — wrapped in a Makefile so you stop googling flags.

Kafka License: MIT Python Français

Running Kafka day to day means retyping the same twelve commands with slightly different flags. This repo turns them into one-word make targets, ships production-shaped config files, and keeps a full command reference for the moments you need the raw CLI.

make help — every target at a glance

Built from production experience operating Kafka platforms at scale. More guides on tuning, security and operations: floriancourouge.com/blog


Quick start (Kafka 4.x, KRaft — no ZooKeeper)

Kafka 4.0 removed ZooKeeper entirely. Clusters run on KRaft, and the bootstrap sequence changed: you now format the storage directory with a cluster ID before the first start.

# 1. Download and extract (Java 17+ required)
wget https://downloads.apache.org/kafka/4.3.1/kafka_2.13-4.3.1.tgz
tar -xzf kafka_2.13-4.3.1.tgz
cd kafka_2.13-4.3.1

# 2. Generate a cluster ID
KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)"

# 3. Format the log directory (once per node, before the first start)
bin/kafka-storage.sh format --standalone -t "$KAFKA_CLUSTER_ID" -c config/server.properties

# 4. Start the broker
bin/kafka-server-start.sh config/server.properties

Then point this repo at it:

make check                      # verify Java, Kafka and Python are in place
export KAFKA_HOME=/path/to/kafka_2.13-4.3.1
export KAFKA_SERVER=localhost:9092
make topic-create TOPIC=orders
Still on Kafka 3.x with ZooKeeper? Read this before upgrading.

You cannot jump straight from a ZooKeeper-based cluster to 4.x. The supported path is:

  1. Upgrade to a recent 3.x release (3.9 is the last one with ZooKeeper support).
  2. Migrate that cluster to KRaft mode while still on 3.x.
  3. Only then upgrade to 4.x.

The --zookeeper CLI flag disappeared well before 4.0 — every command in this repo uses --bootstrap-server, which works on 3.x and 4.x alike.


Make targets

The Makefile is the point of this repo. make help lists everything; here are the ones you'll use daily.

Area Command What it does
Setup make install Install the Python dependencies
make check Verify Java, Kafka and Python prerequisites
Broker make start / make stop / make restart Control the local broker
make status Is it up, and on which port
make logs Tail the broker logs
Topics make topic-create TOPIC=orders Create a topic
make topic-list List topics
make topic-describe TOPIC=orders Partitions, replicas, ISR
make topic-delete TOPIC=orders Delete a topic
Consumer groups make groups List every group
make group GROUP=my-app Lag, offsets and members for one group
make reset GROUP=my-app TOPIC=orders Reset offsets
Benchmarks make test-producer / make test-consumer Throughput tests
make test-batch / make test-compression Compare batching and codecs
make test-full Full performance suite
Analysis make analyze-health Under-replicated and offline partitions
make analyze-offsets Offset and lag breakdown
make analyze-size Topic sizes on disk
make analyze-full Everything above in one run
Examples make producer / make consumer Run the Python examples
Cleanup make clean / make test-cleanup Remove generated and benchmark data

The four scripts behind these targets also run standalone. They look for the Kafka binaries in $KAFKA_HOME/bin first, then on the PATH, and accept both naming conventions (kafka-topics.sh from the Apache tarballs, kafka-topics from the Confluent packages).

Both KAFKA_HOME (default /opt/kafka) and KAFKA_SERVER (default localhost:9092) are overridable, so the same targets work against a remote cluster:

make topic-list KAFKA_SERVER=broker-1.prod:9092

What's in the box

├── Makefile              # the interface — start here (make help)
├── COMMANDES.md          # full CLI reference, every command with examples
├── docs/                 # 12 chapters: concepts, security, stream processing, use cases
├── requirements.txt
└── kafka/
    ├── configs/          # producer, consumer, and SASL/PLAIN + SASL/SCRAM admin clients
    ├── scripts/          # quick-start, topic-manager, performance-tests, topic-analyzer
    └── examples/         # producer-example.py, consumer-example.py

COMMANDES.md is the reference sheet: topics, consumer groups, offsets, ACLs, performance testing, troubleshooting — with the flags spelled out.

docs/ goes wider (in French): core concepts, Confluent and Conduktor, security and governance, advanced stream processing, SaaS options, and real-world use cases.


Who it's for

  • You operate Kafka and want the daily commands one keystroke away.
  • You're learning Kafka and want config files that resemble production, not a toy.
  • You're benchmarking and want repeatable producer/consumer tests.

Contributing

Issues and pull requests are welcome — especially additional commands, fixes for newer Kafka releases, and translations.

License

MIT — use it freely.


Florian Courouge — Apache Kafka & Confluent expert, DevOps engineer. floriancourouge.com · LinkedIn · Kafkabubble (multi-tenant Kafka control plane)

About

Every Apache Kafka command you actually need — Makefile-driven cheat sheet for Kafka 4.x / KRaft

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages