Scale a Cluster

Learn how to scale a Kubernetes cluster on OCI.

You can scale the cluster nodes by using the kubectl scale command, either on the management cluster, or directly in the OCI cluster if it's self-managed.

Note:

You can also scale cluster nodes by editing the replicas option in the appropriate Kubernetes Cluster API Custom Resource file, but this approach isn't recommended in production systems.

Scaling Worker Nodes in an OCI Cluster

Use the kubectl scale command to scale the number of worker nodes in a Kubernetes cluster on OCI.

You can scale the worker nodes in a Kubernetes cluster by running the kubectl scale command, either on the management cluster, or on the OCI cluster if it's self-managed.

  1. Get the name of the machinedeployments Custom Resource.

    Use the kubectl get command to retrieve this information, for example:

    kubectl get machinedeployments --namespace ocne
  2. Run the kubectl scale command, specifying the new number of worker nodes.

    Set the new number of worker nodes with the --replicas option. In this example, the name of the machinedeployments Custom Resource is mycluster-md-0:

    kubectl scale machinedeployment mycluster-md-0 --replicas 3 --namespace ocne
  3. Wait for the cluster to stabilize before performing any other scaling operations.

    You can monitor the status of the nodes by running the following command on the OCI cluster:

    watch kubectl get nodes -A

    The cluster is stable when all the cluster nodes show a status of Ready. Exit the command using Ctrl+C.

    The number of worker nodes in the cluster is scaled up or down to the number of replicas you set.

Scaling Control Plane Nodes in an OCI Cluster

Use the kubectl scale command to scale the number of control plane nodes in a Kubernetes cluster on OCI.

You can scale the control plane nodes in a Kubernetes cluster by running the kubectl scale command, either on the management cluster, or on the OCI cluster if it's self-managed.

  1. Get the name of the kubeadmcontrolplane Custom Resource.

    Use the kubectl get command to retrieve this information, for example:

    kubectl get kubeadmcontrolplane --namespace ocne
  2. Run the kubectl scale command, specifying the new number of control plane nodes.

    Set the new number of control plane nodes with the --replicas option. In this example, the name of the kubeadmcontrolplane Custom Resource is mycluster-control-plane:

    kubectl scale kubeadmcontrolplane mycluster-control-plane --replicas 3 --namespace ocne
  3. Wait for the cluster to stabilize before performing any other scaling operations.

    You can monitor the status of the nodes by running the following command on the OCI cluster :

    watch kubectl get nodes -A

    The cluster is stable when all the cluster nodes show a status of Ready. Exit the command using Ctrl+C.

    The number of control plane nodes in the cluster is scaled up or down to the number of replicas you set.