Enable maintenance mode on a cluster and machine using CLI

You can use the instructions below to enable maintenance mode on a cluster and machine using the Container Cloud API. To enable maintenance mode using the Container Cloud web UI, refer to Enable maintenance mode on a cluster and machine using web UI.

Caution

  • To enable maintenance mode on a machine, first enable maintenance mode on the related cluster.

  • To disable maintenance mode on a cluster, first disable maintenance mode on all machines of the cluster.

Warning

During cluster and machine maintenance:

  • Cluster upgrades and configuration changes (except of the SSH keys setting) are unavailable. Make sure you disable maintenance mode on the cluster after maintenance is complete.

  • Data load balancing is disabled while Ceph is in maintenance mode.

  • Workloads are not affected.

Enable maintenance mode on a cluster and machine

  1. Log in to the host where your management cluster kubeconfig is located and where kubectl is installed.

  2. Enable maintenance mode on the cluster:

    1. In the value section of providerSpec of the Cluster object, set maintenance to true:

      kubectl patch clusters.cluster.k8s.io -n <projectName> <clusterName> --type=merge -p '{"spec":{"providerSpec":{"value":{"maintenance":true}}}}'
      

      Replace the parameters enclosed in angle brackets with the corresponding values.

    2. Wait until the maintenance status is true:

      kubectl get clusters.cluster.k8s.io -n <projectName> <clusterName> -o jsonpath='{.status.providerStatus.maintenance}'
      
  3. Enable maintenance mode on the required machine:

    1. In the value section of providerSpec of the Machine object, set maintenance to true:

      kubectl patch machines.cluster.k8s.io -n <projectName> <machineName> --type=merge -p '{"spec":{"providerSpec":{"value":{"maintenance":true}}}}'
      
    2. Wait until the maintenance status is true:

      kubectl get machines.cluster.k8s.io -n <projectName> <machineName> -o jsonpath='{.status.providerStatus.maintenance}'
      

Once done, the node of the selected machine is cordoned, drained, and prepared for maintenance operations.

Disable maintenance mode on a cluster and machine

  1. Log in to the host where your management cluster kubeconfig is located and where kubectl is installed.

  2. Disable maintenance mode on the machine:

    1. In the value section of providerSpec of the Cluster object, set maintenance to false:

      kubectl patch machines.cluster.k8s.io -n <projectName> <machineName> --type=merge -p '{"spec":{"providerSpec":{"value":{"maintenance":false}}}}'
      
    2. Wait until the machine maintenance mode disables:

      kubectl get machines.cluster.k8s.io -n <projectName> <machineName> -o jsonpath='{.status.providerStatus.maintenance}'
      

      Verify that the system output is false or empty.

  3. Repeat the above steps for all machines that are in maintenance mode.

  4. Disable maintenance mode on the cluster:

    1. In the value section of providerSpec of the Cluster object, set maintenance to false:

      kubectl patch clusters.cluster.k8s.io -n <projectName> <clusterName> --type=merge -p '{"spec":{"providerSpec":{"value":{"maintenance":false}}}}'
      
    2. Wait until the cluster maintenance mode disables:

      kubectl get clusters.cluster.k8s.io -n <projectName> <clusterName> -o jsonpath='{.status.providerStatus.maintenance}'
      

      Verify that the system output is false or empty.