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 Kafka resource do not contain configuration options that are not supported in the new Kafka version.

Procedure

  1. Update the Kafka cluster configuration:

    oc edit kafka <kafka_configuration_file>
  2. If configured, check that the current spec.kafka.metadataVersion is 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 metadataVersion is 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 metadataVersion must be a string to prevent it from being interpreted as a floating point number.

  3. Change the Kafka.spec.kafka.version to specify the new Kafka version; leave the metadataVersion at the default for the current Kafka version.

    注意

    Changing the kafka.version ensures 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 the metadataVersion unchanged 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-IV2 
    1
    
        version: 3.7.0 
    2
    
        # ...
    1
    Metadata version is unchanged
    2
    Kafka version is changed to the new version.
  4. If the image for the Kafka cluster is defined in Kafka.spec.kafka.image of the Kafka custom resource, update the image to point to a container image with the new Kafka version.

    See Kafka version and image mappings

  5. 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.

  6. 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 version property for Kafka Connect and MirrorMaker as the new version of Kafka:

    1. For Kafka Connect, update KafkaConnect.spec.version.
    2. For MirrorMaker, update KafkaMirrorMaker.spec.version.
    3. 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.

  7. Verify that the upgraded client applications work correctly with the new Kafka brokers.
  8. If configured, update the Kafka resource to use the new metadataVersion version. 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 the metadataVersion for 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.

  9. Wait for the Cluster Operator to update the cluster.

    You can check the upgrade has completed successfully from the status of the Kafka resource.

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部