6.2. Working with nodes
As an administrator, you can perform several tasks to make your clusters more efficient.
6.2.1. Evacuating pods on nodes 링크 복사링크가 클립보드에 복사되었습니다!
You can remove, or evacuate, pods from a given node or nodes. Evacuating pods allows you to migrate all or selected pods to other nodes.
You can evacuate only pods that are backed by a replication controller. The replication controller creates new pods on other nodes and removes the existing pods from the specified node(s).
Bare pods, meaning those not backed by a replication controller, are unaffected by default. You can evacuate a subset of pods by specifying a pod selector. Because pod selectors are based on labels, all of the pods with the specified label are evacuated.
Procedure
Mark the nodes as unschedulable before performing the pod evacuation.
Mark the node as unschedulable by running the following command:
$ oc adm cordon <node1>Example output
node/<node1> cordonedCheck that the node status is
Ready,SchedulingDisabledby running the following command:$ oc get node <node1>Example output
NAME STATUS ROLES AGE VERSION <node1> Ready,SchedulingDisabled worker 1d v1.34.2
Evacuate the pods by using one of the following methods:
Evacuate all or selected pods on one or more nodes by running the
oc adm draincommand:$ oc adm drain <node1> <node2> [--pod-selector=<pod_selector>]Force the deletion of bare pods by using the
--forceoption with theoc adm draincommand. When set totrue, deletion continues even if there are pods not managed by a replication controller, replica set, job, daemon set, or stateful set.$ oc adm drain <node1> <node2> --force=trueSet a period of time in seconds for each pod to terminate gracefully by using the
--grace-periodoption with theoc adm draincommand. If negative, the default value specified in the pod will be used:$ oc adm drain <node1> <node2> --grace-period=-1Ignore pods managed by daemon sets by using the
--ignore-daemonsets=trueoption with theoc adm draincommand:$ oc adm drain <node1> <node2> --ignore-daemonsets=trueSet the length of time to wait before giving up using the
--timeoutoption with theoc adm draincommand. A value of0sets an infinite length of time.$ oc adm drain <node1> <node2> --timeout=5sDelete pods even if there are pods using
emptyDirvolumes by setting the--delete-emptydir-data=trueoption with theoc adm draincommand. Local data is deleted when the node is drained.$ oc adm drain <node1> <node2> --delete-emptydir-data=trueList objects that would be migrated without actually performing the evacuation, by using the
--dry-run=trueoption with theoc adm draincommand:$ oc adm drain <node1> <node2> --dry-run=trueInstead of specifying specific node names (for example,
<node1> <node2>), you can use the--selector=<node_selector>option with theoc adm draincommand to evacuate pods on selected nodes.
Mark the node as schedulable when done by using the following command.
$ oc adm uncordon <node1>