In-Place Update of Pod Resources
Current state explanation by dashpole@
Shared Publicly
What we know for sure:
apiVersion: v1
kind: Pod
spec:
containers:
- name: my-container
resources:
requests:
limits:
Container Resources are Mutable
What we know for sure:
apiVersion: v1
kind: Pod
spec:
containers:
- name: my-container
resources:
requests:
limits:
status:
containerStatuses:
resources:
requests:
limits:
Add “actual” resources to
container status
Reported from actual resources allocated by container runtime
Container Runtime
Kubelet
CRI
Status Manager
syncPod
API Server
Problem: Pod Requests <= Node Allocatable?
Instead, we can now try to enforce (but can’t guarantee):
sum(pod_allocated_resources) <= node_allocatable
...where pod_allocated_resources is the resource requests in the pod status.
This means we must only perform updates to container resources when the new resource requests fit on the node...
Problem: When can we update container resources?
When pods are admitted today, we do a one-time check called “admission” to either allow the pod to run as-is, or fail the pod.
For resource updates, we don’t want to fail the pod, even if the new resource requests don’t fit on the node. So we want to “admit” the change, but not act on it.
The decision to act on a particular set of container resources must be:
Option 1: Store “admitted” pod resources on disk
When we decide to run a pod with a particular set of resources, write those resources immediately to disk in a new checkpoint file.
When the kubelet starts, look for this checkpoint file. If it exists, load it, and somehow use those values for pod admission instead of the actual pod resources.
Option 1: Store “admitted” pod resources on disk
Pros:
Cons:
Option 2: Store “admitted” pod resources in spec
When we decide to run a pod with a particular set of resources, write the set of resources back into the pod spec using a pod subresource.
When the kubelet does admission of new pods with “admitted” resources already set, it admits based on the “admitted” resource rather than the pod resources.
Pod.Spec.Container[I]. Resources
Pod.Spec.Container[I].“Admitted”
Pod.Status.ContainerStatus[I].Resources
Admission
Reconciliation
Option 2: Store “admitted” pod resources in spec
Pros:
Cons: