25.6. Upgrading KRaft-based Kafka clusters and client applications
Upgrade a KRaft-based Streams for Apache Kafka cluster to a newer supported Kafka version and KRaft metadata version.
You should also choose a strategy for upgrading clients. Kafka clients are upgraded in step 6 of this procedure.
Refer to the Apache Kafka documentation for the latest on support for KRaft-based upgrades.
Prerequisites
- The Cluster Operator is up and running.
-
Before you upgrade the Streams for Apache Kafka cluster, check that the properties of the
Kafkaresource do not contain configuration options that are not supported in the new Kafka version.
Procedure
Update the Kafka cluster configuration:
oc edit kafka <kafka_configuration_file>If configured, check that the current
spec.kafka.metadataVersionis set to a version supported by the version of Kafka you are upgrading to.For example, the current version is 3.6-IV2 if upgrading from Kafka version 3.6.0 to 3.7.0:
apiVersion: kafka.strimzi.io/v1beta2 kind: Kafka metadata: name: my-cluster spec: kafka: replicas: 3 metadataVersion: 3.6-IV2 version: 3.6.0 # ...If
metadataVersionis not configured, Streams for Apache Kafka automatically updates it to the current default after the update to the Kafka version in the next step.注意The value of
metadataVersionmust be a string to prevent it from being interpreted as a floating point number.Change the
Kafka.spec.kafka.versionto specify the new Kafka version; leave themetadataVersionat the default for the current Kafka version.注意Changing the
kafka.versionensures that all brokers in the cluster are upgraded to start using the new broker binaries. During this process, some brokers are using the old binaries while others have already upgraded to the new ones. Leaving themetadataVersionunchanged at the current setting ensures that the Kafka brokers and controllers can continue to communicate with each other throughout the upgrade.For example, if upgrading from Kafka 3.6.0 to 3.7.0:
apiVersion: kafka.strimzi.io/v1beta2 kind: Kafka metadata: name: my-cluster spec: kafka: replicas: 3 metadataVersion: 3.6-IV21 version: 3.7.02 # ...If the image for the Kafka cluster is defined in
Kafka.spec.kafka.imageof theKafkacustom resource, update theimageto point to a container image with the new Kafka version.Save and exit the editor, then wait for the rolling updates to upgrade the Kafka nodes to complete.
Check the progress of the rolling updates by watching the pod state transitions:
oc get pods my-cluster-kafka-0 -o jsonpath='{.spec.containers[0].image}'The rolling updates ensure that each pod is using the broker binaries for the new version of Kafka.
Depending on your chosen strategy for upgrading clients, upgrade all client applications to use the new version of the client binaries.
If required, set the
versionproperty for Kafka Connect and MirrorMaker as the new version of Kafka:-
For Kafka Connect, update
KafkaConnect.spec.version. -
For MirrorMaker, update
KafkaMirrorMaker.spec.version. For MirrorMaker 2, update
KafkaMirrorMaker2.spec.version.注意If you are using custom images that are built manually, you must rebuild those images to ensure that they are up-to-date with the latest Streams for Apache Kafka base image. For example, if you created a container image from the base Kafka Connect image, update the Dockerfile to point to the latest base image and build configuration.
-
For Kafka Connect, update
- Verify that the upgraded client applications work correctly with the new Kafka brokers.
If configured, update the Kafka resource to use the new
metadataVersionversion. Otherwise, go to step 9.For example, if upgrading to Kafka 3.7.0:
apiVersion: kafka.strimzi.io/v1beta2 kind: Kafka metadata: name: my-cluster spec: kafka: replicas: 3 metadataVersion: 3.7-IV2 version: 3.7.0 # ...警告Exercise caution when changing the
metadataVersion, as downgrading may not be possible. You cannot downgrade Kafka if themetadataVersionfor the new Kafka version is higher than the Kafka version you wish to downgrade to. However, understand the potential implications on support and compatibility when maintaining an older version.Wait for the Cluster Operator to update the cluster.
You can check the upgrade has completed successfully from the status of the
Kafkaresource.