6.6.4. 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

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동