Kafka on OpenShift with Strimzi
You don’t install Kafka on OpenShift so much as declare it and let an operator run it. Two builds of the same operator exist: the open-source Strimzi operator, and Red Hat’s supported build, Streams for Apache Kafka (formerly AMQ Streams). Functionally the same; the Red Hat build adds the support story.
The deployment flow
Section titled “The deployment flow”-
Create a namespace for Kafka (e.g.
kafka). You’ll needcluster-adminorstrimzi-adminrights to install the operator. -
Install the operator from OperatorHub — Operators → OperatorHub, search for Streams for Apache Kafka (or Strimzi) in the Streaming & Messaging category, pick a channel, install. This deploys the Cluster Operator, the CRDs, and RBAC. Confirm it shows Succeeded under Installed Operators.
-
Declare a Kafka cluster by applying a
Kafkacustom resource. The operator reconciles it into running brokers/controllers, services and config.
A minimal Kafka resource
Section titled “A minimal Kafka resource”apiVersion: kafka.strimzi.io/v1beta2kind: Kafkametadata: name: my-cluster namespace: kafkaspec: kafka: replicas: 3 listeners: - name: plain port: 9092 type: internal tls: false storage: type: persistent-claim size: 100GiKRaft and KafkaNodePools
Section titled “KRaft and KafkaNodePools”Kafka has moved off ZooKeeper to KRaft, where Kafka manages its own metadata
quorum. On Strimzi this comes with KafkaNodePool resources: instead of one
undifferentiated set of brokers, you define pools of nodes and assign them
broker and/or controller roles.
apiVersion: kafka.strimzi.io/v1beta2kind: KafkaNodePoolmetadata: name: brokers namespace: kafka labels: strimzi.io/cluster: my-clusterspec: replicas: 3 roles: - broker storage: type: persistent-claim size: 100GiTwo install paths, and a warning
Section titled “Two install paths, and a warning”You can install via OperatorHub/OLM (easiest, automatic updates) or apply the raw
installation artifacts with oc apply -f ./install/cluster-operator for more
control.
What Strimzi does and doesn’t autoscale
Section titled “What Strimzi does and doesn’t autoscale”Strimzi manages the cluster — brokers, topics, rebalancing (via Cruise Control). It does not scale the applications reading from Kafka. Scaling your consumers to keep up with load is a separate concern, and the right tool for it is KEDA — the next guide.