1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 09:46:53 +01:00
Files
openshift-docs/modules/nodes-nodes-working-evacuating.adoc
2020-11-11 15:34:12 -05:00

117 lines
3.0 KiB
Plaintext

// Module included in the following assemblies:
//
// * nodes/nodes-nodes-working.adoc
[id="nodes-nodes-working-evacuating_{context}"]
= Understanding how to evacuate pods on nodes
Evacuating pods allows you to migrate all or selected pods from a given node or
nodes.
You can only evacuate pods 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. Pod selectors are
based on labels, so all the pods with the specified label will be evacuated.
.Procedure
. Mark the nodes unschedulable before performing the pod evacuation.
.. Mark the node as unschedulable:
+
[source,terminal]
----
$ oc adm cordon <node1>
----
+
.Example output
[source,terminal]
----
node/<node1> cordoned
----
.. Check that the node status is `NotReady,SchedulingDisabled`:
+
[source,terminal]
----
$ oc get node <node1>
----
+
.Example output
[source,terminal]
----
NAME STATUS ROLES AGE VERSION
<node1> NotReady,SchedulingDisabled worker 1d v1.19.0
----
. Evacuate the pods using one of the following methods:
** Evacuate all or selected pods on one or more nodes:
+
[source,terminal]
----
$ oc adm drain <node1> <node2> [--pod-selector=<pod_selector>]
----
** Force the deletion of bare pods using the `--force` option. When set to
`true`, deletion continues even if there are pods not managed by a replication
controller, replica set, job, daemon set, or stateful set:
+
[source,terminal]
----
$ oc adm drain <node1> <node2> --force=true
----
** Set a period of time in seconds for each Pod to
terminate gracefully, use `--grace-period`. If negative, the default value specified in the Pod will
be used:
+
[source,terminal]
----
$ oc adm drain <node1> <node2> --grace-period=-1
----
** Ignore DaemonSet-managed pods using the `--ignore-daemonsets` flag set to `true`:
+
[source,terminal]
----
$ oc adm drain <node1> <node2> --ignore-daemonsets=true
----
** Set the length of time to wait before giving up using the `--timeout` flag. A
value of `0` sets an infinite length of time:
+
[source,terminal]
----
$ oc adm drain <node1> <node2> --timeout=5s
----
** Delete pods even if there are pods using emptyDir using the `--delete-local-data` flag set to `true`. Local data is deleted when the node
is drained:
+
[source,terminal]
----
$ oc adm drain <node1> <node2> --delete-local-data=true
----
** List objects that will be migrated without actually performing the evacuation,
using the `--dry-run` option set to `true`:
+
[source,terminal]
----
$ oc adm drain <node1> <node2> --dry-run=true
----
+
Instead of specifying specific node names (for example, `<node1> <node2>`), you
can use the `--selector=<node_selector>` option to evacuate pods on selected
nodes.
. Mark the node as schedulable when done.
+
[source,terminal]
----
$ oc adm uncordon <node1>
----