Managing Valkey™ cluster hosts
You can add and remove cluster hosts and manage their settings. For information about moving cluster hosts to a different availability zone, see this guide.
Getting a list of cluster hosts
- Go to the folder page
and select Yandex Managed Service for Valkey™. - Click the name of the cluster you need and select the Hosts tab.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To get a list of cluster hosts, run the command:
yc managed-redis host list \
--cluster-name=<cluster_name>
Result:
+---------------------------------+----------------------+------------+---------+--------+-------------------+
| NAME | CLUSTER ID | SHARD NAME | ROLE | HEALTH | ZONE ID |
+---------------------------------+----------------------+------------+---------+--------+-------------------+
| rc1a-...caf.mdb.yandexcloud.net | c9qb2q230gg1******** | shard1 | MASTER | ALIVE | ru-central1-a |
| rc1b-...bgc.mdb.yandexcloud.net | c9qb2q230gg1******** | shard1 | REPLICA | ALIVE | ru-central1-b |
+---------------------------------+----------------------+------------+---------+--------+-------------------+
You can request the cluster name with a list of clusters in the folder.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.ListHosts method and make a request, e.g., via cURL
:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-redis/v1/clusters/<cluster_ID>/hosts'
You can get the cluster ID with a 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.ListHosts call and make a request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/redis/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.redis.v1.ClusterService.ListHosts
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
Creating a host
The number of hosts in Yandex Managed Service for Valkey™ clusters is limited by the CPU and RAM quotas available to DB clusters in your cloud. To check the resources currently in use, open the Quotas
Note
Public access to hosts can only be configured for clusters created with enabled TLS support.
To create a host:
- Go to the folder page
and select Yandex Managed Service for Valkey™. - Click the cluster name and go to the Hosts tab.
- Click Create host.
- Specify the host parameters:
-
Availability zone.
-
Subnet (if the required subnet is not on the list, create it).
-
If necessary, configure public access to the host.
-
If you are adding a host to a sharded cluster, select a shard.
-
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To create a host:
-
Request a list of cluster subnets to select one for the new host:
yc vpc subnet list
Result:
+----------------------+-----------+-----------------------+---------------+------------------+ | ID | NAME | NETWORK ID | ZONE | RANGE | +----------------------+-----------+-----------------------+---------------+------------------+ | b0cl69a2b4c6******** | default-d | enp6rq72rndgr******** | ru-central1-d | [172.16.0.0/20] | | e2lkj9qwe762******** | default-b | enp6rq72rndgr******** | ru-central1-b | [10.10.0.0/16] | | e9b0ph42bn96******** | a-2 | enp6rq72rndgr******** | ru-central1-a | [172.16.32.0/20] | | e9b9v22r88io******** | default-a | enp6rq72rndgr******** | ru-central1-a | [172.16.16.0/20] | +----------------------+-----------+-----------------------+---------------+------------------+
If the required subnet is not in the list, create it.
-
View a description of the CLI command for adding a host:
yc managed-redis host add --help
-
Run the add host command:
yc managed-redis host add \ --cluster-name=<cluster_name> \ --host zone-id=<availability_zone>,` `subnet-id=<subnet_ID>,` `assign-public-ip=<public_access>,` `replica-priority=<host_priority>,` `shard-name=<shard_name>
Where:
--cluster-name
: Yandex Managed Service for Valkey™ cluster name. You can retrieve it with a list of clusters in a folder.--host
: Host parameters:zone-id
: Availability zone.subnet-id
: Subnet ID. Specify if two or more subnets are created in the selected availability zone.assign-public-ip
: Internet access to the host via a public IP address,true
orfalse
.replica-priority
: Priority for assigning the host as a master if the primary master fails. It is only available for non-sharded clusters.shard-name
: Name of the shard to create the host in if the cluster is sharded.
To create a host:
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
Add a
host
block to the Yandex Managed Service for Valkey™ cluster description:resource "yandex_mdb_redis_cluster" "<cluster_name>" { ... host { zone = "<availability_zone>" subnet_id = "<subnet_ID>" assign_public_ip = <public_access> replica_priority = <host_priority> shard_name = "<shard_name>" } }
Where
assign_public_ip
is public access to the host,true
orfalse
. -
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
A Terraform provider sets the timeout for Yandex Managed Service for Valkey™ cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster: 60 minutes.
- Deleting a cluster: 15 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_redis_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.AddHosts method and make a request, e.g., via cURL
:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-redis/v1/clusters/<cluster_ID>/hosts:batchCreate' \ --data '{ "hostSpecs": [ { "zoneId": "<availability_zone>", "subnetId": "<subnet_ID>", "shardName": "<shard_name>", "replicaPriority": "<host_priority>", "assignPublicIp": <public_access_to_cluster_host> } ] }'
Where
hostSpecs
sets the host parameters:zoneId
: Availability zone.subnetId
: Subnet ID. Specify if two or more subnets are created in the selected availability zone.shardName
: Shard name for the host. Only used if cluster sharding is enabled.replicaPriority
: Priority for assigning the host as a master if the primary master fails.assignPublicIp
: Internet access to the host via a public IP address,true
orfalse
. You can enable public access only if TLS support is enabled in the cluster.
You can get the cluster ID with a 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.AddHosts call and make a request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/redis/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "host_specs": [ { "zone_id": "<availability_zone>", "subnet_id": "<subnet_ID>", "shard_name": "<shard_name>", "replica_priority": "<host_priority>", "assign_public_ip": <public_access_to_cluster_host> } ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.redis.v1.ClusterService.AddHosts
Where
host_specs
represents the host parameters:zone_id
: Availability zone.subnet_id
: Subnet ID. Specify if two or more subnets are created in the selected availability zone.shard_name
: Shard name for the host. Only used if cluster sharding is enabled.replica_priority
: Priority for assigning the host as a master if the primary master fails.assign_public_ip
: Internet access to the host via a public IP address,true
orfalse
. You can enable public access only if TLS support is enabled in the cluster.
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
Warning
If you cannot connect to the host you added, check that the cluster security group is configured correctly for the host's subnet.
Changing a host
Note
Access to hosts from the Internet via public IP addresses is possible only if the cluster has been created with TLS support enabled.
To change the parameters of the cluster host:
-
Go to the folder page
and select Yandex Managed Service for Valkey™. -
Click the cluster name and open the Hosts tab.
-
Click
in the host's row and select Edit. -
Set new settings for the host:
- Enable Public access if the host must be accessible from outside Yandex Cloud.
- Specify the priority for assigning the host as a master.
-
Click Save.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change the parameters of the host, run the command:
yc managed-redis host update <host_name> \
--cluster-name=<cluster_name> \
--assign-public-ip=<public_access> \
--replica-priority=<host_priority>
Where --assign-public-ip
is public access to the host, true
or false
.
You can request the host name with a list of cluster hosts, and the cluster name, with a list of clusters in the folder.
To change the parameters of the cluster host:
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
In the Yandex Managed Service for Valkey™ cluster description, change the attributes of the
host
block corresponding to the host you are updating.resource "yandex_mdb_redis_cluster" "<cluster_name>" { ... host { zone = "<availability_zone>" subnet_id = "<subnet_ID>" assign_public_ip = <public_access> replica_priority = <host_priority> shard_name = "<shard_name>" } }
Where
assign_public_ip
is public access to the host,true
orfalse
. -
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
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.UpdateHosts method and make a 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 POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-redis/v1/clusters/<cluster_ID>/hosts:batchUpdate' \ --data '{ "updateHostSpecs": [ { "hostName": "<host_name>", "replicaPriority": "<host_priority>", "assignPublicIp": <public_access_to_cluster_host>, "updateMask": "replicaPriority,assignPublicIp" } ] }'
Where
updateHostSpecs
represents the host parameters:hostName
: Name of the host you need to update. To find out the name, get a list of hosts in the cluster.replicaPriority
: Priority for assigning the host as a master if the primary master fails.assignPublicIp
: Internet access to the host via a public IP address,true
orfalse
. You can enable public access only if TLS support is enabled in the cluster.updateMask
: List of parameters to update as a single string, separated by commas.
You can get the cluster ID with a 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.UpdateHosts call and make a 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/redis/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_host_specs": [ { "host_name": "<host_name>", "replica_priority": "<host_priority>", "assign_public_ip": <public_access_to_cluster_host>, "update_mask": { "paths": ["replica_priority", "assign_public_ip"] } } ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.redis.v1.ClusterService.UpdateHosts
Where
update_host_specs
represents the host parameters:host_name
: Name of the host you need to update. To find out the name, get a list of hosts in the cluster.replica_priority
: Priority for assigning the host as a master if the primary master fails.assign_public_ip
: Internet access to the host via a public IP address,true
orfalse
. You can enable public access only if TLS support is enabled in the cluster.update_mask
: List of parameters to update as an array ofpaths[]
strings.
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
Warning
If you cannot connect to the host you added, check that the cluster security group is configured correctly for the host's subnet.
Removing a host
You can remove a host from a Valkey™ cluster if it is not the only host in it. To replace a single host, first create a new host and then remove the old one.
If the host is the master at the time of deletion, Yandex Managed Service for Valkey™ will automatically assign another replica as the master.
You cannot remove a host if the number of hosts in a cluster or cluster shard is equal to the minimum value. For more information, see Quotas and limits.
To remove a host from a cluster:
- Go to the folder page
and select Yandex Managed Service for Valkey™. - Click the cluster name and open the Hosts tab.
- In the cluster row, click
and select Delete. - In the window that opens, enable Delete host and click Confirm.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To remove a host from the cluster, run:
yc managed-redis host delete <host_name> \
--cluster-name=<cluster_name>
You can request the host name with a list of cluster hosts, and the cluster name, with a list of clusters in the folder.
To remove a host from a cluster:
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
Delete the
host
block from the Yandex Managed Service for Valkey™ cluster description. -
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.
-
-
Type
yes
and press Enter.-
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
A Terraform provider sets the timeout for Yandex Managed Service for Valkey™ cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster: 60 minutes.
- Deleting a cluster: 15 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_redis_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.DeleteHosts method and make a request, e.g., via cURL
:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-redis/v1/clusters/<cluster_ID>/hosts:batchDelete' \ --data '{ "hostNames": [ "<host_name>" ] }'
Where
hostNames
is the name of the host to delete. To find out the name, get a list of hosts in the cluster.You can get the cluster ID with a 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.DeleteHosts call and make a request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/redis/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "host_names": [ "<host_name>" ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.redis.v1.ClusterService.DeleteHosts
Where
host_names
is the name of the host to delete. To find out the name, get a list of hosts in the cluster.You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.