1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/powering-off-bare-metal-hosts-web-console.adoc
2025-01-31 17:00:25 +00:00

84 lines
2.9 KiB
Plaintext

// Module included in the following assemblies:
//
// scalability_and_performance/managing-bare-metal-hosts.adoc
:_mod-docs-content-type: PROCEDURE
[id="powering-off-bare-metal-hosts-web-console_{context}"]
= Powering off bare-metal hosts
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`).
Before you power off a host, you should mark the node as unschedulable and drain all pods and workloads from the node.
.Prerequisites
* You have installed a {op-system} compute machine on bare-metal infrastructure for use in the cluster.
* You have logged in as a user with `cluster-admin` privileges.
* You have configured the host to be managed and have added BMC credentials for the cluster host.
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.
.Procedure
. In the web console, mark the node that you want to power off as unschedulable. Perform the following steps:
.. Navigate to *Nodes* and select the node that you want to power off. Expand the *Actions* menu and select *Mark as unschedulable*.
.. Manually delete or relocate running pods on the node by adjusting the pod deployments or scaling down workloads on the node to zero.
Wait for the drain process to complete.
.. Navigate to *Compute* -> *Bare Metal Hosts*.
.. Expand the *Options menu* for the bare-metal host that you want to power off, and select *Power Off*.
Select *Immediate power off*.
. Alternatively, you can patch the `BareMetalHost` resource for the host that you want to power off by using `oc`.
.. Get the name of the managed bare-metal host.
Run the following command:
+
[source,terminal]
----
$ oc get baremetalhosts -n openshift-machine-api -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.provisioning.state}{"\n"}{end}'
----
+
.Example output
[source,terminal]
----
master-0.example.com managed
master-1.example.com managed
master-2.example.com managed
worker-0.example.com managed
worker-1.example.com managed
worker-2.example.com managed
----
.. Mark the node as unschedulable:
+
[source,terminal]
----
$ oc adm cordon <bare_metal_host> <1>
----
<1> `<bare_metal_host>` is the host that you want to shut down, for example, `worker-2.example.com`.
.. Drain all pods on the node:
+
[source,terminal]
----
$ oc adm drain <bare_metal_host> --force=true
----
+
Pods that are backed by replication controllers are rescheduled to other available nodes in the cluster.
.. Safely power off the bare-metal host.
Run the following command:
+
[source,terminal]
----
$ oc patch <bare_metal_host> --type json -p '[{"op": "replace", "path": "/spec/online", "value": false}]'
----
.. After you power on the host, make the node schedulable for workloads.
Run the following command:
+
[source,terminal]
----
$ oc adm uncordon <bare_metal_host>
----