|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// scalability_and_performance/managing-bare-metal-hosts.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="powering-off-bare-metal-hosts-web-console_{context}"] |
| 7 | += Powering off bare-metal hosts |
| 8 | + |
| 9 | +You can power off bare-metal cluster hosts in the web console or by applying a patch in the cluster by using the OpenShift CLI (`oc`). |
| 10 | +Before you power off a host, you should mark the node as unschedulable and drain all pods and workloads from the node. |
| 11 | + |
| 12 | +.Prerequisites |
| 13 | +* You have installed a {op-system} compute machine on bare-metal infrastructure for use in the cluster. |
| 14 | +* You have logged in as a user with `cluster-admin` privileges. |
| 15 | +* You have configured the host to be managed and have added BMC credentials for the cluster host. |
| 16 | +You can add BMC credentials by applying a `Secret` custom resource (CR) in the cluster or by logging in to the web console and configuring the bare-metal host to be managed. |
| 17 | +
|
| 18 | +.Procedure |
| 19 | +. In the web console, mark the node that you want to power off as unschedulable. Perform the following steps: |
| 20 | + |
| 21 | +.. Navigate to *Nodes* and select the node that you want to power off. Expand the *Actions* menu and select *Mark as unschedulable*. |
| 22 | + |
| 23 | +.. Manually delete or relocate running pods on the node by adjusting the pod deployments or scaling down workloads on the node to zero. |
| 24 | +Wait for the drain process to complete. |
| 25 | + |
| 26 | +.. Navigate to *Compute* -> *Bare Metal Hosts*. |
| 27 | + |
| 28 | +.. Expand the *Options menu* for the bare-metal host that you want to power off, and select *Power Off*. |
| 29 | +Select *Immediate power off*. |
| 30 | + |
| 31 | +. Alternatively, you can patch the `BareMetalHost` resource for the host that you want to power off by using `oc`. |
| 32 | + |
| 33 | +.. Get the name of the managed bare-metal host. |
| 34 | +Run the following command: |
| 35 | ++ |
| 36 | +[source,terminal] |
| 37 | +---- |
| 38 | +$ oc get baremetalhosts -n openshift-machine-api -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.provisioning.state}{"\n"}{end}' |
| 39 | +---- |
| 40 | ++ |
| 41 | +.Example output |
| 42 | +[source,terminal] |
| 43 | +---- |
| 44 | +master-0.example.com managed |
| 45 | +master-1.example.com managed |
| 46 | +master-2.example.com managed |
| 47 | +worker-0.example.com managed |
| 48 | +worker-1.example.com managed |
| 49 | +worker-2.example.com managed |
| 50 | +---- |
| 51 | + |
| 52 | +.. Mark the node as unschedulable: |
| 53 | ++ |
| 54 | +[source,terminal] |
| 55 | +---- |
| 56 | +$ oc adm cordon <bare_metal_host> <1> |
| 57 | +---- |
| 58 | +<1> `<bare_metal_host>` is the host that you want to shut down, for example, `worker-2.example.com`. |
| 59 | + |
| 60 | +.. Drain all pods on the node: |
| 61 | ++ |
| 62 | +[source,terminal] |
| 63 | +---- |
| 64 | +$ oc adm drain <bare_metal_host> --force=true |
| 65 | +---- |
| 66 | ++ |
| 67 | +Pods that are backed by replication controllers are rescheduled to other available nodes in the cluster. |
| 68 | + |
| 69 | +.. Safely power off the bare-metal host. |
| 70 | +Run the following command: |
| 71 | ++ |
| 72 | +[source,terminal] |
| 73 | +---- |
| 74 | +$ oc patch <bare_metal_host> --type json -p '[{"op": "replace", "path": "/spec/online", "value": false}]' |
| 75 | +---- |
| 76 | + |
| 77 | +.. After you power on the host, make the node schedulable for workloads. |
| 78 | +Run the following command: |
| 79 | ++ |
| 80 | +[source,terminal] |
| 81 | +---- |
| 82 | +$ oc adm uncordon <bare_metal_host> |
| 83 | +---- |
0 commit comments