TKGm 2.5.X
To correctly assign node labels, uUtargeted worker pool, provisioning new nodes with the label attached at boot time without workload downtime.
Pre-Checks
Apply the Topology Variable Patch
Replace <INDEX>, <KEY>, and <VALUE> with your environment parameters:
kubectl patch cluster <CLUSTER_NAME> -n <NAMESPACE> --type='json' -p='[
{
"op": "add",
"path": "/spec/topology/workers/machineDeployments/<INDEX>/variables",
"value": {
"overrides": [
{
"name": "nodePoolLabels",
"value": [
{"key": "<KEY>", "value": "<VALUE>"}
]
}
]
}
}
]'
Monitor Rolling Update
Cluster API will generate a new KubeadmConfigTemplate and automatically trigger a rolling replacement of the worker nodes. Monitor the progress on the Management Cluster:
kubectl get machines -n <NAMESPACE> -l topology.cluster.x-k8s.io/deployment-name=<TARGET_MD_NAME> -w
Verification
NEW_KCT=$(kubectl get machinedeployment -n <NAMESPACE> -l topology.cluster.x-k8s.io/deployment-name=<TARGET_MD_NAME> -o jsonpath='{.items[0].spec.template.spec.bootstrap.configRef.name}')
kubectl get kubeadmconfigtemplate $NEW_KCT -n <NAMESPACE> -o yaml | grep -A5 kubeletExtraArgs