Skip to content

Strimzi Kafka Operator

This document provides a quick reference for installing, upgrading, and testing a Strimzi Kafka deployment on Kubernetes.


Terminal window
kubectl create namespace inma-kafka
Terminal window
helm repo add strimzi https://strimzi.io/charts/
helm repo update
Terminal window
helm install strimzi strimzi/strimzi-kafka-operator \
--namespace inma-kafka

Verify the installation:

Terminal window
kubectl get pods -n inma-kafka

Before upgrading the operator, update the Custom Resource Definitions (CRDs) to the desired version.

Example (v0.35.0):

Terminal window
kubectl apply -f https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.35.0/strimzi-crds-0.35.0.yaml

Note: Replace 0.35.0 with the version you intend to upgrade to.


Update the Helm repository:

Terminal window
helm repo update

Upgrade the existing installation while preserving the current configuration:

Terminal window
helm upgrade --reuse-values strimzi strimzi/strimzi-kafka-operator \
--namespace inma-kafka

Note: Remove the --reuse-values flag if you want Helm to use the chart’s latest default values instead of the existing configuration.


Start a temporary Kafka consumer to read messages from a topic:

Terminal window
kubectl run kafka-consumer \
-ti \
--image=strimzi/kafka:latest-kafka-2.6.0 \
--rm=true \
--restart=Never \
-- \
bin/kafka-console-consumer.sh \
--bootstrap-server inma-kafka-cluster-kafka-bootstrap.inma-kafka:9092 \
--topic se.kalmarenergi.inma.logging.v1.messages.create \
--from-beginning

Start a temporary Kafka producer to publish messages to a topic:

Terminal window
kubectl run kafka-producer \
-ti \
--image=strimzi/kafka:latest-kafka-2.6.0 \
--rm=true \
--restart=Never \
-- \
bin/kafka-console-producer.sh \
--broker-list inma-kafka-cluster-kafka-bootstrap.inma-kafka:9092 \
--topic se.kalmarenergi.inma.device.v1.nodes.message.received

Verify that the operator and Kafka resources are running correctly:

Terminal window
kubectl get pods -n inma-kafka

List Kafka custom resources:

Terminal window
kubectl get kafka -n inma-kafka

Check the operator logs if troubleshooting is required:

Terminal window
kubectl logs deployment/strimzi-cluster-operator -n inma-kafka
kubectl apply -n inma-kafka -f - <<EOF
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
name: "se.kalmarenergi.inma.notification-teams.v1.messages.send"
namespace: "inma-kafka"
labels:
strimzi.io/cluster: "inma-kafka-cluster"
spec:
partitions: 2
replicas: 2
config:
min.insync.replicas: 2
retention.ms: 7200000
segment.bytes: 1073741824
EOF
kubectl describe kafkatopic se.kalmarenergi.inma.logging.v1.messages.create -n inma-kafka
kubectl get kafkatopics -n inma-kafka

This topic is used to Trigger data fetch from Valmet API.

This topic will be called from scheduler

apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
name: "se.kalmarenergi.inma.integration-production.v1.valmet.fetch-data"
namespace: inma-kafka
labels:
strimzi.io/cluster: "inma-kafka-cluster"
spec:
partitions: 2
replicas: 2
config:
min.insync.replicas: 2
retention.ms: 604800000
segment.bytes: 1073741824
kubectl apply -n inma-kafka -f - <<EOF
apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
name: inma-kafka-cluster
spec:
kafka:
replicas: 2
listeners:
- name: plain
port: 9092
type: internal
tls: false
- name: tls
port: 9093
type: internal
tls: true
authentication:
type: tls
storage:
type: jbod
volumes:
- id: 0
type: persistent-claim
size: 10Gi
deleteClaim: false
config:
auto.create.topics.enable: false
delete.topic.enable: true
log.retention.bytes: 1073741824
log.retention.hours: 1
log.retention.check.interval.ms: 300000
offsets.topic.replication.factor: 1
transaction.state.log.min.isr: 1
transaction.state.log.replication.factor: 1
livenessProbe:
initialDelaySeconds: 15
timeoutSeconds: 5
readinessProbe:
initialDelaySeconds: 15
timeoutSeconds: 5
template:
pod:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-type
operator: In
values:
- kafka
zookeeper:
replicas: 2
livenessProbe:
initialDelaySeconds: 15
timeoutSeconds: 5
readinessProbe:
initialDelaySeconds: 15
timeoutSeconds: 5
storage:
type: persistent-claim
size: 10Gi
deleteClaim: false
template:
pod:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-type
operator: In
values:
- kafka
entityOperator:
topicOperator: {}
userOperator: {}
kafkaExporter:
groupRegex: ".*"
topicRegex: ".*"
logging: debug
enableSaramaLogging: true
readinessProbe:
initialDelaySeconds: 15
timeoutSeconds: 5
livenessProbe:
initialDelaySeconds: 15
timeoutSeconds: 5
EOF