Fun with Learning Technology
LearnCoursesQuestionsTracksToolsNewsExplorePractice
Fun with Learning Technology

A new problem, explained clearly, every day.

Subscribe
Learn
  • Lessons
  • Topics
  • News
  • Tools
  • Courses
  • Career tracks
  • Everything
Site
  • About
  • Contact
  • Support
  • Privacy
  • Terms
Get the daily one

One email per new problem. No spam.

Request a tutorial

Requests shape what gets made next.

© 2026 Fun with Learning TechnologyRSS
Home›Courses›Docker & Kubernetes›Kubernetes Interview Questions

Interview Prep

Kubernetes Interview Questions

This guide provides essential conceptual and practical depth for mastering Kubernetes interview scenarios. Understanding these patterns is crucial for demonstrating architectural competence in distributed system management. You should leverage these insights when tasked with designing, deploying, or troubleshooting containerized workloads in production environments.

Understanding Pod Lifecycle and Restarts

A common interview question explores why a Pod might enter a CrashLoopBackOff state. To understand this, you must grasp that Kubernetes does not perform magic; it monitors the primary process defined in the container's entrypoint. If that process exits with a non-zero code, the container terminates. Kubernetes, acting as a control loop, detects the transition to a failed state and attempts to restart the container based on the restartPolicy (always, on-failure, or never). If the underlying application has a misconfiguration, such as a missing environment variable or a database connection failure, it will crash immediately upon startup. The key to troubleshooting this is checking the container logs via the command line interface to identify the specific error code. Kubernetes only manages the lifecycle of the container; it does not debug your application logic, making robust logging and health checks essential for maintaining high availability within your cluster.

# View logs of a crashing pod to debug startup failure
kubectl logs <pod-name> --previous

# Describe the pod to see events indicating why it failed
kubectl describe pod <pod-name>

Service Discovery and Internal Networking

Kubernetes Services are vital because Pod IP addresses are ephemeral and unpredictable; they change whenever a Pod is destroyed or rescheduled. A Service acts as a stable virtual IP (ClusterIP) that acts as a load balancer across a dynamic set of Pods defined by labels. When a request hits the Service IP, the kube-proxy component on the nodes updates the network rules to route traffic to one of the healthy Pod endpoints. This abstraction decouples the client from the specific identity of individual backend Pods. Interviewers often ask how Services interact with CoreDNS, the internal DNS service. When you create a Service, CoreDNS adds a mapping so other Pods can reach it by name rather than IP. Understanding this flow is critical because it explains how services remain reachable even during rolling updates or scaling events, ensuring that the application remains resilient even when the infrastructure underneath it is constantly shifting and reorganizing.

# Service definition to load balance traffic to app pods
apiVersion: v1
kind: Service
metadata:
  name: backend-service
spec:
  selector:
    app: web-server # Selects pods with this label
  ports:
    - port: 80 # Service port
      targetPort: 8080 # Port exposed by the application

Managing ConfigMaps and Secrets

Decoupling application code from configuration is a fundamental best practice in Kubernetes. ConfigMaps are used to store non-sensitive key-value pairs, while Secrets are designed for sensitive data like API keys or credentials. By injecting these into Pods as environment variables or mounted files, you allow the same container image to behave differently across development, staging, and production environments. From an architectural perspective, this separation allows you to update application configuration without rebuilding the container image. It is important to know that when you update a ConfigMap, pods currently mounting it as a volume will eventually see the change, but pods using them as environment variables will not refresh until the pod is deleted and recreated. This distinction is a classic point of contention in interviews, as it highlights a deep understanding of how Kubernetes propagates configuration state to running processes during the lifecycle of a deployment.

# Example of injecting a ConfigMap as an environment variable
apiVersion: v1
kind: Pod
metadata:
  name: app-config-pod
spec:
  containers:
  - name: app
    image: my-app:latest
    env:
      - name: DB_HOST
        valueFrom:
          configMapKeyRef:
            name: app-config
            key: database_host

Deployment Strategies for Zero Downtime

Deployments provide declarative updates for Pods and ReplicaSets, allowing you to scale up or perform rolling updates. An interviewer will likely ask how to ensure zero downtime during these updates. The rolling update strategy works by incrementally replacing old Pods with new ones; Kubernetes ensures that a minimum number of healthy Pods are always available during this process. The system uses readiness probes to determine when a new Pod is ready to accept traffic; only once the probe succeeds does the load balancer send traffic to the new instance. If you misconfigure these probes, Kubernetes might kill old Pods before the new ones are ready, causing service disruption. Mastering the balance between maxUnavailable and maxSurge settings allows you to control the speed and safety of deployments, ensuring that the cluster can handle the capacity requirements during transition periods while maintaining strict availability requirements for users.

# Deployment configuration with a rolling update strategy
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-deployment
spec:
  replicas: 3
  strategy:
    rollingUpdate:
      maxSurge: 1       # Create 1 extra pod during update
      maxUnavailable: 0 # Keep all pods available
  template:
    spec:
      containers:
      - name: nginx
        image: nginx:1.14

Resource Requests and Limits

Resource management is how Kubernetes ensures cluster stability and quality of service. Requests represent the guaranteed minimum CPU and memory that a container is promised by the scheduler. If you do not specify these, the scheduler might place too many pods on a single node, leading to resource contention. Limits represent the maximum capacity allowed for a container; if a process exceeds its memory limit, the kernel will kill it with an OOM (Out of Memory) signal. CPU is handled differently; it is throttled if a process exceeds its limit but is not killed. Understanding this is crucial because setting too high limits leads to wasted infrastructure costs, while setting them too low leads to frequent application crashes. By setting proper resource boundaries, you allow the scheduler to make intelligent placement decisions across your cluster nodes, effectively preventing 'noisy neighbor' issues where one rogue container consumes all resources on a node.

# Defining resource constraints for a container
resources:
  requests:
    memory: "64Mi"
    cpu: "250m"
  limits:
    memory: "128Mi"
    cpu: "500m"

Key points

  • Pods are the smallest deployable units and are ephemeral by design.
  • Services provide a stable network endpoint for dynamic sets of Pods.
  • ConfigMaps and Secrets enable environment-agnostic container images.
  • Rolling updates ensure service availability through readiness probing.
  • Resource requests help the scheduler place pods on nodes efficiently.
  • Resource limits prevent a single container from exhausting node resources.
  • Labels and selectors are the primary mechanism for grouping and managing resources.
  • Logging and monitoring are essential for troubleshooting automated scheduling decisions.

Common mistakes

  • Mistake: Confusing a Pod with a Container. Why it's wrong: A Pod can contain multiple containers that share resources. Fix: Think of the Pod as the smallest deployable unit, not the container itself.
  • Mistake: Manually managing Pods directly. Why it's wrong: Direct management ignores high availability and self-healing. Fix: Always use Controllers like Deployments to manage Pod replicas.
  • Mistake: Overusing the 'latest' image tag. Why it's wrong: It makes rollbacks and debugging unpredictable because the image content can change. Fix: Always use specific version tags or digests for immutability.
  • Mistake: Assuming Service endpoints update instantly. Why it's wrong: There is a propagation delay for DNS and iptables updates across the cluster. Fix: Design applications to be resilient to temporary connection failures.
  • Mistake: Running everything as root. Why it's wrong: It violates the principle of least privilege and increases security risks. Fix: Define 'securityContext' in Pod specifications to run as non-root users.

Interview questions

What is the fundamental difference between a Docker container and a Kubernetes pod?

A Docker container is a standalone unit that packages software code and its dependencies into a single runnable image. Conversely, a Kubernetes pod is the smallest deployable unit in the cluster, which may contain one or more containers that share the same network namespace and storage volumes. We use pods because they allow closely related processes to communicate via localhost while scaling together as a single atomic unit, providing much more orchestration capability than a single isolated container.

How does a Kubernetes Deployment ensure that a specified number of application replicas are always running?

A Kubernetes Deployment uses a controller loop to constantly monitor the current state of the cluster against the desired state defined in your YAML manifest. If a pod crashes or a node fails, the Deployment controller detects the discrepancy and automatically spins up a new pod to match the requested replica count. This declarative approach is superior to manual management because it ensures high availability and self-healing without requiring human intervention to maintain the application's uptime.

What is the purpose of a Kubernetes Service, and why is it necessary for communication?

Because pods in a Kubernetes cluster are ephemeral and frequently destroyed or recreated with new IP addresses, they cannot rely on static networking. A Kubernetes Service provides a stable, permanent IP address and DNS name that acts as a load balancer for a group of pods. For example, by using a selector in a Service manifest, you ensure that traffic is correctly routed to the active backends, abstracting the pod's underlying network volatility.

Compare and contrast a ConfigMap and a Secret in Kubernetes; when should you use each?

Both ConfigMaps and Secrets are used to inject configuration data into containers, but their primary distinction lies in sensitivity and security. ConfigMaps are designed for plain-text configuration data, such as application settings, environment variables, or port numbers, which do not pose a risk if exposed. Secrets are specifically designed to store sensitive information like passwords, API keys, or TLS certificates. Kubernetes encodes Secrets as base64 strings and provides encryption at rest, making them the appropriate mechanism for protecting credentials while keeping the application configuration separate from the underlying Docker image code.

What is the role of the Kubelet, and how does it interact with the Docker runtime?

The Kubelet is the primary node agent that runs on every worker node in a Kubernetes cluster. It acts as the bridge between the Kubernetes control plane and the node itself. It receives instructions in the form of PodSpecs and ensures that the specified containers are running and healthy. It interacts with the Docker runtime by invoking the Container Runtime Interface (CRI) to pull required images, start containers, and monitor their process states. Without the Kubelet, the master node would have no way to enforce the desired container state on individual worker hardware.

Explain the mechanics of a Kubernetes Rolling Update versus a Recreate deployment strategy.

In a Recreate strategy, Kubernetes shuts down all existing pods of the old version before starting the new pods, which results in significant downtime but is easier to manage. A Rolling Update, by contrast, replaces pods incrementally, spinning up new ones while gracefully terminating the old ones. This is the preferred method in production because it ensures zero downtime and continuous availability. You define this in your deployment manifest using the 'strategy' field, where 'maxUnavailable' and 'maxSurge' parameters allow you to fine-tune exactly how many pods are replaced simultaneously, balancing deployment speed against the load capacity of your cluster nodes during the transition.

All Docker & Kubernetes interview questions →

Check yourself

1. When a Deployment is updated to a new container image, how does Kubernetes ensure there is no downtime during the transition?

  • A.It deletes all old pods and replaces them with new ones simultaneously.
  • B.It uses a RollingUpdate strategy to incrementally replace pods while maintaining readiness.
  • C.It pauses all incoming traffic until the new pods are fully operational.
  • D.It uses a Recreate strategy to perform a seamless swap of existing processes.
Show answer

B. It uses a RollingUpdate strategy to incrementally replace pods while maintaining readiness.
The RollingUpdate strategy ensures availability by spinning up new pods before removing old ones. Simultaneous deletion leads to downtime, pausing traffic is not a native behavior, and Recreate shuts down all instances before starting new ones.

2. What is the primary role of a Service in a Kubernetes cluster?

  • A.To provide a persistent storage volume for containers.
  • B.To monitor the CPU and memory usage of the nodes.
  • C.To provide a stable network endpoint for a group of dynamic Pods.
  • D.To manage the authentication of users accessing the cluster API.
Show answer

C. To provide a stable network endpoint for a group of dynamic Pods.
Services abstract the ephemeral nature of Pod IPs by providing a single stable DNS name and IP. Storage is handled by PersistentVolumes, monitoring by metrics-server, and authentication by RBAC, not Services.

3. Why is it generally better to use a ConfigMap rather than hardcoding environment variables in a Deployment manifest?

  • A.ConfigMaps allow for automatic container image rebuilding.
  • B.ConfigMaps decouple configuration from the application image, allowing the same image to run in different environments.
  • C.ConfigMaps are the only way to store encrypted credentials.
  • D.ConfigMaps allow the Pod to automatically restart when a configuration change is detected.
Show answer

B. ConfigMaps decouple configuration from the application image, allowing the same image to run in different environments.
Decoupling configuration enables the same image to be promoted across environments. Rebuilding is not a function of ConfigMaps, secrets (not ConfigMaps) store credentials, and Pods do not automatically restart on ConfigMap changes.

4. If a Pod is stuck in a 'CrashLoopBackOff' state, what is the most logical first step for troubleshooting?

  • A.Restart the entire Kubernetes cluster.
  • B.Check the container logs using kubectl logs to identify the application error.
  • C.Increase the resource limits for the node.
  • D.Change the container runtime from Docker to a different engine.
Show answer

B. Check the container logs using kubectl logs to identify the application error.
Checking application logs reveals why the process inside the container is failing immediately. Restarting the cluster is destructive, resource limits rarely cause crash loops, and the runtime engine is usually not the culprit for basic crashes.

5. What is the purpose of a Readiness Probe in a Pod specification?

  • A.To kill the container if it uses too much memory.
  • B.To signal to the Service that the Pod is ready to accept network traffic.
  • C.To restart the container if the application process exits with an error.
  • D.To ensure the container has finished downloading all external dependencies.
Show answer

B. To signal to the Service that the Pod is ready to accept network traffic.
Readiness probes prevent traffic from being routed to a Pod that isn't ready. Liveness probes handle restarting failed containers, and resource limits manage memory usage; dependency management is an application-level concern.

Take the full Docker & Kubernetes quiz →

← PreviousDocker Interview Questions

Docker & Kubernetes

24 lessons, free to read.

All lessons →

Track your progress

Sign in to mark lessons done, score quizzes and keep notes.

Open in the app