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

  1. Get the providerID for 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-7cc4fc79f105

  2. Get 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-cluster

    Example 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-ng5sd

  3. Create a Machine object 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-managed

    where:

    <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-CLUSTER value for the other control plane machines, shown in the output of the previous step.
    <provider_id>
    Specifies the providerID value 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 writers
  4. Link the new control plane node and Machine object to the BareMetalHost object by performing the following steps in a single bash shell session:

    1. Define the NEW_NODE_NAME variable by running the following command:

      $ NEW_NODE_NAME=<new_node_name>

      Replace <new_node_name> with the name of the new control plane node.

    2. Define the NEW_MACHINE_NAME variable by running the following command:

      $ NEW_MACHINE_NAME=<new_machine_name>

      Replace <new_machine_name> with the name of the new machine.

    3. Define the BMH_UID by running the following commands to extract it from the new node’s BareMetalHost object:

      $ BMH_UID=$(oc get -n openshift-machine-api bmh $NEW_NODE_NAME -ojson | jq -r .metadata.uid)
      $ echo $BMH_UID
    4. Patch the consumerRef object 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"}}}'
    5. Patch the providerID value 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'"}}'
    6. Review the providerID values by running the following command:

      $ oc get node -l node-role.kubernetes.io/control-plane -ojson | jq -r '.items[] | .metadata.name + "  " + .spec.providerID'
  5. Set the BareMetalHost object’s poweredOn status to true by 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}]'
  6. Review the BareMetalHost object’s poweredOn status by running the following command:

    $ oc get bmh -n openshift-machine-api -ojson | jq -r '.items[] | .metadata.name + "   PoweredOn:" +  (.status.poweredOn | tostring)'
  7. Review the BareMetalHost object’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"}]'
  8. Set the machine’s state to Provisioned by 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"}]'
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部