All Products
Search
Document Center

Container Service for Kubernetes:How to clear NotReady nodes automatically

Last Updated:Jul 30, 2024

When you use the node pool feature in a registered cluster, and you scale in the node pool, the status of some nodes may become NotReady. If these nodes are not cleaned up, it may lead to resource waste. This topic describes how to use the cloud-node-controller component to automatically clean up NotReady nodes.

Prerequisites

Procedure

Before you install the component in the registered cluster, you need to create a Resource Access Management (RAM) user, grant the required permissions, and configure the AccessKey pair to access the relevant cloud resources.

Step 1: Configure permissions for the cloud-node-controller component

  1. Create a RAM user and grant the following custom permission policy. For more information, see Create a custom RAM policy.

    {
        "Version": "1",
        "Statement": [
            {
                "Action": [
                    "ecs:DescribeInstances"      # Allow querying detailed information of ECS instances.
                ],
                "Resource": [
                    "*"
                ],
                "Effect": "Allow"
            }
        ]
    }
  2. Run the following commands to configure the AccessKey information for the RAM policy:

    export ACCESS_KEY_ID=<ACCESS KEY ID>
    export ACCESS_KEY_SECRET=<ACCESS KEY SECRET>
  3. Run the following command to create a Secret named alibaba-addon-secret:

    kubectl -n kube-system create secret generic alibaba-addon-secret --from-literal='access-key-id=${ACCESS_KEY_ID}' --from-literal='access-key-secret=${ACCESS_KEY_SECRET}'
    Note

    If the Secret already exists, you need to grant the RAM user of the Secret the above custom permissions.

Step 2: Install the cloud-node-controller component

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the cluster that you want to manage and click its name. In the left-side navigation pane, choose Operations > Add-ons.

  3. On the Add-ons page, under the Core Components tab, find the cloud-node-controller card and click Install in the lower-right corner.

Step 3: Check the component status

  1. Run the following command to check the status of the cloud-node-controller component:

    kubectl get pods -n kube-system | grep cloud-node-controller

    Expected output:

    cloud-node-controller-abcXXX    1/1     Running   0     5m
  2. After the component is installed, the system automatically cleans up nodes that are in the NotReady state.