kubernetes

Scale a cluster horizontally

To scale a deployment or StatefulSet, two options are available:

  • Use the kubectl scale command to scale the deployment or StatefulSet, if available.
  • Upgrade the deployment or StatefulSet configuring a different number of nodes.

NOTE: When scaling Web applications, it is necessary to use ReadWriteMany volumes if persistence is enabled.

Scaling with kubectl

Use the kubectl scale command to scale the StatefulSet, if available. Here is an example of using the kubectl scale command to scale an etcd StatefulSet:

$ kubectl scale --replicas=4 statefulset/my-release-etcd

Scaling via chart upgrade

Scale the deployment or StatefulSet via a normal chart upgrade, following the steps below:.

  • Set the password used at installation time via the *.password chart parameter. If the password was generated automatically, obtain the auto-generated paassword from the post-deployment instructions.
  • Set the desired number of nodes via the *.replicaCount or *.replicas chart parameter.

NOTE: These parameters differ per chart, depending on the chart architecture. Refer to the chart documentation for the correct parameter names for your chart.

Here is an example of scaling out an Apache deployment. Substitute the PASSWORD placeholder with the original password, the MY-RELEASE placeholder with the correct release name and the NUMBER_OF_REPLICAS placeholder with the total number of nodes required.

$ helm upgrade MY-RELEASE oci://registry-1.docker.io/bitnamicharts/apache \
    --set rootUser.password=PASSWORD \
    --set replicaCount=NUMBER_OF_REPLICAS

Here is another example of scaling out an Elasticsearch StatefulSet. Replace the MY-RELEASE placeholder with the correct release name and the NUMBER_OF_REPLICAS placeholder with the total number of nodes required.

$ helm upgrade MY-RELEASE oci://registry-1.docker.io/bitnamicharts/elasticsearch \
    --set master.replicas=NUMBER_OF_REPLICAS
Last modification January 24, 2024