6.6.6. Linking the node, bare metal host, and machine together
Continue creating the new control plane node by creating a machine and then linking it with the new BareMetalHost object and node.
Procedure
Get the
providerIDfor control plane nodes by running the following command:$ oc get -n openshift-machine-api baremetalhost -l installer.openshift.io/role=control-plane -ojson | jq -r '.items[] | "baremetalhost:///openshift-machine-api/" + .metadata.name + "/" + .metadata.uid'Example output
baremetalhost:///openshift-machine-api/master-00/6214c5cf-c798-4168-8c78-1ff1a3cd2cb4 baremetalhost:///openshift-machine-api/master-01/58fb60bd-b2a6-4ff3-a88d-208c33abf954 baremetalhost:///openshift-machine-api/master-02/dc5a94f3-625b-43f6-ab5a-7cc4fc79f105Get cluster information for labels by running the following command:
$ oc get machine -n openshift-machine-api \ -l machine.openshift.io/cluster-api-machine-role=master \ -L machine.openshift.io/cluster-api-clusterExample output
NAME PHASE TYPE REGION ZONE AGE CLUSTER-API-CLUSTER ci-op-jcp3s7wx-ng5sd-master-0 Running 10h ci-op-jcp3s7wx-ng5sd ci-op-jcp3s7wx-ng5sd-master-1 Running 10h ci-op-jcp3s7wx-ng5sd ci-op-jcp3s7wx-ng5sd-master-2 Running 10h ci-op-jcp3s7wx-ng5sdCreate a
Machineobject for the new control plane node by creating a yaml file similar to the following:apiVersion: machine.openshift.io/v1beta1 kind: Machine metadata: annotations: metal3.io/BareMetalHost: openshift-machine-api/<new_control_plane_machine>1 finalizers: - machine.machine.openshift.io labels: machine.openshift.io/cluster-api-cluster: <cluster_api_cluster>2 machine.openshift.io/cluster-api-machine-role: master machine.openshift.io/cluster-api-machine-type: master name: <new_control_plane_machine>3 namespace: openshift-machine-api spec: metadata: {} providerID: <provider_id>4 providerSpec: value: apiVersion: baremetal.cluster.k8s.io/v1alpha1 hostSelector: {} image: checksum: "" url: "" kind: BareMetalMachineProviderSpec userData: name: master-user-data-managedwhere:
<new_control_plane_machine>- Specifies the name of the new machine, which can be the same as the previously deleted machine name.
<cluster_api_cluster>-
Specifies the
CLUSTER-API-CLUSTERvalue for the other control plane machines, shown in the output of the previous step. <provider_id>-
Specifies the
providerIDvalue of the new bare metal host, shown in the output of an earlier step.
The following warning is expected:
Warning: metadata.finalizers: "machine.machine.openshift.io": prefer a domain-qualified finalizer name to avoid accidental conflicts with other finalizer writersLink the new control plane node and
Machineobject to theBareMetalHostobject by performing the following steps in a single bash shell session:Define the
NEW_NODE_NAMEvariable by running the following command:$ NEW_NODE_NAME=<new_node_name>Replace
<new_node_name>with the name of the new control plane node.Define the
NEW_MACHINE_NAMEvariable by running the following command:$ NEW_MACHINE_NAME=<new_machine_name>Replace
<new_machine_name>with the name of the new machine.Define the
BMH_UIDby running the following commands to extract it from the new node’sBareMetalHostobject:$ BMH_UID=$(oc get -n openshift-machine-api bmh $NEW_NODE_NAME -ojson | jq -r .metadata.uid)$ echo $BMH_UIDPatch the
consumerRefobject into the bare metal host by running the following command:$ oc patch -n openshift-machine-api bmh $NEW_NODE_NAME --type merge --patch '{"spec":{"consumerRef":{"apiVersion":"machine.openshift.io/v1beta1","kind":"Machine","name":"'$NEW_MACHINE_NAME'","namespace":"openshift-machine-api"}}}'Patch the
providerIDvalue into the new node by running the following command:$ oc patch node $NEW_NODE_NAME --type merge --patch '{"spec":{"providerID":"baremetalhost:///openshift-machine-api/'$NEW_NODE_NAME'/'$BMH_UID'"}}'Review the
providerIDvalues by running the following command:$ oc get node -l node-role.kubernetes.io/control-plane -ojson | jq -r '.items[] | .metadata.name + " " + .spec.providerID'
Set the
BareMetalHostobject’spoweredOnstatus totrueby running the following command:$ oc patch -n openshift-machine-api bmh $NEW_NODE_NAME --subresource status --type json -p '[{"op":"replace","path":"/status/poweredOn","value":true}]'Review the
BareMetalHostobject’spoweredOnstatus by running the following command:$ oc get bmh -n openshift-machine-api -ojson | jq -r '.items[] | .metadata.name + " PoweredOn:" + (.status.poweredOn | tostring)'Review the
BareMetalHostobject’s provisioning state by running the following command:$ oc get bmh -n openshift-machine-api -ojson | jq -r '.items[] | .metadata.name + " ProvisioningState:" + .status.provisioning.state'重要If the provisioning state is not
unmanaged, change the provisioning state by running the following command:$ oc patch -n openshift-machine-api bmh $NEW_NODE_NAME --subresource status --type json -p '[{"op":"replace","path":"/status/provisioning/state","value":"unmanaged"}]'Set the machine’s state to
Provisionedby running the following command:$ oc patch -n openshift-machine-api machines $NEW_MACHINE_NAME -n openshift-machine-api --subresource status --type json -p '[{"op":"replace","path":"/status/phase","value":"Provisioned"}]'