Restart a bare metal host

You can use the Container Cloud API to restart a bare metal host in Mirantis OpenStack for Kubernetes clusters. The workflow of the host restart is as follows:

  1. Setting the maintenance mode on the cluster that contains the target node.

  2. Setting the maintenance mode on the target node for OpenStack and Container Cloud to drain it from workloads. No new workloads will be provisioned to a host in the maintenance mode.

  3. Using the BareMetalHost object to initiate a hard reboot of the bare metal server that hosts the node.

To restart a bare metal host:

  1. Using kubeconfig of the Container Cloud management cluster, access the Container Cloud API and open the Cluster object for editing:

    kubectl -n <project-name> edit cluster <cluster-name>
    
  2. Add the following field to the spec section to set the maintenance mode on the cluster:

    spec:
      providerSpec:
        value:
          maintenance: true
    
  3. Verify that the Cluster object status for Maintenance is ready: true:

    kubectl -n <project-name> get cluster <cluster-name>
    

    Example of a negative system response:

    ...
    status:
      providerStatus:
        conditions:
        ...
        - message: 'Maintenance state of the cluster is false, expected:
          # true. Waiting for the cluster to enter the maintenance state'
          ready: false
          type: Maintenance
        ...
        maintenance: true
    
  4. Open the required Machine object for editing:

    kubectl -n <project-name> edit machine <machine-name>
    
  5. In the spec:providerSpec section, set the maintenance mode on the node:

    spec:
      providerSpec:
        value:
          maintenance: true
    
  6. In the annotations section of the Machine definition, capture the bare metal host name connected to the machine:

    metadata:
      annotations:
        metal3.io/BareMetalHost: <project-name>/<host-name>
    
  7. Verify that the Machine maintenance status is true:

    status:
      maintenance: true
    

    Important

    Proceed with the node maintenance only after the machine switches to the maintenance mode.

  8. Open the required BareMetalHost object for editing using the previously captured <host-name>:

    kubectl -n <project-name> edit baremetalhost <host-name>
    
  9. In the spec section, set the online field to false:

    spec:
      online: false
    

    Wait for the host to shut down.

  10. In the spec section, set the online field to true:

    spec:
      online: true
    
  11. Restore the machine from the maintenance mode by deleting the previously set maintenance: true line from the Machine object:

    kubectl -n <project-name> edit machine <machine-name>
    
  12. Restore the cluster from the maintenance mode by deleting the previously set maintenance: true line from the Cluster object.

    kubectl -n <project-name> edit cluster <cluster-name>