Skip to content

feat(kafka): migrate to apache/kafka image with KRaft mode#233

Merged
jarlah merged 1 commit intomainfrom
feat/apache-kafka-image
Feb 2, 2026
Merged

feat(kafka): migrate to apache/kafka image with KRaft mode#233
jarlah merged 1 commit intomainfrom
feat/apache-kafka-image

Conversation

@jarlah
Copy link
Copy Markdown
Member

@jarlah jarlah commented Feb 2, 2026

Summary

  • Replace the confluentinc/cp-kafka image with the official apache/kafka image which runs in KRaft mode by default
  • Eliminate the need for Zookeeper, simplifying deployment and configuration
  • Add automatic topic creation support via with_topics/2

Changes

New Features

  • Use apache/kafka:3.9.0 as the default Docker image
  • KRaft mode (Kafka Raft) for single-node clusters without Zookeeper
  • with_topics/2 function to automatically create topics on container startup
  • bootstrap_servers/1 helper to get the connection string
  • port/1 helper to get the mapped port

Breaking Changes

  • Removed: consensus_strategy option (only KRaft is supported now)
  • Removed: zookeeper_port, zookeeper_host options
  • Removed: broker_port, broker_id options (use kafka_port, node_id instead)
  • Removed: topic_partitions option (use with_topics/2 for topic creation)

Implementation Notes

  • Uses a randomly selected fixed host port (29000-29999) because the apache/kafka image requires knowing the advertised listener address at startup time, before dynamic port mapping is known
  • All KRaft configuration is handled internally for simple single-node deployments

Test plan

  • Unit tests for all configuration methods
  • Integration test: basic Kafka container startup
  • Integration test: produce and consume messages
  • Integration test: automatic topic creation

🤖 Generated with Claude Code

Replace the confluentinc/cp-kafka image with the official apache/kafka
image which runs in KRaft mode by default, eliminating the need for
Zookeeper.

Key changes:
- Use apache/kafka:3.9.0 as the default image
- Configure KRaft mode with combined broker/controller roles
- Use fixed host port (random 29000-29999) for advertised listeners
  since apache/kafka requires knowing the advertised address at startup
- Add with_topics/2 to automatically create topics on startup
- Add bootstrap_servers/1 and port/1 helper functions
- Simplify configuration by removing Zookeeper-related options
- Update tests to match new API

Breaking changes:
- Removed consensus_strategy option (only KRaft is supported)
- Removed zookeeper_port, zookeeper_host options
- Removed broker_port, broker_id options (use kafka_port, node_id)
- Removed topic_partitions option (use with_topics/2 instead)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jarlah
Copy link
Copy Markdown
Member Author

jarlah commented Feb 2, 2026

@Argonus ☝️ 🙈 (used ralph with claude code and it worked without interruption for more than half an hour)

@jarlah
Copy link
Copy Markdown
Member Author

jarlah commented Feb 2, 2026

replaces #232

@jarlah
Copy link
Copy Markdown
Member Author

jarlah commented Feb 2, 2026

i think ill just merge this, so we have a new upgraded version of kafka for version 2.X.X which is yet to be released.

@jarlah
Copy link
Copy Markdown
Member Author

jarlah commented Feb 2, 2026

but do add your comments and/or suggestions/fears with this change @Argonus

@jarlah jarlah merged commit 70752c4 into main Feb 2, 2026
8 checks passed
@jarlah jarlah deleted the feat/apache-kafka-image branch February 2, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant