Apache Kafka® version upgrade
Note
Starting March 1, 2025, support for Apache Kafka® versions 2.8, 3.0, 3.1, 3.2, and 3.3 will be discontinued, so you will not be able to create a cluster with these versions. We recommend that you upgrade your clusters to version 3.5 beforehand.
You can upgrade a Managed Service for Apache Kafka® cluster to version 3.5 or lower. Upgrading to 3.6 or higher is not supported; however, you can create a cluster with one of these versions.
We recommend updating Apache Kafka® step by step without skipping any versions. For example, the upgrade sequence from version 2.8 to 3.1 is: 2.8 → 3.0 → 3.1.
To learn more about updates within a single version and host maintenance, see Maintenance.
Before a version upgrade
Make sure this does not affect your applications: review the Apache Kafka® change log
Upgrading a cluster
Alert
Once upgraded, you cannot roll an Apache Kafka® cluster back to the previous version.
During an upgrade, topics may be unavailable if their replication factor is 1.
- Go to the folder page and select Managed Service for Kafka.
- In the cluster row, click
, then select Edit. - In the Version field, select a new version number.
- Click Save.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
-
Get a 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.version
property: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 with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
In the
config
section of the required Managed Service for Apache Kafka® cluster, add theversion
field (the Apache Kafka® version) or edit the existing one:resource "yandex_mdb_kafka_cluster" "<cluster_name>" { ... config { version = "<version>" } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
Time limits
The Terraform provider limits the amount of time for all Managed Service for Apache Kafka® cluster operations to complete to 60 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
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 the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.update method and send the following request, e.g., via cURL
: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
updateMask
parameter 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
: List of parameters to update as a single string, separated by commas.Here only one parameter is specified:
configSpec.version
. -
configSpec.version
: target Apache Kafka® version, 2.8, 3.0, 3.1, 3.2, 3.3, 3.4, or 3.5.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService/Update call and send the following request, e.g., via gRPCurl
: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_mask
parameter 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.Update
Where:
-
update_mask
: List of parameters to update as an array ofpaths[]
strings.Here only one parameter is specified:
config_spec.version
. -
config_spec.version
: target Apache Kafka® version, 2.8, 3.0, 3.1, 3.2, 3.3, 3.4, or 3.5.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the 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 and find out 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 a cluster named
kafka35
, run the following command:yc managed-kafka cluster get kafka35
id: c9q8p8j2gaih******** ... config: version: "2.8" ...
-
To upgrade the
kafka35
cluster to version 3.0, run this command:yc managed-kafka cluster update kafka35 --version=3.0