[Yandex Cloud documentation](../../../index.md) > [Yandex Managed Service for Kubernetes](../../index.md) > [Step-by-step guides](../index.md) > Managing a node group > Node maintenance with zero resource loss

# Cluster node maintenance with zero resource loss

During maintenance and update, you may need to restart or recreate Managed Service for Kubernetes cluster nodes. In which case node resources become publicly available again and can be taken by other users.

Reservation is especially relevant for limited availability resources, such as GPUs. If the GPU configuration turns out occupied during the GPU node restart, the start will terminate with an error.

There are two ways for you to preserve your resources during maintenance:

* [Using a reserved instance pool](#with-reserved-pool): Suitable for any node restart or recreation scenarios.
* [Using a maintenance task](#with-maintenance-task): Suitable if there is a node maintenance task in Compute Cloud.

## Using a reserved instance pool {#with-reserved-pool}

{% note warning %}

Reserved instance pools are billable: you pay for the whole unused volume of reserved computing resources of VMs, GPU clusters, and software accelerated networks according to the [Yandex Compute Cloud pricing policy](../../../compute/pricing.md). For more information, see [Using reserved instance pools](../../../compute/pricing.md#pool).

{% endnote %}

_The reserved instance pool feature is at the [Preview stage](../../../overview/concepts/launch-stages.md)._

Node resources can be reserved using a [reserved instance pool](../../../compute/concepts/reserved-pools.md). In this case, during node restart or recreation, its resources will remain in the pool and not go public: the node will start on exactly the same resources.

1. [Create a reserved instance pool](../../../compute/operations/reserved-pools/create-reserved-pool.md) of size `0` with a configuration of existing nodes, e.g., with required GPU parameters.

1. [Expand the pool](../../../compute/operations/reserved-pools/update-reserved-pool.md) to as many nodes as you need by activating the `--allow-pending-slots` [resource wait option](../../../compute/concepts/reserved-pools.md#pending-slots). This parameter allows you to add slots, even if there are not enough free resources in the availability zone temporarily.

   Slots that did not get enough resources during the expansion will enter the `pending` status.

1. [Attach the nodes](../../../compute/operations/reserved-pools/manage-pool-vms.md#attach-existing-vm) of the existing Managed Service for Kubernetes cluster to the new pool.

The Managed Service for Kubernetes cluster nodes will occupy free slots in the pool. Next, the nodes will be started or recreated on the pool’s reserved resources.

## Using a maintenance task {#with-maintenance-task}

{% note warning %}

This zero resource loss maintenance method only suits scenarios where Compute Cloud has set a [maintenance task](../../../compute/operations/vm-control/gpus-maintenance.md#list-scheduled-maintenance).

If you want to restart or recreate a node with zero resource loss by yourself, [use a reserved instance pool](#with-reserved-pool).

{% endnote %}

Compute Cloud performs periodical [maintenance](../../../compute/concepts/gpus-maintenance.md) of the hardware your VMs need to operate. Sometimes maintenance implies restarting the GPU VMs.

To complete the maintenance task, GPU VM resources are reserved automatically and not made public again on restart: for maintenance it is enough to remove load from the node and perform a restart via Compute Cloud.

1. To figure out which node requires maintenance, [look up maintenance tasks](../../../compute/operations/vm-control/gpus-maintenance.md#list-scheduled-maintenance).

1. Make sure `kubectl` is connected to the right cluster and get a list of nodes:

    ```bash
    kubectl config current-context
    kubectl get nodes
    ```

    The node name in the command output matches the VM name in Compute Cloud.

1. Evict the pods from the node using `kubectl drain`:

    ```bash
    kubectl drain <node_name> \
      --ignore-daemonsets \
      --delete-emptydir-data
    ```

    Where `<node_name>` is the Kubernetes node name.

    After the command is executed, the node will enter the `SchedulingDisabled` status: new pods will no longer be created on it, and current active pods will be evicted to other cluster nodes.

    For more on pod eviction, see [Evicting pods from nodes](../../concepts/node-group/node-drain.md).

1. [Run the maintenance task immediately](../../../compute/operations/vm-control/gpus-maintenance.md#execute-now). The VM will restart but Compute Cloud will keep the GPU resources assigned to it.

1. Use the [management console](../kubernetes-console/nodes.md#uncordon) or this command to allow pods to be put on the node:

    ```bash
    kubectl uncordon <node_name>
    ```

    The node will once again become available for new pod scheduling.

#### Useful links {#see-also}

* [Evicting pods from nodes](../../concepts/node-group/node-drain.md)
* [Maintenance of GPU VMs](../../../compute/concepts/gpus-maintenance.md)
* [Managing maintenance of GPU VMs](../../../compute/operations/vm-control/gpus-maintenance.md)
* [Creating a group with nodes from a Yandex Compute Cloud reserved instance pool](node-group-create-in-instance-pool.md)