Chapter 17: Interview Questions and Job Readiness
17.8 Monitoring, logging, Kubernetes
Why: the problem
Kubernetes and monitoring questions are where panels test real experience. At a company like PhonePe they show you a pod stuck in CrashLoopBackOff and ask what you do. Or "the service returns nothing", or "pods are Pending", or "an alert fired for high error rate, walk me through it". The answer is always a short chain of kubectl commands and reading the output calmly. In this lesson you will run a free local cluster with kind, then create the four most asked pod problems on purpose: CrashLoopBackOff, ImagePullBackOff, Pending, and a Service with no endpoints. You will also connect it to the monitoring side: which metric or log line would have warned you.
What we will build
You will create a kind cluster, deploy broken apps one by one, and use one Kubernetes triage chain: get, describe, logs, events, endpoints. Then you will answer the "error rate alert" question using golden signals and a log search.
What: every term in plain English
- kind — Kubernetes in Docker. A full cluster on your laptop for practice.
- Pod — The smallest unit in Kubernetes. One or more containers together.
- CrashLoopBackOff — The container keeps crashing and Kubernetes waits longer before each restart.
- ImagePullBackOff — Kubernetes cannot download the image: wrong name, tag or no access.
- Pending — The pod is not placed on any node, usually not enough CPU or memory.
- Endpoints — The list of pod IPs behind a Service. Empty means the selector matches nothing.
- Events — Short messages Kubernetes writes about what happened to an object.
- Golden signals — Latency, traffic, errors and saturation. The four things to watch for any service.
How: step by step
-
Create a cluster
kind create cluster --name iqWhat it does: One node cluster in Docker.
Output
Creating cluster "iq" ... ✓ Ready -
Check nodes
kubectl get nodesWhat it does: Node must be Ready.
Output
NAME STATUS ROLES AGE VERSION iq-control-plane Ready control-plane 40s v1.31.0 -
Make a crashing pod
kubectl run crash --image=busybox:1.36 --restart=Always -- sh -c "echo starting; exit 1"What it does: It starts and exits with 1 every time.
Output
pod/crash created -
Triage 1: get
kubectl get pod crashWhat it does: STATUS and RESTARTS are the first clue.
Output
NAME READY STATUS RESTARTS AGE crash 0/1 CrashLoopBackOff 3 (20s ago) 70s -
Triage 2: logs of the last crash
kubectl logs crash --previousWhat it does: --previous shows the output before the last restart.
Output
starting -
Triage 3: describe
kubectl describe pod crash | sed -n "/Last State/,/Exit Code/p"What it does: Shows the exit code and reason.
Output
Last State: Terminated Reason: Error Exit Code: 1
Example 1: ImagePullBackOff: wrong tag
Stack. Kubernetes
Goal. ImagePullBackOff: wrong tag.
Commands
kubectl create deployment web --image=nginx:1.99-does-not-exist
kubectl get pods -l app=web
kubectl describe pod -l app=web | grep -A3 Events
kubectl set image deployment/web nginx=nginx:1.27
kubectl rollout status deployment/web
What each line does
create deployment— Makes a Deployment with a bad tag.describe ... Events— The event says the tag was not found.set image— Fixes the tag in place.rollout status— Waits until the new pods are ready.
Green output
web-6c9f-x2k 0/1 ImagePullBackOff 0 30s
Warning Failed ... Failed to pull image "nginx:1.99-does-not-exist": not found
deployment "web" successfully rolled out
Expected result. Interview line: ImagePullBackOff means name, tag, registry login or network. describe events tell which.
Example 2: Pending: asking for too much CPU
Stack. Kubernetes
Goal. Pending: asking for too much CPU.
big.yaml
apiVersion: v1
kind: Pod
metadata: { name: big }
spec:
containers:
- name: app
image: nginx:1.27
resources:
requests: { cpu: "64", memory: 1Gi }
Commands
kubectl apply -f big.yaml
kubectl get pod big
kubectl describe pod big | tail -3
kubectl describe node iq-control-plane | grep -A5 "Allocated resources"
kubectl delete pod big
What each line does
requests cpu 64— Asks for 64 CPUs. Our laptop node does not have that.Pending— The scheduler cannot find a node.FailedScheduling event— Says Insufficient cpu.Allocated resources— Shows how much is already used on the node.Fix— Lower the request, add nodes, or let Cluster Autoscaler or Karpenter add them.
Green output
big 0/1 Pending 0 10s
Warning FailedScheduling 0/1 nodes are available: 1 Insufficient cpu.
Expected result. You connect Pending to requests and node capacity.
Example 3: Service with no endpoints: label mismatch
Stack. Kubernetes
Goal. Service with no endpoints: label mismatch.
svc.yaml
apiVersion: v1
kind: Service
metadata: { name: web }
spec:
selector: { app: website }
ports: [{ port: 80, targetPort: 80 }]
Commands
kubectl apply -f svc.yaml
kubectl get endpoints web
kubectl get pods --show-labels | head -3
kubectl patch svc web -p '{"spec":{"selector":{"app":"web"}}}'
kubectl get endpoints web
kubectl run t --rm -it --image=busybox:1.36 --restart=Never -- wget -qO- web | head -4
What each line does
selector app: website— Wrong label. Pods are labelled app=web.get endpoints— Empty ENDPOINTS proves the selector matches nothing.--show-labels— Shows the real labels on pods.kubectl patch— Fixes the selector.wget from a test pod— Tests the Service by DNS name from inside the cluster.
Green output
NAME ENDPOINTS AGE
web none 5s
web 10.244.0.7:80 20s
Welcome to nginx!
Expected result. Interview line: a Service with no endpoints is almost always a label or port mismatch.
Example 4: Alert scenario: "5xx error rate is 8 percent"
Stack. Prometheus, Kubernetes
Goal. Alert scenario: "5xx error rate is 8 percent".
PromQL you would show
sum(rate(http_requests_total{status=~"5.."}[5m]))
/ sum(rate(http_requests_total[5m]))
Your walk-through
1. Acknowledge the alert. Post in the incident channel.
2. Check golden signals on the dashboard:
errors up at 19:02, latency p99 up, traffic normal, CPU normal.
3. What changed at 19:00? kubectl rollout history deployment/pay
-> revision 14 deployed at 18:58.
4. Logs: kubectl logs deploy/pay --since=10m | grep -c "timeout to db"
-> 412 lines.
5. Decide: roll back first, debug later.
kubectl rollout undo deployment/pay
6. Errors back to 0.2 percent at 19:09. MTTR 7 minutes.
7. Postmortem: new code used a smaller DB pool. Add a test and an alert.
What each line does
PromQL ratio— 5xx per second divided by all requests per second.Golden signals— Quick map of what is wrong.What changed?— Most incidents follow a deploy or config change.Roll back first— Restore users fast, investigate later.Numbers— Times and percentages make the story believable.
Green output
errors 8.1 percent -> 0.2 percent after rollback
incident closed, MTTR 7 min
Expected result. A full, calm incident story with commands and numbers.
Verify: did it work?
-
All pods healthy
kubectl get podsWhat it does: Everything Running.
Output
web-7d8b-q1 1/1 Running 0 2m -
Recent events
kubectl get events --sort-by=.lastTimestamp | tail -3What it does: A quick timeline of the cluster.
Output
Normal Started pod/web-7d8b-q1 Started container nginx
When it is red 1
The connection to the server localhost:8080 was refused
Cause. kubectl has no context, the cluster is not up.
Fix, step by step
- kind get clusters
- kubectl cluster-info --context kind-iq
When it is red 2
OOMKilled in describe
Cause. Container went over its memory limit.
Fix, step by step
- Raise limits.memory or fix the leak.
- Watch kubectl top pod (needs metrics-server).
When it is red 3
Readiness probe failed: HTTP probe failed with statuscode: 404
Cause. The probe path is wrong or the app is not ready.
Fix, step by step
- Check the path and port in the probe.
- curl it from inside the pod with kubectl exec.
Cleanup
-
Delete the cluster
kind delete cluster --name iqWhat it does: Removes everything.
Output
Deleting cluster "iq" ...
Ravindra Bagale's Tip
When a pod breaks: get, describe, logs --previous — that triad. In an incident, rollback first, then investigate.
Pod तुटला तर get, describe, logs --previous — हा triad. Incident मध्ये आधी rollback, मग investigation.
Pod टूटे तो get, describe, logs --previous — ये triad. Incident में पहले rollback, फिर investigation.
Practice tasks
Medium Liveness vs readiness
Why: A top follow-up question.
What to do: Add both probes to a Deployment and break each one.
- Break readiness: pod stays but gets no traffic.
- Break liveness: pod restarts.
Check: You can explain the difference from what you saw.
Hard HPA demo
Why: Scaling is often asked.
What to do: Install metrics-server and an HPA at 50 percent CPU, then load it.
- kubectl autoscale deployment web --cpu-percent=50 --min=1 --max=5
- Generate load with a busybox loop.
Check: Replicas go up, then down.
Easy Say Kubernetes and monitoring in two lines
Why: Interviewers cut you off after 30 seconds. The short version must come first.
What to do: Write a two line answer about Kubernetes and monitoring for a fresher interview.
- Line 1: the problem it solves.
- Line 2: the one command or file you used.
- Say it aloud with a timer.
Check: You finish inside 30 seconds and you name one real command.
Easy Run the commands, not just read them
Why: An interviewer can tell if you only read. Typing the command once gives you the real output to talk about.
What to do: Run every command in the How part of this lesson on your own lab machine.
- Start a small Ubuntu VM, WSL or EC2 t3.micro.
- Run each step and save the output in notes.txt.
- Mark any output that looks different from the lesson.
Check: notes.txt has the real output of every step.
Medium Break it on purpose
Why: You must know the red error by face. In a live round there is no time to read slowly.
What to do: Cause one error from the "When it is red" part of this lesson and fix it.
- Follow the error section.
- Copy the exact message into your notes.
- Write the fix in one line.
Check: You fixed it using only your notes.
Medium Answer in the 4-line shape
Why: A clear shape makes any answer sound senior: Situation, Check, Fix, Prevent.
What to do: Pick one interview question from this lesson and answer in four lines.
- Situation: what broke.
- Check: the command you ran and what it showed.
- Fix: the change you made.
- Prevent: the alert, test or doc you added.
Check: Each of the four lines has a real noun, like a command, a file or a number.
Medium Mock round with a friend
Why: Speaking is a different skill from knowing. Practice it.
What to do: Let a friend ask you three questions from this lesson.
- Friend picks random questions.
- You answer, friend times you.
- Swap and repeat.
Check: You answer all three without saying "I am not sure" twice.
Hard Whiteboard it top to bottom
Why: Many panels say "draw it". A neat top-to-bottom drawing shows you see the whole flow.
What to do: Draw the main flow of this lesson as boxes from top to bottom.
- Start at the user or the trigger.
- Add each hop: server, container, pipeline, tool.
- Write the command you use to check each box beside it.
Check: Every box has one check command next to it.
Hard Write a mini runbook
Why: Good engineers leave notes for the next person. Interviewers love to hear that you do this.
What to do: Write a one page runbook for the main scenario in this lesson.
- Title, symptoms, first 3 checks, fix, how to confirm, how to undo.
Check: A teammate can follow it alone at 2 a.m.
Homework: try at home
Try at home
At home, deploy an app with a wrong containerPort and a readiness probe. Find why it is never Ready using describe, fix it and write the 4-line answer.
Recap
- Kubernetes triage: get, describe, logs --previous, events, endpoints.
- CrashLoopBackOff: read previous logs and exit code.
- ImagePullBackOff: tag, name, registry auth.
- Pending: requests vs node capacity.
- Incidents: golden signals, what changed, roll back first.
FAQ
kind or minikube?
Both are fine for practice. kind is light and fast in Docker.
Do I need EKS for interviews?
Know what EKS adds (managed control plane, IAM, load balancers). Practise kubectl on kind.
What is the difference between a Deployment and a Pod?
A Deployment manages ReplicaSets that keep the right number of pods running.
What are requests and limits?
Requests are for scheduling; limits are the max a container may use.
Logs disappear when a pod is deleted?
Yes, unless you ship them with Fluent Bit to CloudWatch or Loki.
Interview questions
-
Pod in CrashLoopBackOff. Steps?
kubectl logs --previous, describe for exit code and events, check config, env, probes and limits, fix and roll out.
-
How does a Service find pods?
Using its label selector; matching pod IPs become endpoints.
-
Readiness vs liveness probe?
Readiness controls traffic; liveness restarts a stuck container.
-
How do you roll back a Deployment?
kubectl rollout undo deployment/NAME, then rollout status.
-
An alert fired. How do you handle it?
Acknowledge, check golden signals, find what changed, mitigate (often rollback), communicate, postmortem.
-
Pods are Pending. Why?
Insufficient CPU or memory, node selectors or taints, or unbound PVCs. describe shows the reason.
Quick quiz
Q1. First three kubectl commands for a broken pod?
get, describe, logs --previous.
Q2. ImagePullBackOff means?
Image cannot be pulled: tag, name, auth or network.
Q3. Pod Pending, likely cause?
Not enough resources or no matching node.
Q4. Service has no endpoints?
Selector does not match pod labels.
Q5. Four golden signals?
Latency, traffic, errors, saturation.
Did you understand? Let us try it once more.
Revision card
Interview card