This episode covers CI/CD and infrastructure as code for Kafka: Terraform for clusters, topic, ACL, schema, and connector definitions as code, CI/CD pipelines with testing and canary deployments, and GitOps with ArgoCD and Flux.

Kafka clusters configured through manually run CLI commands are a source of inconsistency: no one knows exactly what the production configuration is, and changes are hard to audit. Infrastructure as Code (IaC) moves all definitions — clusters, topics, ACLs, schemas, connectors — into a version-controlled repository.
Episode 31 covers Terraform for Kafka infrastructure, topic and ACL configuration as code, CI/CD pipelines for testing and staged deployment, and GitOps with ArgoCD and Flux for automatic synchronization.
Terraform can manage cloud Kafka clusters (MSK, Confluent) as well as Kafka resources themselves (topics, ACLs) via providers:
resource "aws_msk_cluster" "orders" {
cluster_name = "orders-kafka"
kafka_version = "3.7.0"
number_of_broker_nodes = 3
broker_node_group_info {
instance_type = "kafka.m7g.large"
client_subnets = [aws_subnet.a.id, aws_subnet.b.id, aws_subnet.c.id]
}
}aws_msk_cluster declares the cluster along with its version and instances. Because the definition is in code, every cluster change goes through a pull request and can be reviewed before being applied.
server.properties configuration, and service management.Define topics and ACLs in files that can be reviewed and tested:
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
name: orders
spec:
partitions: 6
replicas: 3
config:
cleanup.policy: delete
retention.ms: 604800000partitions: 6 and config.retention.ms document intent clearly. Version control provides history: when a topic was changed, by whom, and for what reason.
One repository per service or a monorepo with directories per environment (dev, staging, prod) are common choices. The key point: changes go through pull requests, reviews, and automatic application — so drift between environments can be prevented.
The CI pipeline runs tests before changes are applied:
Kafka application deployments can use common deployment patterns:
Both are very useful when changing consumer logic or schemas — where errors are better detected on a fraction of traffic than on all of it.
GitOps makes the git repository the single source of truth. ArgoCD or Flux watch the repository and synchronize state to the cluster automatically:
argocd app sync kafka-stackargocd app sync kafka-stack pulls the latest definitions from git and applies them. All changes must go through commits; the operator rejects manual changes that deviate from git.
Info
GitOps is most powerful when combined with Strimzi (episode 28): the entire Kafka stack — clusters, users, topics, connectors — is declared in git and applied automatically. This combination removes most manual Kafka operations.
In this episode 31 you've understood infrastructure as code with Terraform, topic, ACL, schema, and connector definitions as code, CI/CD pipelines with testing and canary deployments, and GitOps with ArgoCD and Flux.
The key takeaways:
In the next episode 32 we'll discuss testing strategies — unit tests for producers, consumers, and Streams topologies, integration tests with Testcontainers and embedded Kafka, performance tests with kafka-producer-perf-test, and chaos engineering for testing failures.