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
A regular node pool is created and scaled out. For more information, see Create and scale out a node pool.
A kubectl client is connected to the registered cluster. For more information, see Use kubectl to connect to the cluster.
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
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" } ] }
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>
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}'
NoteIf 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
Log on to the ACK console. In the left-side navigation pane, click Clusters.
On the Clusters page, find the cluster that you want to manage and click its name. In the left-side navigation pane, choose .
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
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
After the component is installed, the system automatically cleans up nodes that are in the NotReady state.