Chapter 6. Creating and modifying bare metal assets
Bare metal assets are virtual or physical servers that you configure to run your OpenShift Container Platform clusters. Red Hat Advanced Cluster Management for Kubernetes connects to a bare metal asset that your administrator creates. Then you can deploy the bare metal asset in a managed cluster.
The hub cluster inventory controller defines a custom resource definition (CRD) called BareMetalAsset
, that holds the bare metal asset inventory record. When provisioning a managed cluster, the inventory controller reconciles BareMetalAsset
inventory records with corresponding BareMetalHost
resources in the managed cluster.
Red Hat Advanced Cluster Management uses BareMetalAsset
CRs to provision cluster hardware based on records entered in a configuration management database (CMDB), or similar system. An external tool or automation polls the CMDB and uses the Red Hat Advanced Cluster Management API to create corresponding BareMetalAsset
and corresponding Secret
resources in a hub cluster for subsequent deployment in a managed cluster.
Use the following procedures to create and manage bare metal assets for clusters managed by Red Hat Advanced Cluster Management.
6.1. Prerequisites
You need the following prerequisites before creating a bare metal asset:
- A deployed Red Hat Advanced Cluster Management hub cluster on OpenShift Container Platform version 4.6, or later.
- Access for your Red Hat Advanced Cluster Management hub cluster to connect to the bare metal asset.
A configured bare metal asset, and log in credentials with the required permissions to log in and manage it.
Note: Credentials for your bare metal asset include the following items for the asset that are provided by your administrator: user name password Baseboard Management Controller (BMC) Address boot NIC MAC address
6.2. Creating a bare metal asset with the console
To create a bare metal asset using the Red Hat Advanced Cluster Management for Kubernetes console, complete the following steps:
- From the navigation menu, navigate to Infrastructure > Bare metal assets.
- On the Bare metal assets page, click Create bare metal asset.
- Enter a name for your asset that identifies it when you create a cluster.
Enter the namespace where you want to create the bare metal asset.
Note: The bare metal asset, managed bare metal cluster, and its related secret must be in the same namespace.
Users who have access to this namespace can associate this asset to the cluster when creating a cluster.
Enter the BMC address. This is the controller that enables communication with the host. The following protocols are supported:
- IPMI, see IPMI 2.0 Specification for more information.
- iDRAC, see Support for Integrated Dell Remote Access Controller 9 (iDRAC9) for more information.
- iRMC, see Data Sheet: FUJITSU Software ServerView Suite integrated Remote Management Controller - iRMC S5 for more information.
- Redfish, see Redfish specification for more information.
- Enter the username and password for the bare metal asset.
- Add the boot NIC MAC address for the bare metal asset. This is the MAC address of the host’s network-connected NIC that is used to provision the host on the bare metal asset.
You can continue with Creating a cluster on bare metal.
6.3. Creating a bare metal asset using the CLI
Use a BareMetalAsset
CR to create a bare metal asset for a particular namespace in the cluster. Each BareMetalAsset
also has a corresponding Secret
that contains the Baseboard Management Controller (BMC) credentials and the secret name in the same namespace.
6.3.1. Prerequisites
- Install Red Hat Advanced Cluster Management for Kubernetes on a hub cluster.
- Install the Red Hat OpenShift CLI (oc).
-
Log in as a user with
cluster-admin
privileges.
6.3.2. Create the bare metal asset
- Install and provision a bare metal asset in your environment.
- Power on the BMC, and note the IPMI or Redfish BMC address and MAC address for the hardware.
Create the following
BareMetalAsset
andSecret
CR, and save the file asbaremetalasset-cr.yaml
:apiVersion: inventory.open-cluster-management.io/v1alpha1 kind: BareMetalAsset metadata: name: <baremetalasset-machine> namespace: <baremetalasset-namespace> spec: bmc: address: ipmi://<out_of_band_ip>:<port> credentialsName: baremetalasset-machine-secret bootMACAddress: "00:1B:44:11:3A:B7" hardwareProfile: "hardwareProfile" role: "<role>" clusterName: "<cluster name>" --- apiVersion: v1 kind: Secret metadata: name: baremetalasset-machine-secret type: Opaque data: username: <username> password: <password>
-
Replace
baremetalasset-machine
with the name of the machine where the bare metal asset is located. When created, theBareMetalHost
on the managed cluster gets the same name as the correspondingBareMetalAsset
on the hub cluster. TheBareMetalHost
name should always match the correspondingBareMetalAsset
name. -
Replace
baremetalasset-namespace
with the cluster namespace where the bare metal asset is created. -
Replace
out_of_band_ip
andport
with the address and port for your bare metal asset. For Redfish addressing, use the following address format:redfish://<out-of-band-ip>/redfish/v1/Systems/1
. -
Replace
role
withworker
,master
, or leave it empty, depending on the machine role type. Therole
setting is used to match a bare metal asset to specific machine role types in the cluster.BareMetalAsset
resources with a specified machine role type should not be used to fill another role. Therole
value is used as the value for a label with keyinventory.open-cluster-management.io/role
. This enables a cluster management application or user to query for inventory that is intended for a particular role. -
Replace
cluster_name
with the name of your cluster, which is used by the cluster management application or user to query for inventory that is associated with a particular cluster. Leave this value empty to create the bare metal asset without adding it to a cluster deployment. -
Replace
username
with the username for your secret. -
Replace
password
with the password for your secret.
-
Replace
Run the following command to create the
BareMetalAsset
CR:$ oc create -f baremetalasset-cr.yaml
Check that the
BareMetalAsset
is created successfully:$ oc get baremetalassets -A
Example output
NAMESPACE NAME AGE ocp-example-bm baremetalasset-machine 2m ocp-example-bm csv-f24-h27-000-r630-master-1-1 4d21h
6.4. Bulk importing bare metal assets with the console
You can import bare metal assets in bulk using the Red Hat Advanced Cluster Management for Kubernetes console using a CSV formatted list.
6.4.1. Prerequisites
- Install Red Hat Advanced Cluster Management on a hub cluster that manages one or more spoke clusters.
- Install the OpenShift Container Platform CLI (oc).
-
Log in as a user with
cluster-admin
privileges.
6.4.2. Import the assets
To import a set of bare metal assets, complete the following steps:
- From the Red Hat Advanced Cluster Management console, select Cluster management > Bare metal assets in the navigation menu.
Select Import assets, and import the CSV file that contains the bare metal assets data. The CSV file must have the following header columns:
hostName, hostNamespace, bmcAddress, macAddress, role (optional), username, password
6.5. Modifying a bare metal asset
If you need to modify the settings for a bare metal asset, complete the following steps:
- In the Red Hat Advanced Cluster Management for Kubernetes console navigation, select: Infrastructure > Bare metal assets.
- Select the options menu for the asset that you want to modify in the table.
- Select Edit asset.
6.6. Removing a bare metal asset
When a bare metal asset is no longer used for any of the clusters, you can remove it from the list of available bare metal assets. Removing unused assets both simplifies your list of available assets, and prevents the accidental selection of that asset.
To remove a bare metal asset in the console, complete the following steps:
- In the Red Hat Advanced Cluster Management for Kubernetes console navigation, select: Infrastructure > Bare metal assets.
- Select the options menu for the asset that you want to remove in the table.
- Select Delete asset.
6.7. Using the REST API to create a bare metal asset
You can use the OpenShift Container Platform REST API to manage bare metal assets for use in your Red Hat Advanced Cluster Management cluster. This is useful when you have a separate CMDB application or database to manage the bare metal assets in your environment.
6.7.1. Prerequisites
- Install Red Hat Advanced Cluster Management for Kubernetes on a hub cluster.
- Install the OpenShift Container Platform CLI (oc).
-
Log in as a user with
cluster-admin
privileges.
6.7.2. Create the bare metal asset
To use the REST API to create a bare metal asset, do the following:
Obtain a login token for your hub cluster, and login to the cluster at the command line. For example:
$ oc login --token=<login_token> --server=https://<hub_cluster_api_url>:6443
Modify the following curl command with the details of the bare metal asset that you want to add to the cluster, and run the command.
$ curl --location --request POST '<hub_cluster_api_url>:6443/apis/inventory.open-cluster-management.io/v1alpha1/namespaces/<bare_metal_asset_namespace>/baremetalassets?fieldManager=kubectl-create' \ --header 'Authorization: Bearer <login_token>' \ --header 'Content-Type: application/json' \ --data-raw '{ "apiVersion": "inventory.open-cluster-management.io/v1alpha1", "kind": "BareMetalAsset", "metadata": { "name": "<baremetalasset_name>", "namespace": "<bare_metal_asset_namespace>" }, "spec": { "bmc": { "address": "ipmi://<ipmi_address>", "credentialsName": "<credentials-secret>" }, "bootMACAddress": "<boot_mac_address>", "clusterName": "<cluster_name>", "hardwareProfile": "hardwareProfile", "role": "worker" } }'
-
Replace
baremetalasset-name
with the name of the bare metal asset. When created, theBareMetalHost
on the managed cluster gets the same name as the correspondingBareMetalAsset
on the hub cluster. TheBareMetalHost
name should always match the correspondingBareMetalAsset
name. -
Replace
baremetalasset-namespace
with the cluster namespace where the bare metal asset is created. -
Replace
out_of_band_ip
andport
with the address and port for your bare metal asset. For Redfish addressing, use the following address format:redfish://<out-of-band-ip>/redfish/v1/Systems/1
. -
Replace
role
withworker
,master
, or leave it empty, depending on the machine role type. Therole
setting is used to match a bare metal asset to specific machine role types in the cluster.BareMetalAsset
resources with a specified machine role type should not be used to fill another role. Therole
value is used as the value for a label with keyinventory.open-cluster-management.io/role
. This enables a cluster management application or user to query for inventory that is intended for a particular role. Replace
cluster_name
with the name of your cluster, which is used by the cluster management application or user to query for inventory that is associated with a particular cluster. Leave this value empty to create the bare metal asset without adding it to a cluster deployment.Note: For the previous curl command, it is assumed that the API server is served over HTTPS and is accessed securely. In a development or test environment, you can pass the
--insecure
parameter.
-
Replace
Tip: You can append --v=9
to an oc
command to see the raw output of the resulting action. This can be useful for ascertaining the REST API route for an oc
command.