Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 135/ 160
07. Observability, Troubleshooting & SRE

Resource Optimization & Right-Sizing (Goldilocks, Kubecost, OpenCost)

Right-size requests and attribute cost with Goldilocks, Kubecost, or OpenCost.

IntermediateGoldilocks · Kubecost · OpenCost3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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 -A and 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

Loading interactive 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.

Verify Kubecost, not only object creation

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.

Key takeaway: Goldilocks is implemented only when this invariant remains observable: 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.

Recover from Kubecost drift

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.

Key takeaway: Accept the trade-off consciously: Right-sizing releases bin-packable capacity, but the safe change depends on p95/p99 need, burst pattern, PDB, and HPA behavior.

How it works, step by step

Step 1 of 4
SRE and service owner

1. 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.

Goldilocks contract → owned state
Key numbers at this step
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 -A in 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 -A first: 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

Metrics and evidence-led diagnosis
Best for: Right-size requests and attribute cost with Goldilocks, Kubecost, or OpenCost. A concrete incident check 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.

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.

Ad-hoc console inspection
Best for: Quickly testing the Kubecost assumption 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; 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.

Managed observability backend
Best for: Teams that need OpenCost integrated with guardrails; the evidence path 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.

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 -A without 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?
Interview tip: Interview sequence: state the invariant, 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, 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

Loading quiz

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.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
DNS & CoreDNS Latency/Failure Diagnostics
Next topic
Chaos Engineering on Kubernetes (LitmusChaos / Chaos Mesh)