Blame docs/operations/ci/cordoning_nodes_and_draining_pods.md

47c289
# Cordoning Nodes and Draining Pods
47c289
This SOP should be followed in the following scenarios:
47c289
47c289
- If maintenance is scheduled to be carried out on an Openshift node.
47c289
47c289
47c289
## Steps
47c289
47c289
1. Mark the node as unschedulable:
47c289
47c289
```
47c289
nodes=$(oc get nodes -o name  | sed -E "s/node\///")
47c289
echo $nodes
47c289
47c289
for node in ${nodes[@]}; do oc adm cordon $node; done
47c289
node/<node> cordoned
47c289
```
47c289
47c289
2. Check that the node status is `NotReady,SchedulingDisabled`
47c289
47c289
```
47c289
oc get node <node1>
47c289
NAME        STATUS                        ROLES     AGE       VERSION
47c289
<node1>     NotReady,SchedulingDisabled   worker    1d        v1.18.3
47c289
```
47c289
47c289
Note: It might not switch to `NotReady` immediately, there maybe many pods still running.
47c289
47c289
47c289
3. Evacuate the Pods from **worker nodes** using one of the following methods
47c289
This will drain node `<node1>`, delete any local data, and ignore daemonsets, and give a period of 60 seconds for pods to drain gracefully.
47c289
47c289
```
47c289
oc adm drain <node1> --delete-local-data=true --ignore-daemonsets=true --grace-period=60
47c289
```
47c289
47c289
4. Perform the scheduled maintenance on the node
47c289
Do what ever is required in the scheduled maintenance window
47c289
47c289
47c289
5. Once the node is ready to be added back into the cluster
47c289
We must uncordon the node. This allows it to be marked scheduleable once more.
47c289
47c289
```
47c289
nodes=$(oc get nodes -o name  | sed -E "s/node\///")
47c289
echo $nodes
47c289
47c289
for node in ${nodes[@]}; do oc adm uncordon $node; done
47c289
```
47c289
47c289
47c289
### Resources
47c289
47c289
- [1] [Nodes - working with nodes](https://docs.openshift.com/container-platform/4.5/nodes/nodes/nodes-nodes-working.html)