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¶
Log in to the host where your management cluster
kubeconfig
is located and where kubectl is installed.Enable maintenance mode on the cluster:
In the
value
section ofproviderSpec
of theCluster
object, setmaintenance
totrue
: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.
Wait until the
maintenance
status istrue
:kubectl get clusters.cluster.k8s.io -n <projectName> <clusterName> -o jsonpath='{.status.providerStatus.maintenance}'
Enable maintenance mode on the required machine:
In the
value
section ofproviderSpec
of theMachine
object, setmaintenance
totrue
:kubectl patch machines.cluster.k8s.io -n <projectName> <machineName> --type=merge -p '{"spec":{"providerSpec":{"value":{"maintenance":true}}}}'
Wait until the
maintenance
status istrue
: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¶
Log in to the host where your management cluster
kubeconfig
is located and where kubectl is installed.Disable maintenance mode on the machine:
In the
value
section ofproviderSpec
of theCluster
object, setmaintenance
tofalse
:kubectl patch machines.cluster.k8s.io -n <projectName> <machineName> --type=merge -p '{"spec":{"providerSpec":{"value":{"maintenance":false}}}}'
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.
Repeat the above steps for all machines that are in maintenance mode.
Disable maintenance mode on the cluster:
In the
value
section ofproviderSpec
of theCluster
object, setmaintenance
tofalse
:kubectl patch clusters.cluster.k8s.io -n <projectName> <clusterName> --type=merge -p '{"spec":{"providerSpec":{"value":{"maintenance":false}}}}'
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.