kafka
by CloudPirates
Apache Kafka is a distributed event streaming platform used for high-performance data pipelines, streaming analytics, and data integration. This chart deploys Kafka in KRaft mode (no ZooKeeper required).
About this chart
Kafka Helm Chart
Apache Kafka is a distributed event streaming platform used for high-performance data pipelines, streaming analytics, and data integration. This chart deploys Kafka in KRaft mode using the official apache/kafka image, so no ZooKeeper is required.
Each replica runs as a combined broker + controller node, which keeps the deployment self-contained and simple to operate for small and medium clusters.
Quick Start
Prerequisites
- Kubernetes 1.24+
- Helm 3.2.0+
- PV provisioner support in the underlying infrastructure (if persistence is enabled)
Installing the Chart
To install the chart with the release name my-kafka:
helm install my-kafka oci://registry-1.docker.io/cloudpirates/kafka
To install with custom values:
helm install my-kafka oci://registry-1.docker.io/cloudpirates/kafka -f my-values.yaml
Or install directly from the local chart:
helm install my-kafka ./charts/kafka
The command deploys Kafka on the Kubernetes cluster in the default configuration. The Configuration section lists the parameters that can be configured during installation.
Security & Signature Verification
This Helm chart is cryptographically signed with Cosign to ensure authenticity and prevent tampering.
To verify the helm chart before installation, copy the public key from the repository's cosign.pub and run cosign:
cosign verify --key cosign.pub registry-1.docker.io/cloudpirates/kafka:<version>
Getting Started
The chart provisions a StatefulSet of Kafka nodes plus two services:
<release>-kafka– aClusterIPservice for client/bootstrap connections (port9092).<release>-kafka-headless– a headless service used for inter-node controller traffic and stable pod DNS.
Bootstrap server
From inside the cluster, connect your clients to:
<release>-kafka.<namespace>.svc.cluster.local:9092
Produce and consume a test message
kubectl run kafka-client --rm -it --restart='Never' \
--image apache/kafka:4.2.1 -- bash
# Inside the pod:
/opt/kafka/bin/kafka-topics.sh --create --topic demo \
--bootstrap-server my-kafka:9092 --partitions 3 --replication-factor 3
/opt/kafka/bin/kafka-console-producer.sh --topic demo \
--bootstrap-server my-kafka:9092
/opt/kafka/bin/kafka-console-consumer.sh --topic demo --from-beginning \
--bootstrap-server my-kafka:9092
How it works
- KRaft, combined mode: every node sets
process.roles=broker,controller. The staticcontroller.quorum.voterslist is generated fromreplicaCountand the stable headless DNS names of the pods. - Per-node identity: each pod derives its
node.idfrom its StatefulSet ordinal (plusnodeIdOffset) and advertisesPLAINTEXT://<pod>.<headless>.<namespace>.svc.cluster.local:9092so that clients are routed to the correct broker. - Storage formatting: on startup each node formats its KRaft storage with
kafka-storage.sh format --ignore-formatted, which is idempotent and safe across restarts. TheclusterIdvalue is used as the cluster UUID and must be identical for all nodes of the same cluster. - Read-only root filesystem: the base
server.propertiesis mounted from a ConfigMap; the runtime copy and Kafka logs are written to in-memoryemptyDirvolumes, while log segments are persisted to the data PVC.
Note:
replicaCountcontrols both the number of brokers and the size of the KRaft controller quorum. Use an odd number (3 or 5) for production to keep a healthy quorum. ChangingreplicaCountafter the cluster has been formatted requires care — see the Kafka KRaft docs.
Cluster sizing (replicas & replication)
In KRaft combined mode each pod is both a broker and a controller, so replicaCount is your
broker count and your controller quorum size. Two rules drive sizing:
- A replication factor can never exceed the number of brokers — you can't keep 3 copies of data on 1 broker. This chart automatically caps the replication factors to
replicaCount, so smaller clusters just work (see Kafka Configuration). - The controller quorum needs a majority to stay available —
Ncontrollers tolerate(N-1)/2failures, so only an odd count gives you fault tolerance.
Match replicaCount to your number of independent nodes (extra replicas on the same node share its fate and add no real availability):
| Independent nodes | replicaCount | Replication factor | Survives a node failure? | Use case |
|---|---|---|---|---|
| 1 | 1 | 1 | No | dev / CI / local, non-HA |
| 2 | 1 (or 2 for a second data copy) | 1–2 | No (even quorum tolerates 0 failures) | small, non-HA |
| 3 | 3 (default) | 3 | Yes (tolerates 1) | production HA |
| 5 | 5 | 3 (capped) | Yes (tolerates 2) | larger production |
Two nodes is the awkward case: a 2-node quorum still tolerates zero failures, so it costs double without buying availability. Jump straight from 1 → 3 for fault tolerance.
Configuration
Global parameters
| Parameter | Description | Default |
|---|---|---|
global.imageRegistry | Global Docker image registry | "" |
global.imagePullSecrets | Global Docker registry secret names as an array | [] |
global.defaultStorageClass | Global default StorageClass for PVCs (used when persistence.storageClass is empty) | "" |
Image Configuration
| Parameter | Description | Default |
|---|---|---|
image.registry | Kafka image registry | docker.io |
image.repository | Kafka image repository | apache/kafka |
image.tag | Kafka image tag | 4.2.1@sha256:9916d60eca5d599550e2c320230808fda342124ba550bb4ac4ea8591803262a0 |
image.imagePullPolicy | Kafka image pull policy | Always |
Common Parameters
| Parameter | Description | Default |
|---|---|---|
nameOverride | String to partially override fullname | "" |
fullnameOverride | String to fully override fullname | "" |
namespaceOverride | String to override the namespace for all resources | "" |
clusterDomain | Kubernetes cluster domain used to build internal service FQDNs | cluster.local |
clusterId | KRaft cluster ID used to format storage (identical across all nodes; keep stable). Override per cluster | oUl0u_8RQBym0t93b891HA |
nodeIdOffset | Offset added to the pod ordinal to compute each node's node.id | 0 |
commonLabels | Labels to add to all deployed objects | {} |
commonAnnotations | Annotations to add to all deployed objects | {} |
replicaCount | Number of Kafka nodes to deploy (broker + controller) | 3 |
revisionHistoryLimit | Number of revisions to keep in history | 10 |
podDisruptionBudget.enabled | Create a Pod Disruption Budget (only when replicaCount > 1) | true |
podDisruptionBudget.minAvailable | minAvailable for Pod Disruption Budget | "51%" |
podDisruptionBudget.maxUnavailable | maxUnavailable for Pod Disruption Budget | "" |
networkPolicy.enabled | Enable network policies | false |
heapOpts | Kafka JVM heap options (KAFKA_HEAP_OPTS) | -Xmx1G -Xms1G |
command | Command run after storage formatting, instead of kafka-server-start.sh (does not override the container command) | [] |
extraArgs | Extra arguments appended to kafka-server-start.sh (ignored when command is set), e.g. --override key=value | [] |
Kafka Configuration
| Parameter | Description | Default |
|---|---|---|
kafkaConfig.numPartitions | Default number of log partitions per topic | 3 |
kafkaConfig.defaultReplicationFactor | Default replication factor for automatically created topics (capped to replicaCount) | 3 |
kafkaConfig.offsetsTopicReplicationFactor | Replication factor for the offsets topic (capped to replicaCount) | 3 |
kafkaConfig.transactionStateLogReplicationFactor | Replication factor for the transaction state log topic (capped to replicaCount) | 3 |
kafkaConfig.transactionStateLogMinIsr | Minimum in-sync replicas for the transaction state log topic (capped to the effective transaction-log replication factor) | 2 |
kafkaConfig.autoCreateTopicsEnable | Enable auto creation of topics on the server | true |
kafkaConfig.logRetentionHours | Number of hours to keep a log file before deleting it | 168 |
kafkaConfig.extraConfig | Extra Kafka configuration lines appended to server.properties | [] |
Replication factors are capped to
replicaCount. A replication factor can never exceed the number of brokers, so the factors above are automatically clamped — a 1- or 2-node cluster works without lowering them by hand, while a 3+ node cluster keeps the full3/2values. Note that Kafka does not re-replicate already-created internal topics (e.g.__consumer_offsets) when you later scale up, so the effective replication of existing topics won't increase on its own.
Service
| Parameter | Description | Default |
|---|---|---|
service.type | Kubernetes service type | ClusterIP |
service.ports.client | Kafka client (broker) port | 9092 |
service.ports.internal | Inter-broker listener port (headless Service only) | 9094 |
service.ports.controller | Kafka controller (KRaft) port | 9093 |
service.annotations | Additional service annotations | {} |
External access
Exposes an additional EXTERNAL listener so brokers can be reached from outside the Kubernetes
cluster (e.g. legacy VMs, or clients on a VPN-connected network) without an Ingress/Gateway. One
Service is created per broker ordinal (0..replicaCount-1), each selecting only that broker's
pod via the statefulset.kubernetes.io/pod-name label Kubernetes stamps on every StatefulSet
pod, so clients reconnect to the correct broker after the initial bootstrap connection — the same
metadata-driven reconnect flow Kafka always uses. Each broker's advertised address is resolved
either from a static IP (externalAccess.service.loadBalancerIPs, indexed by ordinal) or a domain
suffix (externalAccess.domain, giving <fullname>-<ordinal>.<domain>); at least one of the two
must resolve every broker ordinal, or that broker fails to start.
externalAccess.service.type and .annotations are plain passthroughs, so this works the same
way on any Kubernetes distribution or cloud: LoadBalancer (the default) with your cloud's own
annotations on AWS/GCP/Azure, LoadBalancer with MetalLB on bare metal, or NodePort on
minikube/kind where no load-balancer controller is available.
| Parameter | Description
Deploy kafka with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kafka on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartkafka is pinned at v0.3.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply