Kubernetes Interview Questions

Master Kubernetes with these real-world interview questions and answers.

Switch Topic:

Beginner Questions

Core concepts, syntax, and foundational command-line knowledge.

Easy Associate Level Kubernetes
Q:

What is a ConfigMap and when would you use it over an environment variable?

A ConfigMap stores non-sensitive configuration data as key-value pairs. It decouples your configuration from your container image.

Use ConfigMaps over hardcoded env vars when:

  • Config needs to differ between environments (dev/staging/prod)
  • Multiple pods share the same configuration
  • You need to mount config as a file (e.g., nginx.conf, prometheus.yml)

For sensitive data like passwords, use a Secret instead of a ConfigMap.

Intermediate Questions

Infrastructure management, deployment strategies, and delivery flows.

Medium Senior Level Kubernetes
Q:

Explain the difference between a Liveness probe, Readiness probe, and Startup probe.

Liveness Probe: Checks if the container is alive. If it fails, Kubernetes restarts the container. Use this to recover from deadlocks.

Readiness Probe: Checks if the container is ready to serve traffic. If it fails, the pod is removed from Service endpoints (no traffic sent). Use this during slow startup or when temporarily overloaded.

Startup Probe: Only runs at startup. Allows slow-starting containers enough time to initialize before liveness checks begin. Prevents liveness probes from killing a pod that is simply starting up slowly.

Medium Senior Level Kubernetes
Q:

What is a Kubernetes Ingress and how does it differ from a Service?

A Service exposes a set of pods internally or as a simple LoadBalancer. An Ingress is a Layer-7 (HTTP/HTTPS) routing rule that sits in front of multiple services and routes traffic based on hostname or path.

Example: Route api.example.com to the api-service and example.com to the frontend-service using a single load balancer IP. This is far more cost-effective than having a separate LoadBalancer service for each microservice.

Advanced Questions

Enterprise orchestration, deep architectural concepts, and scaling issues.

Hard Lead / Architect Level Kubernetes
Q:

Explain Kubernetes RBAC and how you would give a service account read-only access to pods.

RBAC (Role-Based Access Control) is the authorization mechanism in Kubernetes. It uses three objects:

  • Role/ClusterRole: Defines what actions are allowed on which resources.
  • ServiceAccount: An identity for pods or external tools.
  • RoleBinding/ClusterRoleBinding: Links a ServiceAccount to a Role.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: pod-reader
rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: read-pods
subjects:
- kind: ServiceAccount
  name: my-service-account
roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io

Real Production Scenarios

Real-world architecture, system migration, and design challenges.

Medium Senior Level Kubernetes
Q:

What is the purpose of a PodDisruptionBudget (PDB) in Kubernetes?

A PodDisruptionBudget limits how many pods of a deployment can be unavailable simultaneously during voluntary disruptions like node drains, cluster upgrades, or scaling down.

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: api-pdb
spec:
  minAvailable: 2
  selector:
    matchLabels:
      app: api

Without a PDB, a cluster upgrade could drain multiple nodes simultaneously and take down your entire service. With minAvailable: 2, Kubernetes ensures at least 2 pods are always running.

Hard Lead / Architect Level Kubernetes
Q:

Explain Kubernetes network policies and how you would isolate a production namespace.

By default, all pods in a Kubernetes cluster can communicate with each other freely. NetworkPolicies are namespace-scoped firewall rules that control which pods can talk to which.

To enforce full isolation on a namespace, start by denying all ingress and egress, then selectively allow only what’s needed:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-all
  namespace: production
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress

Then add specific allow rules for your database, monitoring agents, and DNS (port 53).

Medium Senior Level Kubernetes
Q:

How does the Kubernetes Horizontal Pod Autoscaler (HPA) work?

HPA automatically scales the number of pod replicas based on observed metrics. The default metric is CPU utilization, but it also supports memory and custom metrics via the Metrics API.

kubectl autoscale deployment my-app --min=2 --max=10 --cpu-percent=60

The HPA controller checks metrics every 15 seconds (default) and adjusts replicas to maintain the target. For custom metrics, you can integrate tools like KEDA (Kubernetes Event-Driven Autoscaling) which can scale based on Kafka lag, SQS queue depth, and more.

Hard Lead / Architect Level Kubernetes
Q:

How do you manage secrets securely in Kubernetes? What are the alternatives to plain Kubernetes Secrets?

Kubernetes Secrets are base64-encoded, not encrypted by default. For production, consider these approaches:

  • Encryption at Rest: Enable EncryptionConfiguration to encrypt secrets in etcd.
  • External Secrets Operator: Syncs secrets from AWS Secrets Manager, GCP Secret Manager, or HashiCorp Vault into Kubernetes Secrets automatically.
  • HashiCorp Vault Agent Injector: Injects secrets directly into Pod filesystems without storing them in Kubernetes at all.
  • Sealed Secrets: Encrypts secrets client-side so they are safe to commit to Git.
Medium Senior Level Kubernetes
Q:

How do services in different namespaces communicate in Kubernetes?

All services in a Kubernetes cluster are reachable via DNS using the Fully Qualified Domain Name (FQDN):

<service-name>.<namespace>.svc.cluster.local

For example, a service named postgres in the production namespace is reachable at postgres.production.svc.cluster.local from any pod in any namespace. If NetworkPolicies are in place, you must explicitly allow cross-namespace traffic.

Medium Senior Level Kubernetes
Q:

What is the difference between a StatefulSet and a Deployment?

Use a Deployment for stateless workloads (web servers, APIs) where any Pod is interchangeable. Use a StatefulSet for stateful workloads like databases that need:

  • Stable, predictable network identities (pod-0, pod-1, etc.)
  • Ordered, graceful deployment and scaling
  • Stable persistent storage linked to each pod individually

Common examples: Kafka, ZooKeeper, Cassandra, PostgreSQL replicas.

Easy Associate Level Kubernetes
Q:

What is the difference between a Pod and a Deployment in Kubernetes?

A Pod is the smallest deployable unit in Kubernetes — it wraps one or more containers that share the same network and storage. However, Pods on their own are ephemeral.

A Deployment is a higher-level abstraction that manages Pods. It ensures a specified number of Pod replicas are running at all times, handles rolling updates, and allows rollbacks. You almost never create bare Pods in production; you use Deployments instead.

kubectl create deployment nginx --image=nginx:1.25 --replicas=3
Medium Senior Level Kubernetes
Q:

How do you perform a zero-downtime rolling update in Kubernetes?

Kubernetes Deployments support RollingUpdate strategy by default. The key is configuring maxSurge and maxUnavailable correctly alongside working readiness probes.

strategy:
  type: RollingUpdate
  rollingUpdate:
    maxSurge: 1
    maxUnavailable: 0

With maxUnavailable: 0, Kubernetes will never take down an old Pod until the new one is healthy (as determined by its readiness probe). This guarantees zero downtime.

Easy Associate Level Kubernetes
Q:

Explain the role of ‘Sidecar’ containers in Kubernetes pod architecture.

A sidecar container is a secondary container that runs along with the main application container within the same pod. It is used to extend and enhance the functionality of the main container, such as by providing logging, monitoring, or proxy services.

Medium Senior Level Kubernetes
Q:

What is a ‘StatefulSet’ and when should you use it over a ‘Deployment’ in Kubernetes?

A StatefulSet is used for stateful applications that require unique, persistent identities and stable network identifiers. Unlike Deployments, which are for stateless pods, StatefulSets manage pods that are not interchangeable and have sticky identities.

Hard Lead / Architect Level Kubernetes
Q:

How do you implement Zero-Downtime deployments with Kubernetes Service objects?

Discuss RollingUpdate strategies, readiness probes, and the role of Service selectors in traffic routing during a rollout.

Troubleshooting Scenarios

Live system debugging, incident diagnostics, and latency resolution.

Hard Lead / Architect Level Kubernetes
Q:

How do you troubleshoot high memory usage causing OOMKilled events in production?

When a container exceeds its memory limit, the kernel OOM killer terminates it and Kubernetes logs OOMKilled. Steps to resolve:

  1. Identify: kubectl describe pod <pod> — look for Reason: OOMKilled in Last State.
  2. Profile: Use kubectl top pod or Prometheus/Grafana to understand actual memory usage patterns.
  3. Fix: Either increase limits if the app genuinely needs more memory, or find and fix the memory leak in the application code.
  4. Prevent: Set up PrometheusRule or Datadog alerts to notify before a pod hits its limit.
Easy Associate Level Kubernetes
Q:

What are resource requests and limits in Kubernetes, and why are they important?

Requests tell the Kubernetes scheduler how much CPU/memory to reserve for a pod when scheduling it onto a node. Limits are the hard caps — the container is throttled (CPU) or killed (memory) if it exceeds them.

resources:
  requests:
    memory: "128Mi"
    cpu: "250m"
  limits:
    memory: "256Mi"
    cpu: "500m"

Always set both. Without requests, the scheduler cannot make good placement decisions. Without limits, a runaway container can starve other workloads on the same node (the “noisy neighbor” problem).

Hard Lead / Architect Level Kubernetes
Q:

How do you debug a pod stuck in CrashLoopBackOff?

CrashLoopBackOff means the container starts but repeatedly crashes. Use this systematic approach:

  1. Check logs: kubectl logs <pod> --previous to see the crash output.
  2. Describe the pod: kubectl describe pod <pod> to inspect Events, resource limits, and probe failures.
  3. Check OOM: If you see OOMKilled, the container exceeded its memory limit.
  4. Shell override: Override the entrypoint to keep the container alive for inspection: command: ["sleep", "3600"]