How do you find which pods/containers are consuming the most memory?
Quick Answer
Use kubectl top pods -A --sort-by=memory --containers to rank pods (broken out per container) by live memory usage. It requires the metrics-server to be installed.
Detailed Answer
kubectl top reads real-time usage from the metrics-server (not the same as requests/limits). --containers breaks a multi-container pod down so you can see whether the app or a sidecar is the hog, and --sort-by=memory surfaces the biggest consumers — useful for spotting leaks and right-sizing limits. Swap memory for cpu to chase CPU pressure.
Code Example
kubectl top pods -A --sort-by=memory --containers
Interview Tip
Point out it needs the metrics-server and shows actual usage (vs requests/limits) — a distinction interviewers like to probe.