Scaling worker nodes

The scale-workers phase adds or removes worker nodes on a Kubernetes cluster that the installer created, so that the cluster matches the worker count in bootstrap.env.

To scale the workers of a cluster that the installer created with DEPLOY_INFRA set to true, change INFRA_WORKER_COUNT in bootstrap.env, and run the scale-workers phase. The phase changes only workers, and it never adds or removes control plane nodes.

Requirements

The scale-workers phase has the following requirements:

  • Run the phase from the same working folder that created the cluster. The phase reads bootstrap.env and the .kubernetes-install folder, which holds the Terraform state, the generated inventory, the kubeconfig, and nodes.json. Without this state, the phase cannot manage the cluster.
  • Leave INFRA_TERRAFORM_VARS_FILE empty, because the phase needs the generated Terraform variables.
  • Use an installer image or binary that contains the scale-workers phase.

How the phase works

The following facts apply when you scale workers:

  • The scale-workers phase is not part of the all command, and you run it separately.
  • The phase records the workers that it last applied in nodes.json in INFRA_WORK_DIR. A removed worker leaves a gap in the numbering that a count alone cannot express. Do not edit the file by hand unless a troubleshooting topic instructs you to correct it.
  • New workers are numbered after the highest existing worker, for example, worker-3 and then worker-4. The phase does not reuse the numbers of removed workers.
  • When you remove workers, the phase removes the highest-numbered workers. You cannot choose a different worker.
  • At least one worker always remains, because the control plane nodes do not run workloads. The phase refuses an INFRA_WORKER_COUNT below 1, and you cannot scale down a cluster that has a single worker.
  • A later provision-infra run keeps the recorded workers and warns if INFRA_WORKER_COUNT differs from them, so the run never removes a node without draining it.
  • The phase does not change HAProxy on the bastion, because workers are not API backends.

Related tasks and troubleshooting

For the procedures, see Adding worker nodes to a cluster and Removing worker nodes from a cluster. If a run stops, see the topics in the Troubleshooting section.