[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for Valkey™](../index.md) > [Step-by-step guides](index.md) > Clusters > Managing cluster hosts

# Managing Valkey™ cluster hosts

You can add and remove cluster hosts, as well as manage their settings. To learn how to move cluster hosts to a different [availability zone](../../overview/concepts/geo-scope.md), see [this guide](host-migration.md).

## Getting a list of cluster hosts {#list}

{% list tabs group=instructions %}

- Management console {#console}

  1. Navigate to **Yandex Managed Service for&nbsp;Valkey™**.
  1. Click the name of your cluster and select the **Hosts** tab.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To get a list of cluster hosts, run this command:

  ```bash
  yc managed-redis host list \
    --cluster-name=<cluster_name>
  ```

  Result:

  
  ```text
  +---------------------------------+----------------------+------------+---------+--------+-------------------+
  |              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 get the cluster name with the [list of clusters in the folder](cluster-list.md#list-clusters).

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and place it in an environment variable:

       ```bash
       export IAM_TOKEN="<IAM_token>"
       ```

    1. Call the [Cluster.ListHosts](../api-ref/Cluster/listHosts.md) method, e.g., via the following [cURL](https://curl.se/) request:

        ```bash
        curl \
            --request GET \
            --header "Authorization: Bearer $IAM_TOKEN" \
            --url 'https://mdb.api.cloud.yandex.net/managed-redis/v1/clusters/<cluster_ID>/hosts'
        ```

        You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. Check the [server response](../api-ref/Cluster/listHosts.md#yandex.cloud.mdb.redis.v1.ListClusterHostsResponse) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Call the [ClusterService.ListHosts](../api-ref/grpc/Cluster/listHosts.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        ```bash
        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 request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. Check the [server response](../api-ref/grpc/Cluster/listHosts.md#yandex.cloud.mdb.redis.v1.ListClusterHostsResponse) to make sure your request was successful.

{% endlist %}

## Creating a host {#add}

The number of hosts in Yandex Managed Service for Valkey™ clusters is limited by the CPU and RAM quotas allocated to database clusters in your cloud. To check the resources currently in use, open the [Quotas](https://console.yandex.cloud/cloud?section=quotas) page and find **Managed Databases**.


{% note info %}

You can configure public access to hosts only for clusters created with TLS enabled.

{% endnote %}


{% list tabs group=instructions %}

- Management console {#console}

  To create a host:
  1. Navigate to **Yandex Managed Service for&nbsp;Valkey™**.
  1. Click the cluster name and navigate to the **Hosts** tab.
  1. Click **Create host**.
  1. Specify the following host settings:
     * Availability zone.

     
     * Subnet (if the required subnet is not on the list, [create it](../../vpc/operations/subnet-create.md)).


     * [Host priority for promotion to master](../concepts/replication.md#master-failover).

     
     * Configure public access to the host, if required.


     * If you are adding a host to a sharded cluster, select a shard.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To create a host:

  
  1. To choose a subnet for your new host, get the list of all cluster subnets:

     ```bash
     yc vpc subnet list
	   ```

	 Result:

     ```text
     +----------------------+-----------+-----------------------+---------------+------------------+
     |          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 on the list, [create it](../../vpc/operations/subnet-create.md).


  1. See the description of the CLI command for adding hosts:

     ```bash
     yc managed-redis host add --help
     ```

  1. Run this command to add a host:

     
     ```bash
     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 get it from the [list of clusters in the folder](cluster-list.md#list-clusters).
     * `--host`: Host settings:
       * `zone-id`: [Availability zone](../../overview/concepts/geo-scope.md).
       * `subnet-id`: [Subnet ID](../../vpc/concepts/network.md#subnet). You must specify this setting if the selected availability zone has more than one subnet.
       * `assign-public-ip`: Host accessibility from the internet via a public IP address, `true` or `false`.
       * `replica-priority`: Host priority for assignment as a master if the [primary master fails](../concepts/replication.md#master-failover). It is only available for non-sharded clusters.
       * `shard-name`: Name of the shard to which you are adding the new host if the cluster is sharded.

- Terraform {#tf}

  To create a host:
  1. Open the current Terraform configuration file with the infrastructure plan.

     For information on how to create this file, see [Creating a cluster](cluster-create.md).
  1. Add a new host to the `hosts` section in the Yandex Managed Service for Valkey™ cluster description:

     
     ```hcl
     resource "yandex_mdb_redis_cluster_v2" "<cluster_name>" {
       ...
       hosts = {
         ...
         "<host_name>" = {
           zone             = "<availability_zone>"
           subnet_id        = "<subnet_ID>"
           assign_public_ip = <public_access>
           replica_priority = <host_priority>
           shard_name       = "<shard_name>"
         }
       }
     }
     ```


     Where:

     * `zone_id`: [Availability zone](../../overview/concepts/geo-scope.md).

     
     * `subnet_id`: ID of the subnet in the selected availability zone.
     * `assign_public_ip`: Public access to the host, `true` or `false`.


     * `replica_priority`: Host priority for master promotion during [failover](../concepts/replication.md#master-failover).
     * `shard_name`: Name of the shard the host will reside in.

     The host name must be unique within the cluster.

  1. Make sure the settings are correct.

     1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
     1. Run this command:
     
        ```bash
        terraform validate
        ```
     
        Terraform will show any errors found in your configuration files.

  1. Confirm updating the resources.

     1. Run this command to view the planned changes:
     
        ```bash
        terraform plan
        ```
     
        If 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.
     
     1. If everything looks correct, apply the changes:
        1. Run this command:
     
           ```bash
           terraform apply
           ```
     
        1. Confirm updating the resources.
        1. Wait for the operation to complete.

  For more information, see [this Terraform provider guide](../../terraform/resources/mdb_redis_cluster_v2.md).

  {% note warning "Timeouts" %}
  
  The Terraform provider sets the following timeouts for Yandex Managed Service for Valkey™ cluster operations:
  
  * Creating a cluster, including by restoring it from a backup: 15 minutes.
  * Editing a cluster: 60 minutes.
  * Deleting a cluster: 15 minutes.
  
  Operations exceeding the timeout are aborted.
  
  {% cut "How do I change these limits?" %}
  
  Add the `timeouts` section to your cluster description, such as the following:
  
  ```hcl
  resource "yandex_mdb_redis_cluster_v2" "<cluster_name>" {
    ...
    timeouts = {
      create = "1h30m" # 1 hour 30 minutes
      update = "2h"    # 2 hours
      delete = "30m"   # 30 minutes
    }
  }
  ```
  
  {% endcut %}
  
  {% endnote %}

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and place it in an environment variable:
    
        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```
    
    1. Call the [Cluster.AddHosts](../api-ref/Cluster/addHosts.md) method, e.g., via the following [cURL](https://curl.se/) request:
    
        
        ```bash
        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": <allow_public_access_to_host>
                        }
                      ]
                    }'
        ```
    
    
        Where `hostSpecs` sets the host parameters:
    
        * `zoneId`: [Availability zone](../../overview/concepts/geo-scope.md).
        * `subnetId`: [Subnet ID](../../vpc/concepts/network.md#subnet). Specify it if the selected availability zone has two or more subnets.
        * `shardName`: Shard name for the host. Only used if [cluster sharding](../concepts/sharding.md) is enabled.
        * `replicaPriority`: Host priority for master promotion during [failover](../concepts/replication.md#master-failover).
        * `assignPublicIp`: Internet access to the host via a public IP address, `true` or `false`. You can only enable public access if your cluster supports TLS.
    
        You can get the cluster ID from the [list of clusters in your folder](cluster-list.md#list-clusters).
    
    1. Check the [server response](../api-ref/Cluster/addHosts.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and place it in an environment variable:
    
        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```
    
    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
    
    1. Call the [ClusterService.AddHosts](../api-ref/grpc/Cluster/addHosts.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:
    
        
        ```bash
        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": <allow_public_access_to_host>
                    }
                  ] 
                }' \
            mdb.api.cloud.yandex.net:443 \
            yandex.cloud.mdb.redis.v1.ClusterService.AddHosts
        ```
    
    
        Where `host_specs` sets the host parameters:
    
        * `zone_id`: [Availability zone](../../overview/concepts/geo-scope.md).
        * `subnet_id`: [Subnet ID](../../vpc/concepts/network.md#subnet). Specify it if the selected availability zone has two or more subnets.
        * `shard_name`: Shard name for the host. Only used if [cluster sharding](../concepts/sharding.md) is enabled.
        * `replica_priority`: Host priority for master promotion during [failover](../concepts/replication.md#master-failover).
        * `assign_public_ip`: Internet access to the host via a public IP address, `true` or `false`. You can only enable public access if your cluster supports TLS.
    
        You can get the cluster ID from the [list of clusters in your folder](cluster-list.md#list-clusters).
    
    1. Check the [server response](../api-ref/grpc/Cluster/addHosts.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}


{% note warning %}

If you cannot [connect](connect/index.md) to the host you added, check that the cluster [security group](../concepts/network.md#security-groups) is properly configured for the subnet containing your host.

{% endnote %}


## Updating a host {#update}


{% note info %}

Hosts are only accessible from the internet via public IP addresses if you [created](cluster-create.md#create-cluster) the cluster with TLS support enabled.

{% endnote %}


{% list tabs group=instructions %}

- Management console {#console}

  To change the cluster host settings:
  1. Navigate to **Yandex Managed Service for&nbsp;Valkey™**.
  1. Click the name of your cluster and select the **Hosts** tab.
  1. Click ![image](../../_assets/console-icons/ellipsis.svg) in the host row and select **Edit**.

  
  1. Specify new host settings:

      1. Enable **Public access** if you want the host to be accessible from outside of Yandex Cloud.
      1. Specify [host priority for promotion to master](../concepts/replication.md#master-failover).


  1. Click **Save**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To change the host settings, run this command:

  
  ```bash
  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 get the host name with the [list of cluster hosts](#list), and the cluster name, with the [list of clusters in the folder](cluster-list.md#list-clusters).

- Terraform {#tf}

  To change the cluster host settings:
  1. Open the current Terraform configuration file with the infrastructure plan.

     For information on how to create this file, see [Creating a cluster](cluster-create.md).
  1. In the Yandex Managed Service for Valkey™ cluster description, change the settings of the relevant host in the `hosts` section:

     
     ```hcl
     resource "yandex_mdb_redis_cluster_v2" "<cluster_name>" {
       ...
       hosts = {
         ...
         "<host_name>" = {
           zone             = "<availability_zone>"
           subnet_id        = "<subnet_ID>"
           assign_public_ip = <public_access>
           replica_priority = <host_priority>
           shard_name       = "<shard_name>"
         }
       }
     }
     ```


     Where:

     * `zone_id`: [Availability zone](../../overview/concepts/geo-scope.md).

     
     * `subnet_id`: ID of the subnet in the selected availability zone.
     * `assign_public_ip`: Public access to the host, `true` or `false`.


     * `replica_priority`: Host priority for master promotion during [failover](../concepts/replication.md#master-failover).
     * `shard_name`: Name of the shard the host resides in.

  1. Make sure the settings are correct.

     1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
     1. Run this command:
     
        ```bash
        terraform validate
        ```
     
        Terraform will show any errors found in your configuration files.

  1. Confirm updating the resources.

     1. Run this command to view the planned changes:
     
        ```bash
        terraform plan
        ```
     
        If 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.
     
     1. If everything looks correct, apply the changes:
        1. Run this command:
     
           ```bash
           terraform apply
           ```
     
        1. Confirm updating the resources.
        1. Wait for the operation to complete.

  For more information, see [this Terraform provider guide](../../terraform/resources/mdb_redis_cluster_v2.md).

  {% note warning "Timeouts" %}
  
  The Terraform provider sets the following timeouts for Yandex Managed Service for Valkey™ cluster operations:
  
  * Creating a cluster, including by restoring it from a backup: 15 minutes.
  * Editing a cluster: 60 minutes.
  * Deleting a cluster: 15 minutes.
  
  Operations exceeding the timeout are aborted.
  
  {% cut "How do I change these limits?" %}
  
  Add the `timeouts` section to your cluster description, such as the following:
  
  ```hcl
  resource "yandex_mdb_redis_cluster_v2" "<cluster_name>" {
    ...
    timeouts = {
      create = "1h30m" # 1 hour 30 minutes
      update = "2h"    # 2 hours
      delete = "30m"   # 30 minutes
    }
  }
  ```
  
  {% endcut %}
  
  {% endnote %}

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Call the [Cluster.UpdateHosts](../api-ref/Cluster/updateHosts.md) method, e.g., via the following [cURL](https://curl.se/) request:

        {% note 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.
        
        {% endnote %}

        
        ```bash
        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` sets the host parameters:

        * `hostName`: Name of the host you need to update. To find out the name, [get the list of hosts in the cluster](#list).
        * `replicaPriority`: Host priority for master promotion during [failover](../concepts/replication.md#master-failover).
        * `assignPublicIp`: Host accessibility from the internet via a public IP address, `true` or `false`. You can only enable public access if your cluster supports TLS.
        * `updateMask`: Comma-separated string of settings to update.

        You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. Check the [server response](../api-ref/Cluster/updateHosts.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Call the [ClusterService.UpdateHosts](../api-ref/grpc/Cluster/updateHosts.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        {% note 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 of `paths[]` strings.
        
        {% cut "Format for listing settings" %}
        
        ```yaml
        "update_mask": {
            "paths": [
                "<setting_1>",
                "<setting_2>",
                ...
                "<setting_N>"
            ]
        }
        ```
        
        {% endcut %}
        
        {% endnote %}

        
        ```bash
        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` sets the host parameters:

        * `host_name`: Name of the host you need to update. To find out the name, [get the list of hosts in the cluster](#list).
        * `replica_priority`: Host priority for master promotion during [failover](../concepts/replication.md#master-failover).
        * `assign_public_ip`: Host accessibility from the internet via a public IP address, `true` or `false`. You can only enable public access if your cluster supports TLS.
        * `update_mask`: List of settings to update as an array of strings (`paths[]`).

        You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. Check the [server response](../api-ref/grpc/Cluster/updateHosts.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}


{% note warning %}

If you cannot [connect](connect/index.md) to the host you added, check that the cluster [security group](../concepts/network.md#security-groups) is properly configured for the subnet containing your host.

{% endnote %}


## Deleting a host {#remove}

You can delete a host from a Valkey™ cluster as long as it is not the only host in the cluster. To replace the only host, first create a new host and then delete the old one.

If you are deleting the master host, Managed Service for MySQL® will automatically promote another replica to master.

You cannot delete a host if the number of hosts in the cluster or shard is equal to the minimum allowed. For more information, see [Quotas and limits](../concepts/limits.md#mrd-limits).

{% list tabs group=instructions %}

- Management console {#console}

  To delete a host from a cluster:
  1. Navigate to **Yandex Managed Service for&nbsp;Valkey™**.
  1. Click the name of your cluster and select the **Hosts** tab.
  1. In the host row, click ![image](../../_assets/console-icons/ellipsis.svg) and select **Delete**.
  1. In the window that opens, enable **Delete host** and click **Confirm**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To delete a host from a cluster, run this command:

  ```bash
  yc managed-redis host delete <host_name> \
    --cluster-name=<cluster_name>
  ```

  You can get the host name with the [list of cluster hosts](#list), and the cluster name, with the [list of clusters in the folder](cluster-list.md#list-clusters).

- Terraform {#tf}

  To delete a host from a cluster:
  1. Open the current Terraform configuration file with the infrastructure plan.

     For information on how to create this file, see [Creating a cluster](cluster-create.md).
  1. In the Yandex Managed Service for Valkey™ cluster description, delete the relevant host from the `hosts` section.
  1. Make sure the settings are correct.

     1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
     1. Run this command:
     
        ```bash
        terraform validate
        ```
     
        Terraform will show any errors found in your configuration files.

  1. Type `yes` and press **Enter**.

     1. Run this command to view the planned changes:
     
        ```bash
        terraform plan
        ```
     
        If 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.
     
     1. If everything looks correct, apply the changes:
        1. Run this command:
     
           ```bash
           terraform apply
           ```
     
        1. Confirm updating the resources.
        1. Wait for the operation to complete.

  For more information, see [this Terraform provider guide](../../terraform/resources/mdb_redis_cluster_v2.md).

  {% note warning "Timeouts" %}
  
  The Terraform provider sets the following timeouts for Yandex Managed Service for Valkey™ cluster operations:
  
  * Creating a cluster, including by restoring it from a backup: 15 minutes.
  * Editing a cluster: 60 minutes.
  * Deleting a cluster: 15 minutes.
  
  Operations exceeding the timeout are aborted.
  
  {% cut "How do I change these limits?" %}
  
  Add the `timeouts` section to your cluster description, such as the following:
  
  ```hcl
  resource "yandex_mdb_redis_cluster_v2" "<cluster_name>" {
    ...
    timeouts = {
      create = "1h30m" # 1 hour 30 minutes
      update = "2h"    # 2 hours
      delete = "30m"   # 30 minutes
    }
  }
  ```
  
  {% endcut %}
  
  {% endnote %}

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and place it in an environment variable:
    
        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```
    
    1. Call the [Cluster.DeleteHosts](../api-ref/Cluster/deleteHosts.md) method, e.g., via the following [cURL](https://curl.se/) request:
    
        ```bash
        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 the list of hosts in the cluster](hosts.md#list).
    
        You can get the cluster ID from the [list of clusters in your folder](cluster-list.md#list-clusters).
    
    1. Check the [server response](../api-ref/Cluster/deleteHosts.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and place it in an environment variable:
    
        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```
    
    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
    
    1. Call the [ClusterService.DeleteHosts](../api-ref/grpc/Cluster/deleteHosts.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:
    
        ```bash
        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 the list of hosts in the cluster](hosts.md#list).
    
        You can get the cluster ID from the [list of clusters in your folder](cluster-list.md#list-clusters).
    
    1. Check the [server response](../api-ref/grpc/Cluster/deleteHosts.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}