Overview
This document explains how to drain or cordon a node.
Directions
Cordoning a Node
After cordoning a node, new Pods cannot be scheduled to it. If you want to schedule a Pod to the node, you need to uncordon the node manually. If a node has been bound as backend target node, it will be removed from the target node list after it is condoned. You can cordon a node with one of the following two methods:
- When adding a node, on the CVM Configuration page, click Advanced Settings and select Cordon this node.
- Log in to the TKE console.
- In the left sidebar, click Clusters to go to the cluster management page.
- Click the ID/name of the cluster where to cordon the node to go to the cluster management page as shown below.
- In the left sidebar, select Node Management > Nodes to go to the Node List page.
- In the node list, select the row of the node to be cordoned and click Cordon as shown below.
- In the pop-up dialog box, click OK to complete the cordoning.
Uncordoning a Node
After a node is uncordoned, new Pods can be scheduled to it. You can uncordon a node with one of the following two methods:
When you create a node by running a script, you can uncordon it by adding a command for uncordoning the node in the script. Below is an example:
#!/bin/sh
# your initialization script
echo "hello world!"
# If you set unschedulable when you create a node,
# after executing your initialization script,
# use the following command to make the node schedulable.
node=`ps -ef|grep kubelet|grep -oE 'hostname-override=\S+'|cut -d"=" -f2`
#echo ${node}
kubectl uncordon ${node} --kubeconfig=/root/.kube/config
The kubectl uncordon
command indicates uncordoning the node.
- Log in to the TKE console.
- In the left sidebar, click Clusters to go to the cluster management page.
- Click the ID/name of the cluster where to uncordon the node to go to the management page of the cluster. See the figure below:
- In the left sidebar, select Node Management > Nodes to go to the Node List page.
- In the node list, select the row of the node to be uncordoned and click Uncordon as shown below.
- In the pop-up dialog box, click OK to complete the uncordoning.
Draining a Node
Overview
Before performing maintenance on a node, you can safely drain a Pod from a node by draining the node. After the node is drained, all Pods (excluding those managed by DaemonSet) in the node will be automatically drained to other nodes in the cluster, and the drained node will be set to cordoned status.
Note:
For locally stored Pods, data will be lost after they are drained. Please be cautious when doing so.
Directions
- Log in to the TKE console.
- In the left sidebar, click Clusters to go to the cluster management page.
- Click the ID/name of the cluster where to drain the node to go to the management page of the cluster. See the figure below:
- In the left sidebar, select Node Management > Nodes to go to the Node List page.
- Click More > Drain in the row of the node to be drained. See the figure below:
- In the pop-up dialog box, click OK to complete the draining.
Apakah halaman ini membantu?