AKS upgrade does not work as described - old nodes are not deleted but upgraded instead
What happened:
The docs say here:
During the upgrade process, AKS adds a new node to the cluster that runs the specified Kubernetes version, then carefully cordon and drains one of the old nodes to minimize disruption to running applications. When the new node is confirmed as running application pods, the old node is deleted. This process repeats until all nodes in the cluster have been upgraded.
However, after having tested this on multiple clusters, the behavior seems different:
- a new node is added - which is running on the new aks version
- An existing node is drained, the pods are re-scheduled on the new node
- Now, instead of deleting the old node as described above, instead the node is upgraded (you can also observe this in the underlying Scale Set)
- Once the node update is finished, the old node in marked as "Ready" again and gets pods scheduled
- The process continues with the other nodes
- Once all existing nodes have been updated, the newly added node is drained and then deleted.
Also tested this with surge of 100% on a 3 node cluster: Three new nodes got created in parallel, all pods got moved. Then the old nodes were upgraded and afterwards the new ones were deleted again.
I tested upgrades from 1.17.x to 1.18.6 and also from 1.18.6 to 1.18.8
Can you please clarify if either the docs are wrong or the behavior that I see is not as intended?
Thanks!
What you expected to happen:
As described in the docs, the old nodes should be deleted instead of pods being moved back and the new nodes getting deleted
How to reproduce it (as minimally and precisely as possible): Just upgrade a node pool and observe the behavior.
Anything else we need to know?: Cross-posting from the docs repo as it might be more related to AKS itself.
Environment:
- Kubernetes version (use
kubectl version): 1.18.8 - Size of cluster (how many worker nodes are in the cluster?) 1 (also tested with 3), all clusters that were tested are based on VMSS
- General description of workloads in the cluster (e.g. HTTP microservices, Java app, Ruby on Rails, machine learning, etc.)
- Others:
Hi sebader, AKS bot here :wave: Thank you for posting on the AKS Repo, I'll do my best to get a kind human from the AKS team to assist you.
I might be just a bot, but I'm told my suggestions are normally quite good, as such:
- If this case is urgent, please open a Support Request so that our 24/7 support team may help you faster.
- Please abide by the AKS repo Guidelines and Code of Conduct.
- If you're having an issue, could it be described on the AKS Troubleshooting guides or AKS Diagnostics?
- Make sure your subscribed to the AKS Release Notes to keep up to date with all that's new on AKS.
- Make sure there isn't a duplicate of this issue already reported. If there is, feel free to close this one and '+1' the existing issue.
- If you have a question, do take a look at our AKS FAQ. We place the most common ones there!
@sebader The documentation describes the process of upgrading an AKS cluster running VMs instead of VMSS.
But in the end the result is the same. During an AKS cluster upgrade the OS image of a VMSS instance is replaced by a new one.
An upgrade works by replacing the OS disk of a VM with a new disk created using the latest image version. (https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-automatic-upgrade#how-does-automatic-os-image-upgrade-work)
Just linked the docs as reference as they describe the automatic process that is not used by AKS but done in the same way manually controlled by the AKS managed control plane.
I agree that the docs should be updated to be more precise on the difference between VMs and VMSS based AKS clusters.
Thanks @neumanndaniel for your comments! Where do you read from the docs that this is not applicable to VMSS?
@sebader The process is the same, but the part with deleting the old node and replacing it with a new one is specific to VMs. I should have been more clear on that.
Thanks for the callout, the docs themselves have a GH feedback page. The process you describe is correct. Always creating a new node would be redundant to do at every step and take twice as long, we essentially re-image the old (cordoned and drained) ones with the new image.
The PR with the update is out.
But wouldn't this at least make sense for when someone uses a high surge? Extreme case, using 100% surge. Once all new nodes have been created and all pods have been moved over to them, why are still the old ones being patched (and workloads moved once again afterwards) instead of just deleting the old ones?
That's the purpose of max surge by default the value is one buffer node, you can configure it to whatever value you want. If you do 100% it will double the number of your nodes drain the old ones to the new and delete all the old ones at once.
This can be our default since this requires core quota to be available, for example.
That's what I would expect as well on 100% surge. But this is not what happens
and delete all the old ones at once.
Hi, @sebader you are right, I'm aware of that issue. You can observe the same behavior with one node cluster upgrade (which is 100% surge always, and ideally should just delete the old node). This is one optimization we haven't done, but it is in plan.
cc: @paulgmiller
We always delete the buffer last or buffer batch last to avoid unbalancing a cluster in its zones or availability constructs or maintain the same spread, when using non 100% this is not noticeable but for the 100% case it's a special case where deleting the buffer will have the 2 drain noticeable consequence, we are looking into the optimization for this special case or create a new upgrade mode for new nodepools.
I think surge should have 2 algorithms. Assume surge percentage is P:
- when P < 50%, one by one upgrade/reimage old nodes, then delete surge nodes in the end.
- when P >= 50%, upgrade/reimage (100% - P) old nodes, then delete P portion of old nodes.
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
This issue will now be closed because it hasn't had any activity for 15 days after stale. sebader feel free to comment again on the next 7 days to reopen or open a new issue after that time if you still have a question/issue or suggestion.