Kubernetes interview questions

25 questions from the Kubernetes course, each with the correct answer and an explanation. Try to answer before you open the answer.

Kubernetes Fundamentals

1. What does Kubernetes do when a pod's node fails?

  1. Deletes the Deployment
  2. Nothing until an admin intervenes
  3. Creates replacement pods elsewhere to restore the desired count
  4. Shuts down the cluster
Show answer

Answer: Creates replacement pods elsewhere to restore the desired count

Controllers reconcile toward desired state.

Lesson: What Kubernetes Does

2. Which component decides which node a new pod runs on?

  1. The scheduler
  2. etcd
  3. The kubelet
  4. The container image
Show answer

Answer: The scheduler

Scheduling is a control-plane decision.

Lesson: Cluster Architecture

3. What is the difference between spec and status?

  1. spec is only for Services
  2. They are identical
  3. status is written by users
  4. spec is the desired state you declare; status is the observed state reported by the cluster
Show answer

Answer: spec is the desired state you declare; status is the observed state reported by the cluster

Controllers drive status toward spec.

Lesson: kubectl and Declarative Objects

Workloads

4. What happens to a pod when its node dies?

  1. It moves with the same IP
  2. It is gone; a controller creates a replacement pod with a new IP
  3. It is paused until the node returns
  4. The cluster stops
Show answer

Answer: It is gone; a controller creates a replacement pod with a new IP

Pods are ephemeral.

Lesson: Pods

5. What does a Deployment create to manage its pods?

  1. A StatefulSet
  2. A ReplicaSet for each version of the pod template
  3. A new cluster
  4. A Service automatically
Show answer

Answer: A ReplicaSet for each version of the pod template

ReplicaSets keep the replica count; Deployments manage versions.

Lesson: Deployments and ReplicaSets

6. What does maxUnavailable: 0 guarantee during a rollout?

  1. Old pods are never removed
  2. The rollout is instant
  3. No new pods are created
  4. Available pods never drop below the desired replica count
Show answer

Answer: Available pods never drop below the desired replica count

Capacity is preserved; surge provides the room.

Lesson: Rolling Updates: maxSurge and maxUnavailable

7. Why should Jobs be idempotent?

  1. Retries and occasional duplicate runs can execute the same work more than once
  2. Jobs never retry
  3. Kubernetes forbids side effects
  4. It makes images smaller
Show answer

Answer: Retries and occasional duplicate runs can execute the same work more than once

Design for at-least-once execution.

Lesson: Jobs and CronJobs

Networking and Service Discovery

8. How does a Service know which pods to send traffic to?

  1. By pod name prefix
  2. By pod IP addresses written in the Service
  3. Its label selector matches pod labels, and only ready pods receive traffic
  4. Randomly across the cluster
Show answer

Answer: Its label selector matches pod labels, and only ready pods receive traffic

Labels connect Services to pods.

Lesson: Services and Label Selectors

9. What must be installed for an Ingress resource to do anything?

  1. A database
  2. A second cluster
  3. An ingress controller
  4. Nothing, it works by itself
Show answer

Answer: An ingress controller

Ingress is a spec; a controller implements it.

Lesson: Ingress and the Gateway API

10. What does a headless Service return in DNS?

  1. The individual pod addresses instead of a single virtual IP
  2. Nothing
  3. The node's IP only
  4. A public IP
Show answer

Answer: The individual pod addresses instead of a single virtual IP

Used for stable per-pod identities.

Lesson: DNS and Service Discovery

Configuration and Secrets

11. Why keep configuration in ConfigMaps rather than in the image?

  1. It makes pods start faster
  2. Images cannot contain files
  3. ConfigMaps are encrypted
  4. The same image can run in every environment with different settings
Show answer

Answer: The same image can run in every environment with different settings

Build once, configure per environment.

Lesson: ConfigMaps

12. What protection does base64 encoding in a Secret provide?

  1. Strong encryption
  2. None; it is reversible encoding, not encryption
  3. It hides values from cluster admins
  4. It rotates passwords
Show answer

Answer: None; it is reversible encoding, not encryption

Use encryption at rest, RBAC and external secret stores.

Lesson: Secrets: Encoding Is Not Encryption

13. What happens to environment variables from a ConfigMap when the ConfigMap changes?

  1. They update instantly
  2. Running containers keep the old values until they restart
  3. The pod crashes
  4. The ConfigMap is deleted
Show answer

Answer: Running containers keep the old values until they restart

Env vars are read at start.

Lesson: Consuming Configuration in Pods

Resources and Scheduling

14. What happens when a container exceeds its memory limit?

  1. Nothing
  2. It is throttled
  3. It gets more memory automatically
  4. It is OOM-killed and restarted
Show answer

Answer: It is OOM-killed and restarted

Memory is not compressible; CPU is.

Lesson: Requests, Limits and Units

15. What does the scheduler compare against node capacity?

  1. The pods' resource requests
  2. Their actual current usage only
  3. Their image size
  4. Their names
Show answer

Answer: The pods' resource requests

Requests drive placement.

Lesson: How the Scheduler Places Pods

16. Which pods are evicted first when a node runs out of memory?

  1. The newest pods regardless of class
  2. Guaranteed pods
  3. BestEffort pods with no requests or limits
  4. Pods with the longest names
Show answer

Answer: BestEffort pods with no requests or limits

Set requests to protect important pods.

Lesson: QoS Classes and Eviction

Health Checks and Scaling

17. What happens when a readiness probe fails?

  1. The node is drained
  2. The container is restarted
  3. The pod is removed from Service endpoints but not restarted
  4. The Deployment is deleted
Show answer

Answer: The pod is removed from Service endpoints but not restarted

Readiness controls traffic; liveness controls restarts.

Lesson: Startup, Liveness and Readiness Probes

18. Why must CPU requests be set for CPU-based autoscaling?

  1. Utilisation is measured as a percentage of the requested CPU
  2. Requests make pods faster
  3. The HPA ignores CPU
  4. Limits are used instead and requests are optional
Show answer

Answer: Utilisation is measured as a percentage of the requested CPU

No requests, no utilisation percentage.

Lesson: Horizontal Pod Autoscaling

19. What does a PodDisruptionBudget protect against?

  1. High CPU usage
  2. Node hardware failures
  3. Bad code
  4. Too many pods of an app being evicted at once during voluntary disruptions
Show answer

Answer: Too many pods of an app being evicted at once during voluntary disruptions

It paces drains and evictions.

Lesson: Disruptions and PodDisruptionBudgets

Storage and Packaging

20. What does a StatefulSet provide that a Deployment does not?

  1. Faster image pulls
  2. Stable pod identities and a dedicated volume per replica
  3. Automatic autoscaling
  4. Public IP addresses
Show answer

Answer: Stable pod identities and a dedicated volume per replica

Identity and storage per replica.

Lesson: Persistent Volumes and StatefulSets

21. How does Kustomize customise manifests per environment?

  1. It edits files in place
  2. Overlays patch a shared base without a templating language
  3. It uses Go templates
  4. It requires a separate server
Show answer

Answer: Overlays patch a shared base without a templating language

Base plus overlays.

Lesson: Kustomize Overlays

22. When is Helm especially useful?

  1. Building container images
  2. Writing a single Pod by hand
  3. Replacing kubectl entirely
  4. Installing and upgrading configurable third-party software packages
Show answer

Answer: Installing and upgrading configurable third-party software packages

Charts package configurable installs.

Lesson: Helm Charts

Security, Linting and a Checklist

23. Which setting should a manifest linter flag?

  1. An image tag of latest
  2. A pinned image digest
  3. A readiness probe
  4. Memory requests
Show answer

Answer: An image tag of latest

Unpinned images make deployments unpredictable.

Lesson: Linting Manifests

24. What is the default network behaviour between pods without NetworkPolicies?

  1. Only same-node traffic is allowed
  2. All traffic is blocked
  3. All pods can talk to all pods
  4. Only DNS is allowed
Show answer

Answer: All pods can talk to all pods

Policies are needed to restrict traffic.

Lesson: Security Basics

25. Which item belongs on a Kubernetes production checklist?

  1. Run a single replica for simplicity
  2. Use the latest image tag
  3. Containers run as non-root with a hardened securityContext
  4. Store Secret manifests in git as plain base64
Show answer

Answer: Containers run as non-root with a hardened securityContext

Secure, resilient, observable defaults.

Lesson: A Kubernetes Production Checklist

← Back to the course