Automatically clean up NotReady nodes
When you scale in a node pool in a registered cluster, nodes may enter the NotReady state. If these nodes are not cleaned up promptly, cluster resources may be wasted. The cloud-node-controller add-on cleans up NotReady nodes automatically to prevent resource waste.
Prerequisites
-
A standard node pool is created and scaled out. For instructions, see Create and manage node pools.
-
A kubectl client is connected to the registered cluster. For instructions, see Connect to a cluster by using kubectl.
Procedure
Before you install the add-on in a registered cluster, create a Resource Access Management (RAM) user with the required permissions and configure an AccessKey pair that grants the RAM user access to Alibaba Cloud resources.
Step 1: Configure permissions for the cloud-node-controller add-on
-
Create a RAM user and grant the following custom policy to the RAM user. For instructions, see Grant permissions to a RAM user.
{ "Version": "1", "Statement": [ { "Action": [ "ecs:DescribeInstances" # Allows querying the details of Elastic Compute Service (ECS) instances. ], "Resource": [ "*" ], "Effect": "Allow" } ] } -
Run the following command to configure the AccessKey pair of the RAM user.
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, grant the preceding custom permissions to the RAM user that is associated with the Secret.
Step 2: Install the cloud-node-controller add-on
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your cluster. In the left navigation pane, click Components and Add-ons .
-
On the Add-ons page, click the Core Components tab. Find the cloud-node-controller add-on and click Install in the lower-right corner of the card.
Step 3: Check the add-on status
-
Run the following command to check the status of the cloud-node-controller add-on.
kubectl get pods -n kube-system | grep cloud-node-controllerExpected output:
cloud-node-controller-abcXXX 1/1 Running 0 5m -
After the add-on is deployed, the system automatically cleans up nodes that are in the NotReady state.