Chapter 8. AMQ Streams and Kafka upgrades
Each version of AMQ Streams supports a range of versions of Apache Kafka. You can upgrade to a higher Kafka version as long as that version is supported by your version of AMQ Streams. In some cases, you can also downgrade to a lower supported Kafka version.
When a newer version of AMQ Streams is available, it may provide support for newer versions of Kafka. Therefore, you will need to upgrade to the new version of AMQ Streams before you can upgrade to a higher supported Kafka version. Upgrading the version of AMQ Streams is done by upgrading the Cluster Operator deployment to the new version.
8.1. Upgrading the Cluster Operator from 1.0.0 to 1.1.0 Copy linkLink copied to clipboard!
This procedure will describe how to upgrade a Cluster Operator deployment from version 1.0.0 to version 1.1.0.
The availability of Kafka clusters managed by the Cluster Operator is not affected by the upgrade operation.
Prerequisites
- An existing version 1.0.0 Cluster Operator deployment to be upgraded.
Procedure
Update your existing
Kafka,KafkaConnect,KafkaConnectS2I, andKafkaMirrorMakerresources, as follows:-
Add
Kafka.spec.kafka.versionwith the value2.0.0 -
Add
KafkaConnect.spec.versionwith the value2.0.0 -
Add
KafkaConnectS2I.spec.versionwith the value2.0.0 Add
KafkaMirrorMaker.spec.versionwith the value2.0.0Wait for the associated rolling updates to complete.
-
Add
Backup the existing Cluster Operator resources.
On OpenShift use
oc get:oc get all -l app=strimzi -o yaml > strimzi-backup.yamlUpdate the Cluster Operator. You will need to modify the installation files according to the namespace the Cluster Operator is running in.
On Linux, use:
sed -i 's/namespace: .*/namespace: my-namespace/' install/cluster-operator/*RoleBinding*.yamlOn MacOS, use:
sed -i '' 's/namespace: .*/namespace: my-namespace/' install/cluster-operator/*RoleBinding*.yamlIf you modified one or more environment variables in your existing Cluster Operator
Deployment, editinstall/cluster-operator/050-Deployment-cluster-operator.yamlto reflect the changes that you made.When you have an updated configuration you can deploy it along with the rest of the install resources.
On OpenShift use
oc apply:oc apply -f install/cluster-operatorWait for the associated rolling updates to complete.
Update existing resources to cope with deprecated custom resource properties.
-
If you have
Kafkaresources that specifyKafka.spec.topicOperator, rewrite them to useKafka.spec.entityOperator.topicOperatorinstead.
-
If you have
8.2. Upgrading and downgrading Kafka versions Copy linkLink copied to clipboard!
8.2.1. Versions and images overview Copy linkLink copied to clipboard!
The Cluster Operator embeds knowledge of different Kafka versions, but not of the corresponding images in which those versions are provided. Using the STRIMZI_KAFKA_IMAGES environment variable, the Cluster Operator is configured with a mapping between the Kafka version and the image to be used when that version is requested in a given Kafka resource.
Each Kafka resource can be configured with a Kafka.spec.kafka.version. If Kafka.spec.kafka.image is not configured then the default image for the given version will be used. If Kafka.spec.kafka.image is given, this overrides the default.
The Cluster Operator cannot validate that an image actually contains a Kafka broker of the expected version. Take care to ensure that the given image corresponds to the given Kafka version.
8.2.2. Kafka upgrades using the Cluster Operator Copy linkLink copied to clipboard!
How the Cluster Operator will perform an upgrade depends on the differences between:
- The interbroker protocol version of the two Kafka versions
- The log message format version of the two Kafka versions
- The version of Zookeeper used by the two Kafka versions
When each of these versions is the same, as is typically the case for a patch level upgrade, then the Cluster Operator can perform the upgrade using a single rolling update of the Kafka brokers. When one or more of these versions differ, the Cluster Operator will require two or three rolling updates of the Kafka brokers to perform the upgrade.
8.2.3. Upgrading brokers to a newer Kafka version Copy linkLink copied to clipboard!
This procedure describes how to upgrade a AMQ Streams Kafka cluster from one version of Kafka to a higher version; for example, from 2.0.0 to 2.1.1.
Prerequisites
- The Cluster Operator, which supports both versions of Kafka, is up and running.
-
A
Kafkaresource to be upgraded. -
You have checked that your
Kafka.spec.kafka.configcontains no options that are not supported in the version of Kafka that you are upgrading to. - Determine whether the new Kafka version has a different log message format version than the previous version. See the following table for help.
| Kafka version | Interbroker protocol version | Log message format version | Zookeeper version |
|---|---|---|---|
| 2.0.0 | 2.0 | 2.0 | 3.4.13 |
| 2.1.1 | 2.1 | 2.1 | 3.4.13 |
Procedure
If the log message format version of the previous Kafka version is the same as that of the new Kafka version, proceed to the next step. Otherwise, ensure that the
Kafka.spec.kafka.confighas thelog.message.format.versionconfigured to the default for the previous version.For example, if upgrading from Kafka 2.0.0:
apiVersion: v1alpha1 kind: Kafka spec: # ... kafka: version: 2.0.0 config: log.message.format.version: "2.0" # ...NoteYou must format the value of
log.message.format.versionas a string to prevent it from being interpreted as a number.If the
log.message.format.versionis unset, set it and then wait for the resulting rolling restart of the Kafka cluster to complete.Change the
Kafka.spec.kafka.versionto specify the new version, but leave thelog.message.format.versionas the previous version. If the image to be used is different from the image for the given version of Kafka configured in the Cluster Operator’sSTRIMZI_KAFKA_IMAGESthen configure theKafka.spec.kafka.imageas well.For example, if upgrading from Kafka 2.0.0 to 2.1.1:
apiVersion: v1alpha1 kind: Kafka spec: # ... kafka: version: 2.1.11 config: log.message.format.version: "2.0"2 # ...Wait for the Cluster Operator to upgrade the cluster. If the old and new versions of Kafka have different interbroker protocol versions, look in the Cluster Operator logs for an
INFOlevel message in the following format:Reconciliation #<num>(watch) Kafka(<namespace>/<name>): Kafka version upgrade from <from-version> to <to-version>, phase 2 of 2 completedAlternatively, if the old and new versions of Kafka have the same interbroker protocol version, look in the Cluster Operator logs for an
INFOlevel message in the following format:Reconciliation #<num>(watch) Kafka(<namespace>/<name>): Kafka version upgrade from <from-version> to <to-version>, phase 1 of 1 completedFor example, using
grep:oc logs -f <cluster-operator-pod-name> | grep -E "Kafka version upgrade from [0-9.]+ to [0-9.]+, phase ([0-9]+) of \1 completed"Upgrade all your client applications to use the new version of the client libraries.
WarningYou cannot downgrade after completing this step. If, for whatever reason, you need to revert the update at this point, follow the procedure Section 8.2.5, “Downgrading brokers to an older Kafka version”.
If the log message format versions, as identified in step 1, are the same proceed to the next step. Otherwise change the
log.message.format.versioninKafka.spec.kafka.configto the default version for the new version of Kafka now being used. For example, if upgrading to 2.1.1:apiVersion: v1alpha1 kind: Kafka spec: # ... kafka: version: 2.1.1 config: log.message.format.version: "2.1" # ...- Wait for the Cluster Operator to update the cluster.
Additional resources
- See Section 8.2.5, “Downgrading brokers to an older Kafka version” for the procedure to downgrade a AMQ Streams Kafka cluster from one version to a lower version, for example 2.1.1 to 2.0.0.
8.2.4. Kafka downgrades using the Cluster Operator Copy linkLink copied to clipboard!
Whether and how the Cluster Operator will perform a downgrade depends on the differences between:
- The interbroker protocol version of the two Kafka versions
- The log message format version of the two Kafka versions
- The version of Zookeeper used by the two Kafka versions
If the downgraded version of Kafka has the same log message format version then downgrading is always possible. In this case the Cluster Operator will be able to downgrade by performing a single rolling restart of the brokers.
If the downgraded version of Kafka has a different log message format version, then downgrading is only possible if the running cluster has always had log.message.format.version set to the version used by the downgraded version. This is typically only the case if the upgrade procedure was aborted before the log.message.format.version was changed. In this case the downgrade will require two rolling restarts of the brokers if the interbroker protocol of the two versions is different, or a single rolling restart if they are the same.
8.2.5. Downgrading brokers to an older Kafka version Copy linkLink copied to clipboard!
The previous version is the Kafka version that you are downgrading to (such as 2.0.0). The new version is the version that you are downgrading from (such as 2.1.1).
You can downgrade a AMQ Streams Kafka cluster from one version to a lower version; for example, from 2.1.1 to 2.0.0. Downgrading is not possible if the new version has ever used a log.message.format.version that is not supported by the previous version (including where the default value for log.message.format.version is used).
For example:
apiVersion: v1alpha1
kind: Kafka
spec:
# ...
kafka:
version: 2.1.1
config:
log.message.format.version: "2.0"
# ...
This resource can be downgraded to Kafka version 2.0.0 because the log.message.format.version has not been changed. If the log.message.format.version were absent (so that the parameter took its default value for a 2.1.0 broker of 2.1), or was "2.1" then downgrade would not be possible.
Prerequisites
- The Cluster Operator is up and running.
-
A
Kafkaresource to be downgraded. -
The
Kafka.spec.kafka.confighas alog.message.format.versionthat is supported by the version being downgraded to. -
You have checked that your
Kafka.spec.kafka.configcontains no options which are not supported in the version of Kafka being downgraded to.
Procedure
Change the
Kafka.spec.kafka.versionto specify the previous version. If the image to be used is different from the image for the given version of Kafka configured in the Cluster Operator’sSTRIMZI_KAFKA_IMAGESthen configure theKafka.spec.kafka.imageas well.For example, if downgrading from Kafka 2.1.1 to 2.0.0:
apiVersion: v1alpha1 kind: Kafka spec: # ... kafka: version: 2.0.01 config: log.message.format.version: "2.0"2 # ...NoteIt is necessary to format the value of
log.message.format.versionas a string to prevent it from being interpreted as a number.Wait for the Cluster Operator to downgrade the cluster. If both the previous and new versions of Kafka have a different interbroker protocol version, check the Cluster Operator logs for an
INFOlevel message in the following format:Reconciliation #<num>(watch) Kafka(<namespace>/<name>): Kafka version downgrade from <from-version> to <to-version>, phase 2 of 2 completedAlternatively, if both the previous and new versions of Kafka have the same interbroker protocol version look in the Cluster Operator logs for an
INFOlevel message in the following format:Reconciliation #<num>(watch) Kafka(<namespace>/<name>): Kafka version downgrade from <from-version> to <to-version>, phase 1 of 1 completedFor example, using
grep:oc logs -f <cluster-operator-pod-name> | grep -E "Kafka version downgrade from [0-9.]+ to [0-9.]+, phase ([0-9]+) of \1 completed"- Downgrade each client application to use the previous version of the client libraries.