Lesson 07 of 7 · Platform services
Kafka as a platform service with Strimzi
Offer Kafka as a self-service platform capability on kind: the Strimzi operator installed through Argo CD, one shared KRaft cluster with only an mTLS listener, teams declaring topics and users in their own repositories, prefix ACLs and quotas per team, and admission guard-rails on topic names, partitions and retention. Verified end to end, including the denied cross-team write.
The brief
"Teams wait days for a Kafka topic and share one superuser password. Make topics self-service, give every service its own identity, stop one team from reading another's data, and stop one noisy producer from slowing everyone."
The school post room gives every club its own pigeonholes with its name on them, and a key card that opens only those. Clubs can ask for new pigeonholes by filling in a form, and the post room checks the name and size are sensible. Nobody can post 10,000 letters a minute and block everyone else.
Resources needed
- A kind cluster with Argo CD (the hub-and-workload lab from Build an Internal Developer Platform, or one cluster with Argo CD installed).
- About 3 GB of free memory for Kafka.
- Kyverno installed (for the guard-rails step).
- A Git server (Gitea in the lab) for a "team repository".
The flow
platform repo ─► ApplicationSet installs Strimzi on labelled clusters
platform repo ─► Kafka cluster "platform" (KRaft, mTLS listener only, ACLs on, auto-create off)
team repo ─► KafkaTopic orders.events + KafkaUser orders-svc (ACLs: orders.* only, quotas)
│ Argo CD syncs; Strimzi's Topic and User Operators create topic, cert and ACLs
service pod ─► mTLS with its own certificate → can use orders.*; payments.* is denied
Step 1: the operator as a fleet add-on
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: addon-strimzi
namespace: argocd
spec:
goTemplate: true
generators:
- clusters:
selector:
matchLabels: { fleet.example.io/ring: "0" }
template:
metadata:
name: 'strimzi-{{ .name }}'
spec:
project: default
source:
repoURL: https://strimzi.io/charts/
chart: strimzi-kafka-operator
targetRevision: 1.3.1
helm:
valuesObject:
replicas: 1
labels: { app.kubernetes.io/part-of: kafka-platform }
destination:
server: '{{ .server }}'
namespace: kafka
syncPolicy:
automated: { prune: true, selfHeal: true }
syncOptions: [ CreateNamespace=true, ServerSideApply=true ]
The labels value is there because the platform's own admission policy requires a part-of label on every pod: platform add-ons follow the same guard-rails as teams.
Step 2: one shared cluster, identities only
apiVersion: kafka.strimzi.io/v1
kind: KafkaNodePool
metadata:
name: dual-role
namespace: kafka
labels: { strimzi.io/cluster: platform }
spec:
replicas: 1
roles: [ controller, broker ]
storage:
type: jbod
volumes:
- { id: 0, type: persistent-claim, size: 2Gi, deleteClaim: true, kraftMetadata: shared }
---
apiVersion: kafka.strimzi.io/v1
kind: Kafka
metadata:
name: platform
namespace: kafka
spec:
kafka:
version: 4.3.2
listeners:
- { name: tls, port: 9093, type: internal, tls: true, authentication: { type: tls } }
authorization:
type: simple
config:
default.replication.factor: 1
min.insync.replicas: 1
offsets.topic.replication.factor: 1
transaction.state.log.replication.factor: 1
transaction.state.log.min.isr: 1
auto.create.topics.enable: false
entityOperator:
topicOperator: {}
userOperator: {}
- KRaft: no ZooKeeper. One dual-role node for the lab; production uses three controllers and several brokers across zones with replication factor 3 and
min.insync.replicas: 2. - Only an mTLS listener: every client has an identity, so ACLs and quotas apply per service. No anonymous access.
auto.create.topics.enable: false: topics exist only if declared.
Step 3: a team declares its topic and identity (in its own repo)
apiVersion: kafka.strimzi.io/v1
kind: KafkaTopic
metadata:
name: orders.events
namespace: kafka
labels: { strimzi.io/cluster: platform, platform.example.io/team: orders }
spec:
partitions: 6
replicas: 1
config:
retention.ms: 259200000 # 3 days
cleanup.policy: delete
---
apiVersion: kafka.strimzi.io/v1
kind: KafkaUser
metadata:
name: orders-svc
namespace: kafka
labels: { strimzi.io/cluster: platform, platform.example.io/team: orders }
spec:
authentication: { type: tls }
authorization:
type: simple
acls:
- resource: { type: topic, name: orders., patternType: prefix }
operations: [ Read, Write, Describe ]
- resource: { type: group, name: orders., patternType: prefix }
operations: [ Read ]
quotas:
producerByteRate: 1048576 # 1 MiB/s
consumerByteRate: 2097152 # 2 MiB/s
requestPercentage: 25
Argo CD syncs these from the team's repository. The User Operator issues a client certificate (Secret orders-svc) and creates the ACLs and quotas; the Topic Operator creates the topic. No ticket.
Step 4: guard-rails at admission
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: kafka-topic-guardrails
spec:
rules:
- name: naming-and-limits
match:
any:
- resources: { kinds: [ kafka.strimzi.io/v1/KafkaTopic ] }
validate:
failureAction: Enforce
message: "Topics must be named <team>.<name> (lowercase), use at most 12 partitions and retain at most 7 days."
deny:
conditions:
any:
- key: "{{ regex_match('^[a-z0-9-]+\\.[a-z0-9.-]+$', '{{ request.object.metadata.name }}') }}"
operator: Equals
value: false
- key: "{{ request.object.spec.partitions || `1` }}"
operator: GreaterThan
value: 12
- key: "{{ to_number(request.object.spec.config.\"retention.ms\" || `0`) }}"
operator: GreaterThan
value: 604800000
Kyverno ClusterPolicy is deprecated
From Kyverno 1.19, kyverno.io/v1 ClusterPolicy prints a deprecation warning: it will be removed in a future release in favour of the CEL-based ValidatingPolicy, MutatingPolicy, GeneratingPolicy and ImageValidatingPolicy (policies.kyverno.io). The example above still works today; write new policies in the new kinds (migration guide). A rule like this, which only validates fields, can also be written as Kubernetes' built-in ValidatingAdmissionPolicy (GA since 1.30), with no engine to run.
Try a topic called BigTopic with 50 partitions: the API server rejects it with the message above.
Step 5: prove isolation with a real client
Run a pod with the Strimzi Kafka image, mounting the orders-svc user Secret and the cluster CA Secret platform-cluster-ca-cert. Write a client config and test:
$ printf "security.protocol=SSL\nssl.truststore.location=/ca/ca.p12\nssl.truststore.type=PKCS12\nssl.truststore.password=$CA_PW\nssl.keystore.location=/user/user.p12\nssl.keystore.type=PKCS12\nssl.keystore.password=$USER_PW\n" > /tmp/c.properties
$ echo hello | kafka-console-producer.sh --bootstrap-server platform-kafka-bootstrap:9093 --command-config /tmp/c.properties --topic orders.events
$ kafka-console-consumer.sh --bootstrap-server platform-kafka-bootstrap:9093 --command-config /tmp/c.properties --topic orders.events --group orders.reader --from-beginning --max-messages 1
$ echo x | kafka-console-producer.sh --bootstrap-server platform-kafka-bootstrap:9093 --command-config /tmp/c.properties --topic payments.ledger
The first two work. The last fails with TopicAuthorizationException: the orders-svc identity has no rights on payments.*.
When it breaks
| Symptom | Check |
|---|---|
| Operator pods blocked at admission | Platform policies apply to add-ons too: set the required labels through chart values |
| Kafka pod pending | Memory requests vs the node; PVC bound? |
| Topic not created | kubectl get kafkatopic -n kafka conditions; labels must include strimzi.io/cluster |
| Client handshake fails | Using port 9093 with SSL; truststore is the cluster CA; keystore password from the user Secret |
| Authorization errors on your own topic | ACL prefix includes the dot (orders.); consumer group name also needs the prefix |
Key points to explain
- Topic as code: teams own their topics and identities in Git; the platform owns the cluster.
- Identity per service (mTLS client certificates) is what makes ACLs and quotas meaningful; shared passwords make them impossible.
- Prefix ACLs give each team a namespace inside Kafka; quotas contain noisy neighbours; very large or regulated tenants get their own Kafka cluster.
- Admission guard-rails keep names, partitions and retention within limits the cluster can afford.
- On a cloud-managed Kafka (such as MSK), the same API shape can be kept with a controller or Crossplane provider calling the admin APIs; identity becomes IAM or SASL/SCRAM.
Clean up
$ kubectl delete kafkatopic,kafkauser --all -n kafka
$ kubectl delete kafka platform -n kafka && kubectl delete kafkanodepool dual-role -n kafka
$ kubectl -n argocd delete applicationset addon-strimzi
Delete topics and users before the operator, so its finalizers can complete.
Command summary
kubectl get kafka,kafkanodepool,kafkatopic,kafkauser -n kafka
kubectl get secret orders-svc platform-cluster-ca-cert -n kafka
kubectl describe kafkauser orders-svc -n kafka
kafka-acls.sh --bootstrap-server <b> --command-config <admin.properties> --list
kafka-console-producer.sh / kafka-console-consumer.sh --command-config /tmp/c.properties …
Recap
- Strimzi turns Kafka clusters, topics and users into Kubernetes resources delivered by GitOps.
- An mTLS-only listener, prefix ACLs and quotas give every service an identity, a namespace and a fair share.
- Admission policy keeps self-service within limits; isolation is proven with a real denied write.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.