Node capacity and pressure formulas¶
Attune applies always-on node capacity and pressure gates in the resize path (not opt-in). They are safety defaults: skip or avoid request increases that cannot fit on the current node or that worsen a stressed node. They do not require a policy feature flag.
Related product work: capacity-aware recommendations (#372 / #445) and bin-packing / reclaimed capacity signals (#431 / #446).
Multi-container pod formula¶
For a pod on node N with target container C and proposed target requests
T_cpu, T_mem:
- Build the planned pod, the shape Attune would write:
- Merge
T_*intoC's requests. A resource the target omits keeps its current value - When in-place pod-level resize is on and the pod has
spec.resources, raise that envelope to the same container aggregate (app containers plus native sidecars, or each regular init plus the sidecars declared before it). The raise does not replace that sum with the current pod-level request, and it does not add overhead - Take the planned pod's effective request, the scheduler's formula
(
k8s.io/component-helpers/resource.PodRequests): - The sum of
spec.containersand native sidecars (init containers withrestartPolicy: Always) - Or, if larger, each regular init container plus the native sidecars declared before it. A finished init container still counts: the scheduler and kubelet resize admission do not check the phase
- Pod-level
spec.resources.requestsreplace that result for each resource they set - Plus
spec.overhead(RuntimeClass overhead) - That gives CPU millicores and memory bytes →
sum_cpu,sum_mem - Read
N.status.allocatablefor CPU and memory - Skip resize if
sum_cpu > allocatable_cpuORsum_mem > allocatable_mem
Reason string: total pod requests would exceed node allocatable.
Metric: attune_capacity_skip_total{reason="allocatable"}.
Neighbor free request budget¶
For a request increase on a scheduled pod (spec.nodeName set):
- List the pods on the same node (all namespaces), leaving out
SucceededandFailedpods - Sum the effective request of each listed pod (same formula as step 2
above, from its current spec), then subtract this pod's own entry as
listed →
neighbor_sum. Neighbors with no requests add zero - Skip if
sum_* + neighbor_sumexceeds allocatable CPU or memory
Known limit: kubelet sizes a pod with a pending resize from its
allocated resources, not its spec. Attune reads the spec only, so a
neighbor in the middle of a decrease is under-counted and a Deferred
increase is over-counted until kubelet catches up.
Reason string: node free request budget exceeded by neighbors.
Metric: attune_capacity_skip_total{reason="neighbors"}.
Decreases stay allowed. Pods without nodeName skip this gate (not
scheduled yet). DaemonSet pods use the same formula on their current
node. A failed neighbor list skips the increase (fail-closed; same
class as unavailable node status). There is no extra safety margin:
the comparison is a hard greater-than against allocatable.
Static and mirror pods without requests do not consume the budget.
DaemonSet special case¶
DaemonSet pods are node-bound: there is one pod per node (subject to nodeSelector / affinity). Capacity gates still use the same formula against the current node:
- Increases that would make this DaemonSet pod's total requests exceed that node's allocatable are skipped.
- Attune does not rebalance across nodes or skip entire DaemonSets cluster-wide.
- Prefer conservative
maxAllowedfor DaemonSets so recommendations stay within the smallest node pool shape you schedule them on.
Pressure gates¶
When the node has any of these conditions True:
| Condition | Effect |
|---|---|
MemoryPressure |
Skip memory request increases (CPU increases still allowed) |
DiskPressure |
Skip any request increase (CPU or memory) |
PIDPressure |
Skip any request increase |
Decreases remain allowed under pressure (they free capacity).
Metric: attune_capacity_skip_total{reason="pressure"}.
Pressure is read via the typed Kubernetes clientset (live API), not only
the informer cache, and is re-checked immediately before UpdateResize
so a mid-reconcile condition flip cannot authorize an increase.
Unavailable node status (fail-closed for increases)¶
If the pod has a nodeName but Attune cannot load the Node object
(Clientset and controller-runtime client both fail or are unset),
request increases are skipped. Decreases still proceed (same idea as
pressure: free capacity without needing a pressure read).
Reason string: node status unavailable; skipping request increase.
Metric: attune_capacity_skip_total{reason="unavailable"}.
Event: ResizeSkipped.
Empty nodeName (not scheduled yet) does not use this path; scheduling
gates apply elsewhere.
Always-on default¶
These gates run for every resize attempt. There is no capacityAware: false
escape hatch in the first release. To effectively disable pressure sensitivity
you would need nodes without those conditions; allocatable skip only fires
when the proposed pod total exceeds allocatable.
Reclaimed capacity (bin packing signal)¶
When recommendations are below current requests, status and metrics expose freeable request capacity for node consolidation tools:
- Status:
status.savings.reclaimedCpuRequest/reclaimedMemoryRequest(aliases of the reduction fields) - Metrics:
attune_reclaimed_request_cpu_cores,attune_reclaimed_request_memory_bytes
These are estimated from recommendations, not measured node free space. Use them with Cluster Autoscaler / Karpenter-class tools as capacity review inputs, not as a remote node controller. See bin packing.