Skip to main content

Kafka Templates

Four Kafka patterns on cosmonic:kafka@0.5.0, one per delivery shape. Each is a self-contained project with source, a pinned WIT lockfile, and manifests for Cosmonic and Kubernetes, pointing at prebuilt components published from the repository.

Kafka clients are binding-scoped capabilities: the broker address, credentials, consumer group, and topic grant live in the workload's cosmonic:kafka entry under hostInterfaces, and the component cannot supply or override them at runtime. It therefore cannot redirect itself to another broker or substitute another credential.

Repository: cosmonic-labs/awesome-cosmonic/components/kafka Languages: Rust Interfaces: cosmonic:kafka/{handler,producer,consumer,transaction}

Which pattern do I want?​

TemplateShapeDelivery guaranteeUse when…
kafka-handler-consumerHost pushes partition-ordered batches to elastic component instancesat-least-once; dead-letter on permanent errorsServerless event processing, including consume→transform→produce. The recommended starting point
http-kafka-producerHTTP request in, Kafka record outbroker ack per recordAn API, webhook or UI event needs to publish records; ingest gateways
kafka-pull-serviceLong-running service owning a pull-consumer sessionat-least-once; your own dead-letter routingYou need assign, pause, seek, rebalance events, or explicit commits
kafka-transactionalPull service plus transactions: outputs and input offsets commit atomicallyexactly-once read-process-writeMoney, inventory, dedup-sensitive enrichment, where a replayed batch is unacceptable

The host keeps consumer-group membership stable while component instances scale with assigned partition work and can return to zero when idle. Growing the component pool does not add group members or trigger a rebalance; increasing workload replicas does.

Start from one​

wash new https://github.com/cosmonic-labs/awesome-cosmonic \
  --subfolder components/kafka/rust/kafka-handler-consumer

Rust only. cosmonic:kafka@0.5.0 declares every function async func, which needs a toolchain that can bind the WASI p3 async ABI.

Secrets​

config is for plain values, configFrom pulls a ConfigMap, and secretFrom pulls a Secret. The three merge in that order, so a password reaches the client without appearing in the manifest. See Component Configuration and Secrets.