Apache Kafka® version upgrade
Note
Starting March 1, 2025, support for Apache Kafka® 2.8, 3.0, 3.1, 3.2, and 3.3 is discontinued. You cannot create a cluster with these versions. We recommend that you upgrade your existing clusters to version 3.9.
You can find the list of supported versions in the Apache Kafka® versioning policy section. We recommend upgrading Apache Kafka® step by step, without skipping any versions. For example, upgrade from version 3.1 to 3.5 in the following sequence: 3.1 → 3.2 → 3.3 → 3.4 → 3.5.
To learn more about minor version updates and host maintenance, see Maintenance.
Before upgrading a version
Make sure this does not affect your applications: review the Apache Kafka® release notes
Upgrading a cluster
Alert
Once your Apache Kafka® version is upgraded, you cannot revert the cluster to the previous version.
During an upgrade, topics may be unavailable if their replication factor is 1.
- In the management console
, navigate to the relevant folder. - Go to Managed Service for Kafka.
- In the cluster row, click
and select Edit. - In the Version field, select the new version number.
- Click Save.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
Get the list of your Managed Service for Apache Kafka® clusters:
yc managed-kafka cluster list -
Get information about the cluster you need and check the version in the
config.versionproperty:yc managed-kafka cluster get <cluster_name_or_ID> -
Run the Apache Kafka® upgrade:
yc managed-kafka cluster update <cluster_name_or_ID> \ --version=<new_version_number>
-
Open the current Terraform configuration file describing your infrastructure.
Learn how to create this file in Creating a cluster.
-
In the
configsection of the Managed Service for Apache Kafka® cluster, add theversionfield (the Apache Kafka® version) or update its value if it already exists:resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... config { version = "<version>" } } -
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Timeouts
The Terraform provider limits the time for all operations with the Managed Service for Apache Kafka® cluster to 60 minutes.
Operations exceeding the timeout are aborted.
How do I change these limits?
Add the timeouts section to your cluster description, such as the following:
resource "yandex_mdb_kafka_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.update method, e.g., via the following cURL
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
updateMaskparameter as a single comma-separated string.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ -url 'https://mdb.api.cloud.yandex.net/managed-kafka/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.version", "configSpec": { "version": "<version>" } }'Where:
-
updateMask: Comma-separated string of settings you want to update.Here, we only specified a single setting,
configSpec.version. -
configSpec.version: Target Apache Kafka® version, 3.6, 3.7, 3.8 or 3.9.
You can get the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService/Update method, e.g., via the following gRPCurl
request:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
update_maskparameter as an array ofpaths[]strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/kafka/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.version" ] }, "config_spec": { "version": "<version>" } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.kafka.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array of strings (paths[]).Here, we only specified a single setting,
config_spec.version. -
config_spec.version: Target Apache Kafka® version, 3.6, 3.7, 3.8 or 3.9.
You can get the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
Examples
Let's assume you need to upgrade your cluster from version 2.8 to version 3.0.
-
To get a list of clusters with their IDs and names, run this command:
yc managed-kafka cluster list+----------------------+---------------+---------------------+--------+---------+ | ID | NAME | CREATED AT | HEALTH | STATUS | +----------------------+---------------+---------------------+--------+---------+ | c9q8p8j2gaih******** | kafka35 | 2021-10-23 12:44:17 | ALIVE | RUNNING | +----------------------+---------------+---------------------+--------+---------+ -
To get information about the
kafka35cluster, run the following command:yc managed-kafka cluster get kafka35id: c9q8p8j2gaih******** ... config: version: "2.8" ... -
To upgrade the
kafka35cluster to version 3.0, run this command:yc managed-kafka cluster update kafka35 --version=3.0