Back to sections

Kubernetes Interview Questions & Answers

A sample of real Kubernetes interview questions with full answers and explanations - practice for interviews or certification exams.

easy

1. A new pod is stuck in Pending, and kubectl describe pod shows the event: '0/3 nodes are available: 3 Insufficient cpu'. What does this mean?

The cluster's control plane is out of CPU and can't schedule anything
The pod's container image failed to build due to a CPU-intensive step
The pod needs a CPU limit set before it can be scheduled at all
No node in the cluster currently has enough allocatable CPU to satisfy the pod's requested resources.requests.cpuCorrect

The scheduler filters out any node that can't satisfy a pod's requested resources. This event means every node's already-allocated CPU requests leave too little room for what this pod is asking for - the fix is usually more/bigger nodes or a smaller request.

medium

2. A container in a Pod keeps crashing. Which command helps diagnose it?

All of the aboveCorrect
kubectl describe pod <pod>
kubectl get events --field-selector involvedObject.name=<pod>
kubectl logs <pod> --previous

No single command tells the whole story of a crash: --previous shows you what the container printed right before it died, describe pod shows recent events and how many times it's restarted, and get events shows broader scheduling/health signals from the cluster. Using all three together gives you the fullest picture of what actually went wrong.

hard

3. What is Ephemeral Containers used for?

Init containers that auto-delete
Short-lived jobs (replaces Jobs)
Containers with time-limited resource quotas
Debugging running Pods without restarting (added dynamically via kubectl debug)Correct

Normally, debugging a running Pod means adding tools to its image and restarting it, which changes exactly the thing you're trying to investigate. Ephemeral containers let you attach a temporary debugging container to an ALREADY-running Pod on the fly (usually via kubectl debug), without restarting or recreating anything.

easy

4. Your application occasionally hangs due to a bug and stops responding to requests, but the process itself never crashes, so Kubernetes doesn't notice anything is wrong by default. Which feature should you configure so Kubernetes automatically restarts the container when this happens?

A readiness probe.
A liveness probe.Correct
A resource limit.
A namespace quota.

A liveness probe periodically checks whether a container is actually healthy, and if the checks keep failing, the kubelet restarts that container. A readiness probe only controls whether the pod receives traffic, it wouldn't cause the hung container to restart.

medium

5. Your cluster's CNI plugin doesn't implement NetworkPolicy support (e.g. a plain flannel install without Calico). You apply several NetworkPolicy resources to restrict pod traffic. What actually happens?

The resources are accepted and stored by the API server, but silently have no enforcement effect at allCorrect
Traffic is blocked using a slower, less efficient fallback mechanism
Kubernetes automatically switches the cluster to a NetworkPolicy-capable CNI
The API server rejects the resources at creation time

NetworkPolicy is just an API object - Kubernetes itself doesn't enforce it. Enforcement is entirely the CNI plugin's job, so on a plugin that doesn't support it, the policies exist in etcd but do nothing, with no warning or error.

hard

6. You update a Kubernetes Secret with a new database password because the old one was rotated. Pods that reference the Secret as environment variables are still using the old password and fail to connect, while a different pod that mounts the same Secret as a volume picks up the new value after a short delay. Why the difference?

Environment variables are set once at container start from the Secret's value at that time, while a mounted Secret volume gets updated on disk automatically as the underlying Secret changes.Correct
Environment variables are stored in etcd permanently and never change.
Volume mounts require a manual kubectl apply to refresh, while env vars update live.
Secrets used as env vars are cached by DNS.

Environment variables are injected once when the container starts and stay frozen for that container's life, so a Secret change has no effect until the pod restarts, while the kubelet periodically syncs mounted Secret volumes so file contents on disk update without needing a restart. Neither DNS caching nor etcd permanence has anything to do with this behavior.

easy

7. One of your pods keeps getting terminated with the status OOMKilled shortly after it starts processing a large batch of data. What does this status indicate?

The pod failed its liveness probe.
The node ran out of disk space.
The container ran out of CPU time.
The container tried to use more memory than its configured limit allowed, so the kernel killed it.Correct

OOMKilled specifically means the Linux out-of-memory killer terminated the process because it exceeded the memory limit set for the container. Running out of CPU causes throttling rather than a kill, and disk space or probe failures would show up as a different status entirely.

medium

8. You just rolled out a new version of your app and now error rates are spiking. You want to immediately get back to the last known-good version without redeploying from scratch. What should you run?

kubectl rollout undo deployment/<name>Correct
kubectl scale deployment/<name> to 0 replicas
kubectl edit configmap/<name>
kubectl delete deployment/<name>

kubectl rollout undo reverts a Deployment to its previous revision using the rollout history Kubernetes automatically keeps, making it the fast, safe way to recover from a bad release. Deleting the Deployment or scaling it to zero would take the app down entirely instead of restoring the working version.

hard

9. What does the Downward API allow?

Downgrade Kubernetes API versions
Push logs downward to node agents
Inject metadata (e.g., Pod name, namespace, labels) into containers without contacting API serverCorrect
Allow Pods to scale down automatically

Normally, if your app wants to know its own Pod name or namespace, it would have to ask the Kubernetes API directly. The Downward API skips that entirely by exposing a Pod's own metadata (name, namespace, labels) straight into its environment variables or files, no API call needed.

easy

10. Your database pod gets rescheduled to a different node after a crash, but you need the data it had written to disk to still be there when it comes back up. What Kubernetes objects let storage persist independently of any single pod's lifecycle?

ConfigMap and Secret.
Namespace and Label.
Taint and Toleration.
PersistentVolume and PersistentVolumeClaim.Correct

A PersistentVolume represents the actual underlying storage, and a PersistentVolumeClaim is how a pod requests and binds to that storage, so the data outlives any single pod that happens to use it. ConfigMaps and Secrets only hold configuration data, not durable application storage.

Want to practice under real conditions?

Try the full timed Kubernetes quiz.

    Welcome to OpsQuiz!

    Real scenario-based DevOps questions, hands-on practice, and clear explanations for every answer.