Skip to content
Tutorials Center
My learning

Topics

Lesson 76 of 78 ยท Practice

Kubernetes Interview Questions

Prepare for a Kubernetes interview: architecture, workloads, networking, storage, security and troubleshooting questions with concise answers, diagrams and runnable models.

Kubernetes interviews rarely ask you to recite flags. They ask whether you understand why the system behaves as it does: what happens when you apply a manifest, why a pod is Pending, how a Service finds its pods. This page collects the questions that come up most often, with answers short enough to say aloud, grouped from architecture to troubleshooting.

Kubernetes cannot run on this site, so every manifest and command in the answers is read-only. Three runnable Python stand-ins turn the most-asked ideas into something you can run and explain on a whiteboard: the reconcile loop, QoS classes and Service endpoints. They model the logic, they are not Kubernetes.

A tip for any answer: give the definition in one sentence, a small example, and one trade-off or pitfall. That pattern shows depth without rambling.

Answer in three beats

Define One clear sentence.
Example A real manifest or command.
Pitfall One trade-off or common mistake.
1 / 2

Architecture

What is Kubernetes, and what problem does it solve?

Kubernetes is an open-source system that runs containers across a cluster of machines. You describe the desired state (which images, how many copies, what resources) and the system keeps reality matching it: it places containers, restarts failed ones, scales them and rolls out new versions. It does not build images, and it is not a PaaS by itself. See What Is Kubernetes?.

Name the control plane components and what each does.

  • kube-apiserver: the front door; every client and component talks to it, and it validates, authenticates and stores requests.
  • etcd: the consistent key-value store holding all cluster state.
  • kube-scheduler: assigns unscheduled pods to nodes.
  • kube-controller-manager: runs the controllers (Deployment, ReplicaSet, Node, Job and more).
  • cloud-controller-manager: talks to the cloud for load balancers, nodes and volumes.

Each worker node runs the kubelet (starts the pods assigned to it), kube-proxy (programs Service rules) and a container runtime such as containerd. See Cluster Architecture.

What happens when you run kubectl apply -f deployment.yaml?

sequenceDiagram
  participant U as kubectl
  participant A as API server
  participant E as etcd
  participant C as Controllers
  participant S as Scheduler
  participant K as Kubelet
  U->>A: POST/PATCH Deployment
  A->>E: store object
  C->>A: watch: create ReplicaSet, then Pods
  S->>A: watch: bind Pod to a node
  K->>A: watch: start containers
  K->>A: report status

Nothing calls anything directly: every component watches the API server and reacts.

kubectl authenticates, the API server authorizes, runs admission and validation, and writes the object to etcd. The Deployment controller notices and creates a ReplicaSet, which creates Pods. The scheduler binds each unscheduled Pod to a node, and that node's kubelet starts the containers and reports status back.

What is the control loop (reconciliation)?

A controller repeatedly compares the desired state in the spec with the observed state and acts to close the gap. It is level-triggered: it reacts to the current difference, not to a remembered event, so a missed notification or a restart cannot lose work. That is why Kubernetes is self-healing. See Controllers and the Reconcile Loop.

Python A reconcile loop in 30 lines

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Run it twice in your head: the second pass changes nothing, which is what "idempotent" means for a controller, and killing a pod needs no special handling, because the loop only looks at the gap.

Why is etcd so important, and how do you protect it?

Everything the cluster knows lives there; lose it without a backup and the cluster forgets its objects (running containers keep running, but nobody manages them). Run an odd number of members (3 or 5) for quorum, keep it on fast disks, restrict access, encrypt Secrets at rest and back it up with etcdctl snapshot save. Managed services such as EKS and GKE operate it for you.

Workloads

What is a Pod, and why not just run containers?

A Pod is the smallest deployable unit: one or more containers that share a network namespace (one IP, localhost between them) and can share volumes, scheduled together on one node. Multi-container pods are for tightly coupled helpers such as sidecars. See Pods.

Pod vs ReplicaSet vs Deployment?

A ReplicaSet keeps N identical pods alive. A Deployment manages ReplicaSets to give declarative updates: a new pod template creates a new ReplicaSet and shifts replicas gradually, keeping old ones for rollback. You almost never create a bare ReplicaSet or Pod for an application. See Deployments.

How does a rolling update work?

The Deployment scales the new ReplicaSet up and the old one down in steps limited by maxSurge (extra pods allowed above the desired count) and maxUnavailable (pods allowed to be missing). New pods must pass their readiness probe before old ones are removed. kubectl rollout undo switches back to the previous ReplicaSet. See Rolling Updates and Rollbacks.

When do you use a StatefulSet, DaemonSet or Job?

  • StatefulSet: stable names (db-0, db-1), ordered start-up and per-pod volumes, for databases and clustered systems.
  • DaemonSet: one pod per (selected) node, for log shippers and node agents.
  • Job / CronJob: run to completion once or on a schedule.

Explain liveness, readiness and startup probes.

Liveness failing makes the kubelet restart the container. Readiness failing removes the pod from Service endpoints without restarting it. Startup delays the other two until a slow application has booted. The classic mistake is a liveness probe that checks a dependency (a database), so a brief outage restarts every pod at once. See Probes.

What are QoS classes?

Kubernetes derives a class from requests and limits, and uses it to decide who is evicted first under node memory pressure.

Python Compute the QoS class

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Under node memory pressure the kubelet evicts BestEffort pods first, then Burstable pods using more than they requested, and Guaranteed last. See Resource Requests and Limits.

Networking

How does a Service work?

A Service gives a stable virtual IP and DNS name to a changing set of pods chosen by a label selector. The control plane maintains EndpointSlices listing the ready pod IPs, and kube-proxy (iptables, IPVS or nftables rules) rewrites traffic to the virtual IP into a pod IP. See Services and How Services Really Work: kube-proxy.

Python Which pods receive traffic?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real kube-proxy picks backends randomly (iptables) or by algorithm (IPVS), not strictly round-robin; the model uses round-robin so the output is easy to read.

ClusterIP vs NodePort vs LoadBalancer vs Ingress?

ClusterIP is reachable only inside the cluster. NodePort opens the same port (30000-32767 by default) on every node. LoadBalancer asks the cloud for an external load balancer in front of the nodes. Ingress (and its successor, Gateway API) is not a Service type: it routes HTTP(S) by host and path to Services through a controller. See NodePort, LoadBalancer and ExternalName and Ingress and Ingress Controllers.

How does DNS work inside a cluster?

CoreDNS answers names like web.shop.svc.cluster.local. The pod's resolv.conf has search domains, so within the namespace web is enough. Because of ndots:5, a name with fewer than five dots is first tried with each search domain, which adds lookups for external names; end an external name with a dot to skip that. See DNS and Service Discovery.

What does a NetworkPolicy do?

By default every pod can talk to every pod. A NetworkPolicy selects pods and restricts their ingress and/or egress to specific peers and ports; once a pod is selected for a direction, anything not allowed is denied. It only works if the CNI plugin enforces policies (Calico and Cilium do; plain Flannel does not). See Network Policies.

Configuration and storage

ConfigMap vs Secret? Are Secrets secure?

Both hold configuration, injected as environment variables or mounted files. Secrets are base64-encoded, which is not encryption: anyone with read access to the Secret can decode it. Protect them with RBAC, enable encryption at rest in etcd, and consider an external secrets manager. See Secrets.

Explain PV, PVC and StorageClass.

A PersistentVolume is a piece of storage in the cluster; a PersistentVolumeClaim is a request for it (size, access mode, class); a StorageClass describes how to provision volumes on demand. With dynamic provisioning, creating a PVC makes the provisioner create the volume and bind it. See PersistentVolumes and Claims.

What happens to data when a pod is deleted?

An emptyDir is deleted with the pod; data on a PVC survives. A StatefulSet keeps its PVCs when pods are rescheduled, and the PV's reclaim policy (Delete or Retain) decides what happens when the claim itself is deleted.

Scheduling and scaling

How does the scheduler pick a node?

It filters out nodes that cannot run the pod (insufficient requests, taints, selectors, affinity) and scores the rest (spreading, balance, preferences), then binds the pod to the highest score. A pod that fits nowhere stays Pending, and its events say why. See How the Scheduler Works.

Taints vs node affinity?

Taints live on nodes and repel pods unless they tolerate them; affinity lives on pods and attracts them to nodes. To dedicate nodes you usually combine both. See Taints and Tolerations.

How does the HPA decide replicas?

desired = ceil(current replicas * current metric / target metric), ignored within a 10% tolerance and smoothed by stabilization windows. It needs metrics (metrics-server for CPU and memory) and pods with resource requests, because CPU utilization is measured against the request. See Horizontal Pod Autoscaler.

What is a PodDisruptionBudget?

It limits how many pods of an application may be down during voluntary disruptions such as node drains and upgrades. A PDB with minAvailable equal to the replica count blocks every drain. See PodDisruptionBudgets, Priority and Eviction.

Security

How does RBAC work?

Rules (verbs on resources) live in a Role or cluster-wide ClusterRole; a RoleBinding or ClusterRoleBinding grants them to users, groups or service accounts. Access is additive: there are no deny rules. Check with kubectl auth can-i. See Authentication and RBAC.

How do you secure a workload?

Run as non-root with allowPrivilegeEscalation: false, drop all capabilities, use a read-only root filesystem and the RuntimeDefault seccomp profile; enforce this with Pod Security Admission or a policy engine; give each app its own service account with minimal RBAC; scan and pin images; and add network policies. See Pod Security and Security Contexts.

Troubleshooting

A pod is Pending. What do you do?

Run kubectl describe pod and read the Events. FailedScheduling lists the reasons per node: insufficient CPU or memory, untolerated taints, unmatched selectors, unbound PVCs. Fix the manifest or add capacity.

CrashLoopBackOff? ImagePullBackOff? OOMKilled?

  • CrashLoopBackOff: the container keeps exiting; read kubectl logs --previous and the exit code.
  • ImagePullBackOff: wrong image name or tag, or missing registry credentials.
  • OOMKilled (exit 137): memory limit exceeded.

A Service returns nothing. How do you debug?

Check endpoints first (kubectl get endpointslices), then labels (--show-labels), then readiness, then the targetPort, then DNS from a debug pod, then NetworkPolicies. The full tree is in the Troubleshooting Playbook.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which component is the only one that talks to etcd directly?

    All other components read and write state through the API server, which validates requests and is the sole client of etcd.
  2. 2. What makes a controller 'level-triggered'?

    Level-triggered logic looks at the difference between desired and observed state, which makes controllers idempotent and self-healing.
  3. 3. A pod has requests equal to limits for CPU and memory in every container. Its QoS class is:

    Equal requests and limits for both resources in all containers give Guaranteed, the last class to be evicted under memory pressure.
  4. 4. Why can a failing readiness probe be safer than a failing liveness probe?

    Readiness controls whether the pod receives traffic; liveness triggers a restart, which can make an overloaded system worse.
  5. 5. Are Kubernetes Secrets encrypted by default in etcd?

    Base64 is encoding, not encryption. Enable an EncryptionConfiguration (or use a managed service that does) and restrict read access with RBAC.

Summary

  • Kubernetes keeps desired state in etcd behind the API server; controllers, the scheduler and kubelets watch and converge.
  • Deployments manage ReplicaSets, which manage Pods; StatefulSets, DaemonSets and Jobs cover other shapes of work.
  • Services give stable names over ready pods chosen by labels; Ingress or Gateway API routes HTTP.
  • Requests drive scheduling and QoS; limits cap usage; the HPA scales on utilization of requests.
  • Secrets are encoded, not encrypted; RBAC is additive; Pod Security and NetworkPolicies limit blast radius.
  • Debug from events, then labels and endpoints, then logs.

Next, learn how to pass the exams in CKA, CKAD and CKS Study Guide.