Scale stateful workloads

Scale your stateful workloads to your evolving container workload requirements.

Before you begin

To run commands against a user cluster, use the gdcloud CLI to access its kubeconfig file.

  1. Ensure that you have downloaded, installed, and configured the gdcloud CLI.

  2. Run gdcloud auth login to log in to the org admin cluster.

  3. Locate the user cluster name, or ask your Platform Administrator what the cluster name is.

  4. To generate the kubeconfig file of the user cluster, run:

    gdcloud clusters get-credentials USER_CLUSTER_NAME
    
  5. Record the path to the generated file, such as /tmp/user-cluster-kubeconfig-with-user-identity.yaml.

  6. Use the path to replace USER_CLUSTER_KUBECONFIG in these instructions.

To get the required permissions to scale stateful workloads, ask your Organization IAM Admin to grant you the Namespace Admin role.

Scale a StatefulSet resource

Leverage the scaling functionality of Kubernetes to appropriately scale the amount of pods running in your StatefulSet resource.

Manually scale the pods of a StatefulSet resource

To manually scale your StatefulSet resource, run:

kubectl --kubeconfig USER_CLUSTER_KUBECONFIG \
    scale statefulset STATEFULSET_NAME \
    --replicas NUMBER_OF_REPLICAS

Replace the following:

  • USER_CLUSTER_KUBECONFIG: the kubeconfig file for the user cluster.

  • STATEFULSET_NAME: the name of the StatefulSet object in which to scale.

  • NUMBER_OF_REPLICAS: the desired number of replicated Pod objects in the StatefulSet object.

Scale the pods by making an in-place update

To scale the pods of a StatefulSet resource directly in the manifest file, run:

kubectl --kubeconfig USER_CLUSTER_KUBECONFIG \
    patch statefulsets STATEFULSET_NAME \
    -p '{"spec":{"replicas":NUMBER_OF_REPLICAS}}'

Replace the following:

  • USER_CLUSTER_KUBECONFIG: the kubeconfig file for the user cluster.

  • STATEFULSET_NAME: the name of the StatefulSet object in which to scale.

  • NUMBER_OF_REPLICAS: the desired number of replicated Pod objects in the StatefulSet object.