In this post, I highlight the benefits of using Kubernetes annotations to store information about Kafka topics, and share a simplified example of how this can even be automated.
Managing Kafka topics as Kubernetes resources brings many benefits. For example, they enable automated creation and management of topics as part of broader CI/CD workflows, it gives a way to track history of changes to topics and avoid configuration drift as part of GitOps processes, and they give a point of control for enforcing policies and standards.
The value of annotations
Another benefit that I’ve been seeing increasing interest in recently is that they provide a cheap and simple place to store small amounts of metadata about topics.
For example, you could add annotations to topics that identify the owning application or team.
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
name: some-kafka-topic
annotations:
acme.com/topic-owner: 'Joe Bloggs'
acme.com/topic-team: 'Finance'
Annotations are simple key/value pairs, so you can add anything that might be useful to a Kafka administrator.
You can add links to team documentation.
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
name: some-kafka-topic
annotations:
acme.com/documentation: 'https://acme-intranet.com/finance-apps/some-kafka-app'
You can add a link to the best Slack channel to use to ask questions about the topic.
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
name: some-kafka-topic
annotations:
acme.com/slack: 'https://acme.enterprise.slack.com/archives/C2QSX23GH'
(more…)