K8s 1.27 Update Pod requests/limits for running Pods
How Killercoda will be able to use this feature to improve performance in production
TL;DR
In this article we’ll:
- Describe the new feature “Update K8s Resources In-Place”
- Allow you to see this in action simply in your browser
- Describe a production use-case where this feature will be used
What is possible now?
Let’s imagine we create a Pod like this:
Since K8s 1.27 it’s now possible to update the resources Requests/Limits of running Pods without the need for restarting them. This means we can simply run kubectl patch
or kubectl apply
with updated values:
How awesome is this?! (The answer is: very awesome)
What are the requirements?
As this is still in Alpha state it requires the feature InPlacePodVerticalScaling
to be enabled. For K3s it’s for example possible using:
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.27.1%2Bk3s1 sh -s - --kube-apiserver-arg feature-gates=InPlacePodVerticalScaling=true
Can I see this in action?
Very glad you’re asking, yes you can! Simply head to the Killercoda scenario and test it out simply in your browser:
Production Use-Case
On Killercoda.com we create Sandbox Virtual Machine environments for teaching, learning, presenting or testing. As soon as the user opens their browser they’ll get access to a fresh VM. Read more about the Killercoda architecture here.
The workflow for an Ubuntu VM is something like this:
Workflow before K8s 1.27
- Create new Ubuntu VM KubeVirt Pod, limit Pod to 1 CPU
- Wait till the KubeVirt Pod/VM is ready
- Provide access to the user, User can use max 1 CPU
As you can see we have to limit the CPU resources that a Pod/VM is allowed to consume already at the very beginning, hence step 2 might be slow and causes longer load times.
Workflow since K8s 1.27:
- Create new Ubuntu VM KubeVirt Pod, limit Pod to 6 CPU
- Wait till the KubeVirt Pod/VM is ready
- Limit Pod to 1 CPU by updating the resources section in-place
- Provide access to the user, User can use max 1 CPU
Now we can use higher resources limits during setup/installation and add the final user limits later.