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. What is the default Service type?

ClusterIPCorrect
NodePort
LoadBalancer
ExternalName

Unless you explicitly ask for something else, a new Service defaults to ClusterIP, meaning it only gets an internal address reachable from inside the cluster. You have to specifically choose NodePort, LoadBalancer, or ExternalName if you want it reachable differently.

medium

2. What is the effect of spec.containers[].resources.requests.cpu: "500m"?

Limits container to 500ms CPU burst per second
Guarantees 0.5 CPU cores for scheduling, and enforces limit if limits is setCorrect
Reserves 500 CPU threads
Throttles CPU if usage > 500m

A CPU 'request' isn't a cap, it's a reservation: it tells the scheduler 'guarantee this container half a CPU core when deciding which node to place it on'. It's a completely separate setting from a CPU 'limit', which is what actually caps how much CPU the container is allowed to use once running.

hard

3. After a bad deployment, you run kubectl rollout undo deployment/api, but the pods come back with the same broken image as before the rollback. What likely happened?

The earlier ReplicaSet revision was already garbage collected past the Deployment's revisionHistoryLimit, so there was nothing to roll back toCorrect
rollout undo requires a --to-revision flag or it does nothing
kubectl rollout undo only reverts the Deployment's labels, not its image
The rollback succeeded, but the image registry served a stale cached layer

Kubernetes only keeps a limited number of old ReplicaSets per revisionHistoryLimit (default 10). If the last known-good revision has already aged out, undo has nothing valid to restore and can effectively re-apply the current broken state.

easy

4. Which command creates a Deployment from a YAML file named app.yaml?

kubectl deploy app.yaml
kubectl apply -f app.yamlCorrect
kubectl run -f app.yaml
kubectl create deployment app.yaml

kubectl apply reads whatever's described in a YAML file and either creates it (if it doesn't exist) or updates it (if it does), which is exactly the 'point at this file and make the cluster match it' behavior you want for deploying from app.yaml.

medium

5. A Deployment rollout appears stuck - kubectl rollout status never completes, and the new pods show as Running but never Ready. What's the likely cause?

The new pods are failing their readiness probe, so the rollout can't proceed past its maxUnavailable/maxSurge thresholdsCorrect
kubectl rollout status only works for StatefulSets, not Deployments
The old ReplicaSet was deleted before the new one was created
The Deployment's replica count was set to zero

A rolling update waits for new pods to pass their readiness probe before continuing to replace old ones. A pod stuck at Running-but-not-Ready halts the whole rollout, since the Deployment controller won't take down more old pods than the strategy allows.

hard

6. What is the difference between emptyDir and ephemeral volumes?

ephemeral requires a StorageClass
ephemeral is a generic concept; emptyDir is one type of ephemeral volume (others: CSI ephemeral, configMap, secret)Correct
emptyDir persists across container restarts; ephemeral does not
emptyDir is deprecated; ephemeral is the new standard

'Ephemeral volume' is really just the general idea of 'storage whose life is tied to the Pod's life', and emptyDir is one specific way to implement that idea. Other kinds like CSI ephemeral, configMap, and secret volumes are also ephemeral volumes, so emptyDir isn't a separate, competing thing, it's one member of that same family.

easy

7. How do you view logs of a Pod named web-123?

kubectl logs web-123Correct
kubectl get events --pod=web-123
kubectl describe pod web-123
kubectl exec web-123 -- cat /var/log/app.log

When you need to see what a container has actually printed out (its stdout/stderr), kubectl logs is the direct route to that output, rather than describe (which shows events and status) or exec (which runs a command inside the container instead of reading its own logs).

medium

8. A Pod is stuck in Pending state. Which is NOT a likely cause?

Image pull failureCorrect
Insufficient CPU/memory resources in the cluster
No node matches the Pod’s node selector/taint tolerance
PersistentVolumeClaim not bound

A Pod only shows as Pending BEFORE it's been scheduled onto a node, and everything else in this list (not enough resources, no matching node, an unbound volume claim) are all things that block scheduling itself. An image pull failure happens AFTER a Pod is already scheduled onto a node, which is why it shows up as ImagePullBackOff instead, not Pending.

hard

9. How can you run a container as non-root and drop all capabilities?

Use podSecurityContext only
In Pod spec: securityContext: {runAsNonRoot: true, capabilities: {drop: ["ALL"]}}
A and CCorrect
Set allowPrivilegeEscalation: false

Locking down a container properly usually takes more than one setting: runAsNonRoot stops it from running as root, capabilities.drop: ["ALL"] strips away extra Linux permissions it doesn't need, and allowPrivilegeEscalation: false stops it from gaining MORE privileges than it started with. Using all of these together, not just one, is what actually hardens the container.

easy

10. What is `kubectl` primarily used for?

Command-line tool for interacting with a Kubernetes clusterCorrect
Managing DNS records
Monitoring server hardware
Building Docker images

Building images is Docker's job, not Kubernetes', and hardware monitoring and DNS management are unrelated, separate systems entirely. `kubectl` is the command-line client that talks to a cluster's API server, letting you create, inspect, update, and delete Kubernetes resources like Pods and Services.

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.