Strimzi Kafka Operator
This document provides a quick reference for installing, upgrading, and testing a Strimzi Kafka deployment on Kubernetes.
Installation
Section titled “Installation”Create the Namespace
Section titled “Create the Namespace”kubectl create namespace inma-kafkaAdd the Helm Repository
Section titled “Add the Helm Repository”helm repo add strimzi https://strimzi.io/charts/helm repo updateInstall the Strimzi Kafka Operator
Section titled “Install the Strimzi Kafka Operator”helm install strimzi strimzi/strimzi-kafka-operator \ --namespace inma-kafkaVerify the installation:
kubectl get pods -n inma-kafkaUpgrade Guide
Section titled “Upgrade Guide”Step 1: Upgrade the CRDs
Section titled “Step 1: Upgrade the CRDs”Before upgrading the operator, update the Custom Resource Definitions (CRDs) to the desired version.
Example (v0.35.0):
kubectl apply -f https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.35.0/strimzi-crds-0.35.0.yamlNote: Replace
0.35.0with the version you intend to upgrade to.
Step 2: Upgrade the Operator
Section titled “Step 2: Upgrade the Operator”Update the Helm repository:
helm repo updateUpgrade the existing installation while preserving the current configuration:
helm upgrade --reuse-values strimzi strimzi/strimzi-kafka-operator \ --namespace inma-kafkaNote: Remove the
--reuse-valuesflag if you want Helm to use the chart’s latest default values instead of the existing configuration.
Testing Kafka
Section titled “Testing Kafka”Consumer Test
Section titled “Consumer Test”Start a temporary Kafka consumer to read messages from a topic:
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-beginningProducer Test
Section titled “Producer Test”Start a temporary Kafka producer to publish messages to a topic:
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.receivedVerification
Section titled “Verification”Verify that the operator and Kafka resources are running correctly:
kubectl get pods -n inma-kafkaList Kafka custom resources:
kubectl get kafka -n inma-kafkaCheck the operator logs if troubleshooting is required:
kubectl logs deployment/strimzi-cluster-operator -n inma-kafkaTopic Management
Section titled “Topic Management”Create topic
Section titled “Create topic”kubectl apply -n inma-kafka -f - <<EOFapiVersion: kafka.strimzi.io/v1beta2kind: KafkaTopicmetadata: 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: 1073741824EOFDescribe topic
Section titled “Describe topic”kubectl describe kafkatopic se.kalmarenergi.inma.logging.v1.messages.create -n inma-kafkaGet topics
Section titled “Get topics”kubectl get kafkatopics -n inma-kafkaTopic Example
Section titled “Topic Example”This topic is used to Trigger data fetch from Valmet API.
This topic will be called from scheduler
apiVersion: kafka.strimzi.io/v1beta2kind: KafkaTopicmetadata: 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: 1073741824Cluster Management
Section titled “Cluster Management”kubectl apply -n inma-kafka -f - <<EOFapiVersion: kafka.strimzi.io/v1beta2kind: Kafkametadata: name: inma-kafka-clusterspec: 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: 5EOF