Scale your stateful workloads to your evolving container workload requirements.

## Before you begin

To complete the tasks in this document, you must request the necessary
permissions and prepare your environment.

### Request IAM roles

To create, delete, edit, or view stateful workloads in a Kubernetes cluster, ask
your Organization IAM Admin to grant you the **Namespace Admin**
(`namespace-admin`) role. This role is bound to your project namespace.

### Prepare your environment

To run commands against the pre-configured bare metal Kubernetes cluster, make sure you have the
following resources:

1. Locate the Kubernetes cluster name, or ask your Platform
   Administrator what the cluster name is.

2. [Sign in and generate](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/iam/sign-in#kubernetes-cluster-kubeconfig) the
   kubeconfig file for the Kubernetes cluster if you don't have one.

3. Use the kubeconfig path of the Kubernetes cluster to replace
   `CLUSTER_KUBECONFIG` in these instructions.

## Scale a `StatefulSet` resource

Use 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 CLUSTER_KUBECONFIG -n NAMESPACE \
        scale statefulset STATEFULSET_NAME \
        --replicas NUMBER_OF_REPLICAS

Replace the following:

- `CLUSTER_KUBECONFIG`: the kubeconfig file for
  the Kubernetes cluster.

- `NAMESPACE`: the project namespace.

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

- `NUMBER_OF_REPLICAS`: the chosen 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 CLUSTER_KUBECONFIG -n NAMESPACE \
        patch statefulsets STATEFULSET_NAME \
        -p '{"spec":{"replicas":NUMBER_OF_REPLICAS}}'

Replace the following:

- `CLUSTER_KUBECONFIG`: the kubeconfig file for
  the Kubernetes cluster.

- `NAMESPACE`: the project namespace.

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

- `NUMBER_OF_REPLICAS`: the chosen number of replicated
  `Pod` objects in the `StatefulSet` object.