kafka

by CloudPirates

Helm chartv0.3.0App 4.4.0Apache-2.0Verified publisher

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 – a ClusterIP service for client/bootstrap connections (port 9092).
  • <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 static controller.quorum.voters list is generated from replicaCount and the stable headless DNS names of the pods.
  • Per-node identity: each pod derives its node.id from its StatefulSet ordinal (plus nodeIdOffset) and advertises PLAINTEXT://<pod>.<headless>.<namespace>.svc.cluster.local:9092 so 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. The clusterId value is used as the cluster UUID and must be identical for all nodes of the same cluster.
  • Read-only root filesystem: the base server.properties is mounted from a ConfigMap; the runtime copy and Kafka logs are written to in-memory emptyDir volumes, while log segments are persisted to the data PVC.

Note: replicaCount controls 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. Changing replicaCount after 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 — N controllers tolerate (N-1)/2 failures, 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 nodesreplicaCountReplication factorSurvives a node failure?Use case
111Nodev / CI / local, non-HA
21 (or 2 for a second data copy)1–2No (even quorum tolerates 0 failures)small, non-HA
33 (default)3Yes (tolerates 1)production HA
553 (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

ParameterDescriptionDefault
global.imageRegistryGlobal Docker image registry""
global.imagePullSecretsGlobal Docker registry secret names as an array[]
global.defaultStorageClassGlobal default StorageClass for PVCs (used when persistence.storageClass is empty)""

Image Configuration

ParameterDescriptionDefault
image.registryKafka image registrydocker.io
image.repositoryKafka image repositoryapache/kafka
image.tagKafka image tag4.2.1@sha256:9916d60eca5d599550e2c320230808fda342124ba550bb4ac4ea8591803262a0
image.imagePullPolicyKafka image pull policyAlways

Common Parameters

ParameterDescriptionDefault
nameOverrideString to partially override fullname""
fullnameOverrideString to fully override fullname""
namespaceOverrideString to override the namespace for all resources""
clusterDomainKubernetes cluster domain used to build internal service FQDNscluster.local
clusterIdKRaft cluster ID used to format storage (identical across all nodes; keep stable). Override per clusteroUl0u_8RQBym0t93b891HA
nodeIdOffsetOffset added to the pod ordinal to compute each node's node.id0
commonLabelsLabels to add to all deployed objects{}
commonAnnotationsAnnotations to add to all deployed objects{}
replicaCountNumber of Kafka nodes to deploy (broker + controller)3
revisionHistoryLimitNumber of revisions to keep in history10
podDisruptionBudget.enabledCreate a Pod Disruption Budget (only when replicaCount > 1)true
podDisruptionBudget.minAvailableminAvailable for Pod Disruption Budget"51%"
podDisruptionBudget.maxUnavailablemaxUnavailable for Pod Disruption Budget""
networkPolicy.enabledEnable network policiesfalse
heapOptsKafka JVM heap options (KAFKA_HEAP_OPTS)-Xmx1G -Xms1G
commandCommand run after storage formatting, instead of kafka-server-start.sh (does not override the container command)[]
extraArgsExtra arguments appended to kafka-server-start.sh (ignored when command is set), e.g. --override key=value[]

Kafka Configuration

ParameterDescriptionDefault
kafkaConfig.numPartitionsDefault number of log partitions per topic3
kafkaConfig.defaultReplicationFactorDefault replication factor for automatically created topics (capped to replicaCount)3
kafkaConfig.offsetsTopicReplicationFactorReplication factor for the offsets topic (capped to replicaCount)3
kafkaConfig.transactionStateLogReplicationFactorReplication factor for the transaction state log topic (capped to replicaCount)3
kafkaConfig.transactionStateLogMinIsrMinimum in-sync replicas for the transaction state log topic (capped to the effective transaction-log replication factor)2
kafkaConfig.autoCreateTopicsEnableEnable auto creation of topics on the servertrue
kafkaConfig.logRetentionHoursNumber of hours to keep a log file before deleting it168
kafkaConfig.extraConfigExtra 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 full 3/2 values. 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

ParameterDescriptionDefault
service.typeKubernetes service typeClusterIP
service.ports.clientKafka client (broker) port9092
service.ports.internalInter-broker listener port (headless Service only)9094
service.ports.controllerKafka controller (KRaft) port9093
service.annotationsAdditional 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartkafka is pinned at v0.3.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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