Resource Optimization & Right-Sizing (Goldilocks, Kubecost, OpenCost)
Right-size requests and attribute cost with Goldilocks, Kubecost, or OpenCost.
In plain words
Right-sizing is fitting a vehicle from observed passenger load while reserving enough seats for the busiest station. The simple Kubernetes rule is: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
Think of it like…
Right-sizing is fitting a vehicle from observed passenger load while reserving enough seats for the busiest station.
Where you’ve seen it
An SRE testing a diagnosis runs kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A. Expected evidence: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits. If the run instead shows this symptom, stop and restore the last known state: Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated.
Words you’ll hear
- Goldilocks
- For this lesson, Goldilocks is the controlling idea: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
- Kubecost
- Kubecost is the checkpoint; run
kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -Aand inspect the owner chain. Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated. - OpenCost
- OpenCost is the outcome to preserve; the cost is explicit: Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior.
- Verification evidence
- The evidence command is
kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A. It connects the declaration to this behavior: Right-size requests and attribute cost with Goldilocks, Kubecost, or OpenCost.
Visual diagram
Theory & deep dive
How Goldilocks reaches the intended state
Right-size requests and attribute cost with Goldilocks, Kubecost, or OpenCost. Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
The concrete checkpoint is kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A; compare the Goldilocks owner, Kubecost state, and OpenCost outcome instead of treating YAML acceptance as proof.
Run kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A after the change and correlate the result with Events and the owning object. Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
Kubecost: failure boundary and production cost
Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated. The prerequisite contract is concrete: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior. A safe design limits blast radius, records the last good configuration, and uses kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A as a deterministic rollback checkpoint.
Capture the current state with kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated.
How it works, step by step
Step 1 of 41. Define the symptom and SLI
Turn the user symptom into a measurable question and select a telemetry source: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
- Goal
- Right-size requests and attribute cost with Goldilocks, Kubecost, or OpenCost.
- Owner
- Goldilocks
When to use it & trade-offs
What it is
Right-size requests and attribute cost with Goldilocks, Kubecost, or OpenCost. Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
Why it matters: Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated. The invariant at risk is specific: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits. The quickest fact check before changing the design is kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A.
When to reach for it
- Use Goldilocks to enforce this invariant: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
- Use Kubecost evidence from
kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -Ain reviews and incident timelines. Right-size requests and attribute cost with Goldilocks, Kubecost, or OpenCost. - Choose the managed observability backend route only when this cost is justified by governance or scale: Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior.
When to avoid or be careful
- Avoid assuming Goldilocks is complete after YAML submission; the required behavior is concrete: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
- Avoid treating the next symptom as random; check the owner and state with
kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -Afirst: Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated. - Avoid adopting a heavier platform wrapper before measuring its cost: Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior.
Native, manual, and managed paths for Goldilocks
kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A.Strengths: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
Watch out: Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior. Recovery must also recognize this signal: Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated.
kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A; the expected invariant is: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.Strengths: kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A gives immediate feedback without first building a platform layer.
Watch out: A manual change can hide drift, and unlike Goldilocks, it does not make this symptom self-documenting: Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated.
kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A.Strengths: Platform controls can wrap this exact behavior in policy or dashboards: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
Watch out: The added platform ownership buys value at this cost: Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior.
Interview signals & numbers to know
When this topic comes up
- Interview anchor: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
- Trace Goldilocks to OpenCost through Kubecost; the invariant is: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
- Recognize the symptom: Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated.
- Justify the cost: Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior.
- Verify with kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A instead of only inspecting YAML.
Benchmarks & rules of thumb
- 95
- or higher percentiles are useful request baselines for bursty workloads
- 2
- resource dimensions to right-size: CPU and memory
- 0
- optimization should ignore SLO and HPA behavior
Common mistakes & follow-ups
Common interview mistakes
- Debugging only the child object misses the Goldilocks owner contract: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits.
- Ignoring this telltale condition leads to unrelated changes: Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated.
- Repeating
kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -Awithout an owner for remediation wastes retry cost. Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior.
Likely interviewer follow-ups
- How would API output and runtime evidence prove this behavior: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits?
- Which owner object, logs, and Events would you inspect for this symptom-Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated-?
- At what threshold would this cost become unacceptable: Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior?
kubectl get pods -o custom-columns='NAME:.metadata.name,CPU:.spec.containers[*].resources.requests.cpu,MEM:.spec.containers[*].resources.requests.memory'; kubectl top pod -A, name the failure, then justify the cost. Invariant: Goldilocks combines recommendation signals, Kubecost attributes spend and efficiency, and OpenCost exposes vendor-neutral allocation to optimize Pod requests and limits. Failure: Lowering a request based on one quiet week creates throttling or scheduling contention, and idle-cost attribution can mislead when shared control planes or storage are not allocated. Cost: Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Resource Optimization & Right-Sizing (Goldilocks, Kubecost, OpenCost) with generative AI interview Q&A and hands-on practice.