Running Kafka on Kubernetes by hand means StatefulSets, certificates, listeners, and a careful broker-by-broker restart every time a setting changes. Strimzi turns that into an operator: you describe the cluster in a Kafka resource and its node pools, topics in KafkaTopic resources, and users with their ACLs in KafkaUser resources, and the Cluster Operator does the rest. Red Hat ships the same project as Streams for Apache Kafka, formerly AMQ Streams. This lesson follows one configuration change through a three-broker KRaft cluster, shows how the operator rolls brokers without losing writes, why it refuses to roll when a broker is already down, and what clients with unsafe settings do during the roll.
Difficulty: Advanced · Know this first: Lesson 144, Lesson 145, Lesson 101
This bar splits one rolling configuration change across three brokers, in seconds. It is a worked example, not a measurement. Waiting for each broker to catch up is most of it, and it is time well spent.
Choose the replication factor, min.insync.replicas, and how many brokers holding a partition are down. Producers with acks=all need min.insync.replicas copies in sync to write.
acks=all writes succeed while RF − down ≥ min.insync.replicas · no replica left means no leader · min.insync.replicas 1 lets a single copy accept writes
Writes continue; no further restart is safe until this one catches up
Three questions. No score is saved anywhere — this is just you against the material.
Strimzi grows in four levels: first what the operator manages, then a cluster with node pools, listeners, topics, and users, then safe changes, upgrades, and rebalancing, and finally running Kafka as a platform service.
At the basic level you know the resources. Kafka describes the cluster: version, listeners, authorization, and config. KafkaNodePool describes groups of nodes: roles (controller, broker, or both), replicas, and storage. KafkaTopic and KafkaUser describe topics and users. Optional ones add Kafka Connect, MirrorMaker 2, the Kafka Bridge, and Cruise Control rebalances.
KRaft: current Strimzi runs Kafka without ZooKeeper; controller nodes hold the metadata in a Raft quorum.
Where it breaks: editing pods or config inside them by hand; the operator puts them back.
Try it: Basic
Which resource says how many broker nodes there are and what disks they use?
Now do it: Read the Kafka and KafkaNodePool manifests in Go deeper and say which nodes are controllers and which are brokers.
At the intermediate level you build a usable cluster.
authorization: simple for ACLs.min.insync.replicas: 2.Try it: Intermediate
An application needs to consume from topic orders as group billing. What should its KafkaUser grant?
Now do it: Write the KafkaUser in Go deeper for a producer to orders instead, and check which operations change.
At the advanced level you change clusters without losing writes.
spec.kafka.version (a roll), then the metadata version once all clients are tested.Failure scenarios: a full disk on one broker blocks every roll; an under-sized PVC cannot be shrunk; JBOD volumes can be added but not removed casually.
Try it: Advanced
A Kafka version upgrade is applied and the roll stalls with the operator reporting it cannot roll broker 1. What do you check first?
Now do it: Run kafka_availability.py in Go deeper and find the settings at which a roll is never safe.
At the master level you run Kafka for many teams.
Trade-off: one large shared cluster is efficient and makes noisy neighbours everyone's problem; several clusters isolate teams and multiply the operations.
Try it: Master
One team's batch job saturates the brokers' network every night and other teams' consumer lag grows. What fixes it at the platform level?
Now do it: For your cluster, compute disk needed: daily bytes in × retention days × replication factor, and compare with what the PVCs hold.
Kafka's write availability is arithmetic on three numbers. This script prints when acks=all producers can write, whether a rolling restart is safe, and how long a consumer group needs to catch up after a pause. Standard library only; python3 kafka_availability.py.
# kafka_availability.py - can producers with acks=all still write, and is a rolling restart safe?
def writes_ok(rf, min_isr, down):
return rf - down >= min_isr
print("RF min.insync brokers down acks=all writes")
for rf, mi in [(3, 2), (3, 1), (1, 1)]:
for down in range(0, rf + 1):
verdict = "ok" if writes_ok(rf, mi, down) else "fail: no leader, partition offline" if down == rf else "fail: NotEnoughReplicas"
if mi == 1 and rf > 1 and down == rf - 1:
verdict += " (one copy left: the next failure loses data)"
print(f"{rf:>2} {mi:>10} {down:>12} {verdict}")
# A rolling restart takes one more broker away, on purpose, for a few minutes.
def safe_to_roll(rf, min_isr, already_down):
return writes_ok(rf, min_isr, already_down + 1)
for already in (0, 1):
print(f"RF 3, min.insync 2, {already} broker(s) already down -> restarting one more is "
f"{'safe' if safe_to_roll(3, 2, already) else 'NOT safe: wait or fix the broken broker first'}")
# Consumer lag after a pause: how long until the group catches up?
lag, incoming, consumers, per_consumer = 1_200_000, 18_000, 12, 2_000 # messages and messages/s
drain = consumers * per_consumer - incoming
print(f"lag {lag:,} messages, consuming {consumers * per_consumer:,}/s against {incoming:,}/s arriving "
f"-> caught up in about {lag / drain / 60:.0f} minutes")
$ python3 kafka_availability.py RF min.insync brokers down acks=all writes 3 2 0 ok 3 2 1 ok 3 2 2 fail: NotEnoughReplicas 3 2 3 fail: no leader, partition offline 3 1 0 ok 3 1 1 ok 3 1 2 ok (one copy left: the next failure loses data) 3 1 3 fail: no leader, partition offline 1 1 0 ok 1 1 1 fail: no leader, partition offline RF 3, min.insync 2, 0 broker(s) already down -> restarting one more is safe RF 3, min.insync 2, 1 broker(s) already down -> restarting one more is NOT safe: wait or fix the broken broker first lag 1,200,000 messages, consuming 24,000/s against 18,000/s arriving -> caught up in about 3 minutes
Read it like this: RF 3 with min.insync.replicas 2 survives one broker down, which is exactly the room a rolling restart uses, so a roll with a broker already down must wait; min.insync.replicas 1 keeps writing with one copy at the cost of losing data on the next failure; and a group consuming 6,000 messages a second faster than they arrive clears 1.2 million messages of lag in a few minutes.
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaNodePool
metadata:
name: brokers
namespace: kafka
labels:
strimzi.io/cluster: shop
spec:
replicas: 3
roles: ["broker"]
storage:
type: persistent-claim
size: 500Gi
deleteClaim: false
---
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaNodePool
metadata:
name: controllers
namespace: kafka
labels:
strimzi.io/cluster: shop
spec:
replicas: 3
roles: ["controller"]
storage:
type: persistent-claim
size: 20Gi
---
apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
name: shop
namespace: kafka
annotations:
strimzi.io/node-pools: enabled
strimzi.io/kraft: enabled
spec:
kafka:
version: 4.0.0
listeners:
- name: tls
port: 9093
type: internal
tls: true
authentication:
type: tls
authorization:
type: simple
config:
default.replication.factor: 3
min.insync.replicas: 2
offsets.topic.replication.factor: 3
entityOperator:
topicOperator: {}
userOperator: {}
---
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
name: orders
namespace: kafka
labels:
strimzi.io/cluster: shop
spec:
partitions: 24
replicas: 3
config:
min.insync.replicas: 2
retention.ms: 604800000
---
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaUser
metadata:
name: billing
namespace: kafka
labels:
strimzi.io/cluster: shop
spec:
authentication:
type: tls
authorization:
type: simple
acls:
- resource: {type: topic, name: orders}
operations: [Read, Describe]
- resource: {type: group, name: billing}
operations: [Read]
The manifests parse as YAML and use Strimzi's v1beta2 API. The two annotations were required to enable KRaft and node pools in Strimzi releases before KRaft became the only mode; check the documentation for your Strimzi version, and the Kafka versions it supports, before applying. Try them on kind or minikube with the Strimzi quick start first.
kubectl get kafka,kafkanodepool,kafkatopic,kafkauser -n kafka kubectl get pods -n kafka -l strimzi.io/cluster=shop -w kubectl -n kafka exec shop-brokers-0 -- bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --under-replicated-partitions kubectl -n kafka logs deploy/strimzi-cluster-operator | grep -i roll
This is a composite of a failure pattern that keeps repeating; the numbers are illustrative. A team ran Kafka on Kubernetes with a plain StatefulSet before moving to an operator.
Kafka moved to Strimzi, which creates PodDisruptionBudgets and checks replica safety before every restart, and the Strimzi Drain Cleaner was installed so node drains hand evictions to the operator. The node upgrade process now waits for under-replicated partitions to reach zero between nodes.
Design a Kafka platform on Kubernetes with Strimzi for 20 teams, carrying orders, payments, and clickstream events, with a second region for disaster recovery.
What throughput and retention does each team need? Which topics need acks=all and min.insync.replicas 2? Who may create topics and users? How will node upgrades and Kafka upgrades be done? What must keep working if a region fails?
Say 150 MB/s in at peak, 7 days of retention, replication factor 3, 3 zones, and 2,000 partitions.
Three controllers and six brokers in node pools spread across zones with rack awareness; 150 MB/s × 7 days × 3 copies ≈ 270 TB of disk with headroom, on fast persistent volumes; TLS listeners with mTLS users and ACLs from Git; quotas per user; Cruise Control for rebalancing; Drain Cleaner for node drains; MirrorMaker 2 to the second region with offset sync and a rehearsed failover; alerts on under-replicated, offline and under-min-ISR partitions, disk, and lag.
A shared cluster is efficient and needs quotas and careful tenancy; separate clusters isolate teams and multiply the operations. Running Kafka on Kubernetes keeps one platform and needs fast local or network storage and drain discipline; a managed Kafka service removes that work and costs more per byte. Cross-region replication protects data and adds lag and the complexity of offset translation at failover.