Scale Kubernetes Cluster Horizontally
Procedures to scale Kubernetes cluster horizontally by adding nodes
This assumes you’ve followed the Geodesic Module Usage guide which covers all the scaffolding necessary to get started.
Kops cluster can be scaled horizontally by adding EC2 instances.
Kops supports rolling cluster upgrades where the master and worker nodes are upgraded one by one.
First, in the module’s
NODE_MIN_SIZE to reflect the desired number of the worker nodes:
Dockerfile Kops config
ENV BASTION_MACHINE_TYPE="t2.medium" ENV MASTER_MACHINE_TYPE="t2.large" ENV NODE_MACHINE_TYPE="t2.large" ENV NODE_MAX_SIZE="3" ENV NODE_MIN_SIZE="3"
geodesic shell by running:
Then, ensure that the
kubectl context has been set.
geodesic shell run:
kops export kubecfg
(Note, in older versions of
kops you will need to pass the cluster name, so run
kops export kubecfg $KOPS_CLUSTER_NAME)
Apply the lastest kops manifest:
kops replace -f /conf/kops/manifest.yaml
--yes option immediately applies the changes. Not specifying
--yes works like
terraform plan and shows the pending changes.
Update the Kubernetes state store to match the cluster state. This can be done using the following command:
kops update cluster --yes
Lastly, perform a rolling update for all cluster nodes using the kops
kops rolling-update cluster --yes
--yes updates all nodes in the cluster, first master nodes and then worker nodes.
There is a 5-minute delay between restarting master nodes, and a 2-minute delay between restarting nodes.
These values can be altered using
--node-interval options, respectively.
Only the worker nodes may be updated by using the
--instance-group node option.