Before you restart or release an ECS instance in a Kubernetes cluster, you need to remove the ECS node from the cluster. This topic describes how to remove a node from a Kubernetes cluster.

Prerequisites

Background information

  • Removing a node causes pod migration. This may affect the services provided by the pods running on the node. Therefore, we recommend that you remove a node only when fewer services are in demand.
  • Removing a node may cause unintended risks. We recommend that you back up your data in advance and exercise caution when performing this action.
  • When you start to remove a node, the node is automatically set to the unschedulable status.
  • Only Worker nodes can be removed.

Procedure

  1. Run the following command to migrate the pods on the target node to other nodes:
    Note You must ensure that other nodes in the Kubernetes cluster have sufficient resources to run the pods that you want to migrate.
    kubectl drain node-name
    Note The node-name parameter must be in the format of your-region-name.node-id.
    • your-region-name indicates the name of the region where your cluster resides.
    • node-id indicates the ID of the ECS instance in which the node to be removed resides. For example, cn-hanghzou.i-xxx.
  2. In the left-side navigation pane under Kubernetes, choose Clusters > Nodes.
  3. Under the target cluster, select the target node, and choose More > Remove in the Action column.

    Note If you want to remove multiple nodes at a time, you can select the target cluster on the Node List page, select all the nodes to be removed, and then click Remove.

  4. Optional: Select the Release ECS at the Same Time check box to permanently release the ECS instance where the node resides.

    Note
    • Only Pay-As-You-Go ECS instances can be released.
    • A Subscription ECS instance will be released automatically when it expires.
    • If you do not select the Release ECS at the Same Time check box, the ECS instance in which the node resides will continue to be charged.
  5. Click OK.