CCE Changing Node Pool#
This document describes the procedure for modifying the node pool flavors or limit size of our CCE clusters.
Our CCE clusters make use of node pools to manage worker nodes.
Node Flavor is an immutable field of the node pool specification. Modifying the flavor of an existing node pool managed by terraform will trigger a replacement of the pool (existing Kubernetes worker nodes will be destroyed and new ones will be created). This operation has an impact on the applications running on the cluster.
Also min_nodes, desired_nodes, max_nodes parameters are not properly taken into account by CCE, particularly in the case of a reduction of desired nodes.
When node flavor or limit size modifications are required, a better approach would be to add new node pools to the cluster, switch all the workloads to the new nodes and, finally, remove the old node pools from the configuration.
Procedure#
All of the operations are performed from within the envs-ng directory:
cd <envs-ng directory>
nix-shell
export ZONE_NAME=<name of the target zone>
git checkout master
git pull
Create a new branch to work on#
git checkout -b "${ZONE_NAME}_nodepool_flavor_change"
Identify the nodes belonging to the targeted node pool#
We need to know which cluster's nodes belong to the targeted node pool. We will use inttac as an example.
Connect to the cluster and identify the node:
kswitch inttac
kubectl get nodes -o custom-columns="NAME":".metadata.name","NODEPOOL":".metadata.labels['caascad\.io/nodepool']"
grep for the name of target node pool. pod-tac is used as an example
kubectl get nodes -o custom-columns="NAME":.metadata.name,"LABELS":.metadata.labels['caascad\.io/nodepool'] | grep pod-tac
Modify the zones file#
The zones files are located in the zones directory:
cd zones
cd caascad_zones
vi zones.cue
inttac is used in the example below. The node pool section will look something like this:
parameters: kubernetes: pools: {
"application-pool": {
labels: "caascad.io/nodepool": "application-pool"
availability_zone: null
max_nodes: 100
min_nodes: 2
desired_nodes: 2
flavor_id: "s3.xlarge.2"
}
"pod-tac": {
labels: "caascad.io/nodepool": "pod-tac"
availability_zone: "eu-west-0c"
max_nodes: 5
min_nodes: 1
desired_nodes: 1
flavor_id: "s6.4xlarge.2"
}
}
There are two node pools visible: application-pool and pod-tac. If we want to change the flavor for the pod-tac node pool to s6.4xlarge.4, we will add a new section with the new node pool definition. The new file will look like this:
parameters: kubernetes: pools: {
"application-pool": {
labels: "caascad.io/nodepool": "application-pool"
availability_zone: null
max_nodes: 100
min_nodes: 2
desired_nodes: 2
flavor_id: "s3.xlarge.2"
}
"pod-tac": {
labels: "caascad.io/nodepool": "pod-tac"
availability_zone: "eu-west-0c"
max_nodes: 5
min_nodes: 1
desired_nodes: 1
flavor_id: "s6.4xlarge.2"
}
"pod-tac2": {
labels: "caascad.io/nodepool": "pod-tac"
availability_zone: "eu-west-0c"
max_nodes: 5
min_nodes: 1
desired_nodes: 1
flavor_id: "s6.4xlarge.4"
}
}
Compile the zones file#
The modified zones.cue file needs to be compiled:
cue fmt zones.cue
generate-static-zones-files
Apply the changes using trackbone#
Go to the envs-ng directory to apply the configuration. As an example, for caascad, this would be envs-ng/contexts/caascad. Apply the new CCE configuration:
trackbone apply -z <zone_name> -c cce
Drain nodes belonging to the old node pool#
Cordon the nodes in the list of nodes identified earlier in order to make them unavailable for scheduling.
Drain the nodes. It is a good idea to drain them node-by-node and to make sure all the pods are in a Running state.
Remove the old node pool from the zones file#
Return the zones directory. As an example, for caascad, this would be zones/caascad_zones. Edit the zones.cue file and remove the old node pool. The end result will look something like this:
parameters: kubernetes: pools: {
"application-pool": {
labels: "caascad.io/nodepool": "application-pool"
availability_zone: null
max_nodes: 100
min_nodes: 2
desired_nodes: 2
flavor_id: "s3.xlarge.2"
}
"pod-tac2": {
labels: "caascad.io/nodepool": "pod-tac"
availability_zone: "eu-west-0c"
max_nodes: 5
min_nodes: 1
desired_nodes: 1
flavor_id: "s6.4xlarge.4"
}
}
Compile the zones file (again)#
The modified zones.cue file needs to be compiled:
cue fmt zones.cue
generate-static-zones-files
At this point, commit all the changed files to git and create a MR in gitlab. The MR has to be approved by the automation team.
Apply the changes using trackbone (again)#
Go to the envs-ng directory to apply the configuration. As an example, for caascad, this would be envs-ng/contexts/caascad. Apply the new CCE configuration:
trackbone apply -z <zone_name> -c cce
At this point, the node of the old node pool should no longer be visible from the command line:
kubectl get nodes
Merge changes into the master branch#
In gitlab, perform a trackbone plan and verify the changes applied. There should be no changes because they were already applied from the command line.
Finally, merge the change into the master branch by clicking the Merge button and update your envs-ng copy on your work station:
git checkout master
git pull