Skip to content
RED SAGSkills

Kubernetes interview questions and answers

Kubernetes interview questions test how you deploy, scale and debug containers in a cluster.

Below are 60 Kubernetes questions with the correct answer and a short explanation, grouped from fresher to experienced level. Try each one before you open the answer.

What Kubernetes interviews usually check

  • ✓Pods, Deployments and Services
  • ✓ConfigMaps, Secrets and volumes
  • ✓Probes, rolling updates and rollbacks
  • ✓Scaling and resource limits
  • ✓Debugging CrashLoopBackOff and networking

Kubernetes interview questions for freshers easy

1. Why use a .dockerignore file

What is the main purpose of a .dockerignore file?

  1. A.It lists base images that docker pull should never download from a registry.
  2. B.It tells the running container which network ports to block at runtime.
  3. C.It keeps files like .git, node_modules and .env out of the build context.
  4. D.It lists Dockerfile instructions that the builder should skip during the build, such as RUN apt-get.
Show answer

Answer: C. It keeps files like .git, node_modules and .env out of the build context.

When you run docker build, the whole build context is sent to the builder. A .dockerignore file keeps large or sensitive files out of that context, which makes builds faster, keeps caches stable and stops secrets like .env from being copied into images by a broad COPY . instruction.

2. CMD vs ENTRYPOINT

An image has ENTRYPOINT ["python", "app.py"] and CMD ["--port", "8000"]. You run `docker run myimg --port 9000`. What command runs inside the container?

  1. A.python app.py --port 8000 --port 9000
  2. B.--port 9000 (the entrypoint is replaced)
  3. C.python app.py (arguments are ignored)
  4. D.python app.py --port 9000
Show answer

Answer: D. python app.py --port 9000

Arguments given to docker run replace CMD, and the result is appended to ENTRYPOINT. ENTRYPOINT stays fixed unless you pass --entrypoint, so the container runs python app.py --port 9000. This is why CMD is used for default arguments and ENTRYPOINT for the fixed program.

3. What EXPOSE really does

A Dockerfile has `EXPOSE 8080`. You run the container with plain `docker run myimg` and cannot reach it on localhost:8080. Why?

  1. A.EXPOSE works only when the image is pushed to a registry
  2. B.EXPOSE only documents the port; you still need -p to publish it
  3. C.EXPOSE opens the port only for UDP traffic by default
  4. D.EXPOSE needs the container to run as root to bind
Show answer

Answer: B. EXPOSE only documents the port; you still need -p to publish it

EXPOSE is metadata that tells readers and tools which port the app listens on. It does not open anything on the host. To reach it from the host you publish it with -p 8080:8080 (or -P to publish all exposed ports to random host ports).

4. Reading a -p port mapping

You run `docker run -p 8081:80 nginx`. Which URL on your laptop reaches the nginx server?

  1. A.http://localhost:8081
  2. B.http://localhost:80
  3. C.http://localhost:8080
  4. D.http://localhost:8180
Show answer

Answer: A. http://localhost:8081

The format is -p HOST:CONTAINER. Port 8081 on the host is forwarded to port 80 inside the container, where nginx listens. So you browse to localhost:8081.

5. Reading a CronJob schedule

A CronJob has `schedule: "30 2 * * 1"` and no timeZone field. When does it run?

  1. A.At 02:30 on the first day of every month
  2. B.Every 30 minutes between 02:00 and 03:00 daily
  3. C.At 30 minutes past every hour on Mondays
  4. D.At 02:30 every Monday, in the controller's time zone
Show answer

Answer: D. At 02:30 every Monday, in the controller's time zone

Cron fields are minute, hour, day of month, month, day of week. "30 2 * * 1" means minute 30, hour 2, any day of month, any month, day of week 1 (Monday). Without spec.timeZone the time is taken from the kube-controller-manager, which is usually UTC, so set timeZone: "Asia/Kolkata" or "Asia/Dubai" if you mean local time.

6. Finding which node a Pod is on

You want to see the node and Pod IP for each Pod in a namespace in one command. Which do you run?

  1. A.kubectl get pods -o wide
  2. B.kubectl get pods --show-labels
  3. C.kubectl get nodes -o yaml
  4. D.kubectl top pods
Show answer

Answer: A. kubectl get pods -o wide

The -o wide output adds columns such as IP, NODE and NOMINATED NODE to the normal list. --show-labels only adds labels, and kubectl top shows CPU and memory use. This is a quick first step when you suspect one bad node.

7. Docker restart policy on a VM

You run a small service with plain Docker on a VM. You want it to start again after a crash or a VM reboot, but not if you stopped it on purpose. Which restart policy fits?

  1. A.--restart unless-stopped
  2. B.--restart no
  3. C.--restart on-failure:0
  4. D.--restart never
Show answer

Answer: A. --restart unless-stopped

unless-stopped restarts the container after crashes and when the Docker daemon starts, unless you stopped it by hand. always would also bring back a container you had deliberately stopped once the daemon restarts. no is the default and never restarts it.

8. Where cluster state lives

Where does Kubernetes keep the desired and current state of all objects such as Deployments and Secrets?

  1. A.In etcd, through the API server
  2. B.In a file on each worker node
  3. C.Inside the kube-scheduler memory
  4. D.In the container registry
Show answer

Answer: A. In etcd, through the API server

etcd is a consistent key-value store that holds all cluster objects. Only the API server talks to it directly; every other component reads and writes through the API. That is why etcd backups and encryption at rest matter so much.

9. Pushing an image to a registry

You built an image locally as myapp:1.4.0 and want to push it to registry.example.ae/team/myapp. What must you do before docker push?

  1. A.Rebuild it with the --push-only flag set to the registry
  2. B.Export it with docker save and upload the tar file by hand
  3. C.Tag it with the full registry path and the same version
  4. D.Rename the Dockerfile so it matches the registry name
Show answer

Answer: C. Tag it with the full registry path and the same version

docker push uses the registry host in the image name to know where to send it. docker tag myapp:1.4.0 registry.example.ae/team/myapp:1.4.0 adds that name, then docker push sends it after docker login. A name without a host goes to Docker Hub.

10. Docker image vs container

What is the relationship between a Docker image and a container?

  1. A.An image is a read-only template; a container is a running instance of it
  2. B.A container is a compressed archive of an image used for shipping it between registries
  3. C.Images run processes, while containers only store configuration files
  4. D.They are two names for exactly the same thing in Docker
Show answer

Answer: A. An image is a read-only template; a container is a running instance of it

An image is a layered, read-only package of a filesystem and metadata. When you run it, Docker adds a thin writable layer and starts a process, and that running instance is a container. You can start many containers from the same image.

11. Keeping CPU near a target

You want an Auto Scaling group to add or remove instances so average CPU stays near 50 percent. Which scaling setup fits?

  1. A.A target tracking scaling policy on average CPU
  2. B.A scheduled action that runs every hour
  3. C.Changing the desired capacity by hand when alerts fire
  4. D.Moving to a larger instance type
Show answer

Answer: A. A target tracking scaling policy on average CPU

Target tracking works like a thermostat: you set the target value and AWS creates the alarms and adjusts capacity. Scheduled actions suit known patterns, not unknown load. A bigger instance is vertical scaling and does not react to changing demand.

12. Containers vs virtual machines

Why do containers usually start faster and use less overhead than VMs?

  1. A.They run without any operating system underneath
  2. B.They share the host kernel rather than boot their own
  3. C.They always need bigger, dedicated hardware
  4. D.They skip storing application code on disk
Show answer

Answer: B. They share the host kernel rather than boot their own

A VM runs a full guest OS on a hypervisor. Containers package the app and its libraries but share the host kernel, so they start in seconds and pack densely. The trade-off is weaker isolation than full VMs.

13. Managed Kubernetes on each cloud

Which list gives the managed Kubernetes service on AWS, Azure and Google Cloud?

  1. A.EKS, AKS, GKE
  2. B.ECS, ACI, Cloud Run
  3. C.ECR, ACR, Artifact Registry
  4. D.EC2, Azure VMs, Compute Engine
Show answer

Answer: A. EKS, AKS, GKE

Amazon EKS, Azure Kubernetes Service and Google Kubernetes Engine run the Kubernetes control plane for you. ECS is AWS's own container orchestrator, and ECR, ACR and Artifact Registry store container images.

14. Where container images live

Your CI pipeline builds a Docker image. Where should it push the image so ECS or EKS can pull it?

  1. A.An EBS volume attached to the CI server
  2. B.A DynamoDB table holding image bytes
  3. C.A container registry such as Amazon ECR
  4. D.The application's CloudWatch log group
Show answer

Answer: C. A container registry such as Amazon ECR

Container registries store versioned images that orchestrators pull at deploy time. ECR, Azure Container Registry and Google Artifact Registry integrate with each cloud's IAM, image scanning and replication.

15. Traffic before the model has loaded

A model pod takes 60 seconds to load weights. Requests sent during that time fail. Which Kubernetes feature prevents this?

  1. A.A liveness probe that restarts the pod
  2. B.A larger CPU limit
  3. C.A ConfigMap
  4. D.A readiness probe that reports ready only after the model is loaded
Show answer

Answer: D. A readiness probe that reports ready only after the model is loaded

Kubernetes sends traffic only to pods whose readiness probe passes. If the probe checks that the model is loaded, new pods join the service only when they can answer. A liveness probe with too short a delay would instead keep restarting the slow-loading pod.

16. GPU nodes show zero GPUs

A new GPU node joins the cluster, but kubectl describe node shows no nvidia.com/gpu capacity. What is most likely missing?

  1. A.A larger memory limit on each pod
  2. B.The NVIDIA device plugin (GPU Operator)
  3. C.A faster container image registry
  4. D.A second network interface
Show answer

Answer: B. The NVIDIA device plugin (GPU Operator)

Kubernetes does not discover GPUs by itself. The NVIDIA device plugin (often deployed by the GPU Operator, along with drivers and the container toolkit) registers GPUs with the kubelet so they appear as allocatable resources.

17. Training pod keeps getting evicted

A Kubernetes training job is evicted when the node is busy. Its manifest sets no resource requests. What should be added?

  1. A.More replicas of the same training pod
  2. B.A higher log level for the container
  3. C.CPU, memory and GPU requests and limits
  4. D.A shorter image name for the training job
Show answer

Answer: C. CPU, memory and GPU requests and limits

Without requests, the scheduler cannot reserve capacity and the pod gets the lowest quality-of-service class, so it is evicted first. Setting requests (and GPU resources such as nvidia.com/gpu) gives predictable placement.

18. Running tests in Docker

Why do many teams run their UI test suite inside a Docker container in CI?

  1. A.Docker makes tests pass even when the app is broken
  2. B.Docker removes the need for assertions
  3. C.The container gives the same OS, browser versions and dependencies on every machine, so results are reproducible
  4. D.Docker is required by all test frameworks
Show answer

Answer: C. The container gives the same OS, browser versions and dependencies on every machine, so results are reproducible

Different browser or font versions between laptops and CI cause "works on my machine" failures. Official images such as the Playwright Docker image pin those versions, so local and CI runs behave the same.

19. Effect of resource leveling

A project manager applies resource leveling to remove over-allocation. What can happen to the finish date?

  1. A.It always moves earlier, because work is spread out
  2. B.It never changes, because leveling only uses float
  3. C.It is removed from the schedule until approved
  4. D.It can move later, because tasks are delayed until people are free
Show answer

Answer: D. It can move later, because tasks are delayed until people are free

Resource leveling shifts activities so no one is booked beyond capacity. If the only way to do that is to delay a critical activity, the project end date moves out. Resource smoothing, by contrast, stays within available float.

20. What a resource calendar shows

What does a resource calendar in a scheduling tool show?

  1. A.The cost of each resource per hour
  2. B.The dates on which invoices are paid
  3. C.The order in which tasks must happen
  4. D.When each person or item is available to work
Show answer

Answer: D. When each person or item is available to work

A resource calendar records working days, hours, leave and holidays for a person or piece of equipment. The tool uses it to schedule assigned tasks, so missing leave or public holidays, such as Eid or Diwali, gives wrong dates.

Kubernetes intermediate interview questions medium

21. Readiness vs liveness probes

A service takes 40 seconds to warm its cache at startup and sometimes cannot reach its database for a few seconds. Which probe setup is most correct?

  1. A.Use only a liveness probe that checks the database, so Pods restart when it is down.
  2. B.Use only a readiness probe; liveness probes are deprecated.
  3. C.Use a startup probe for the warm-up, a readiness probe that removes the Pod from Service endpoints when it cannot serve, and a light liveness probe that only checks the process is not stuck.
  4. D.Set initialDelaySeconds to 0 on all probes so problems are found faster.
Show answer

Answer: C. Use a startup probe for the warm-up, a readiness probe that removes the Pod from Service endpoints when it cannot serve, and a light liveness probe that only checks the process is not stuck.

A startup probe holds off the other probes until slow initialisation finishes. A failing readiness probe only stops traffic to the Pod, which is right for temporary dependency problems. Liveness failures restart the container, so a liveness probe that checks the database would cause restart storms during a database blip.

22. CPU vs memory limits

A container goes over its Kubernetes resource limits. What happens for CPU and for memory?

  1. A.Both cause the container to be restarted immediately.
  2. B.Going over the CPU limit causes throttling; going over the memory limit gets the container OOMKilled.
  3. C.Going over the CPU limit gets it OOMKilled; going over memory causes throttling.
  4. D.Nothing happens; limits are only used for scheduling.
Show answer

Answer: B. Going over the CPU limit causes throttling; going over the memory limit gets the container OOMKilled.

CPU is a compressible resource, so the kernel throttles the container through CFS quotas when it uses more than its limit. Memory is not compressible, so going over the limit makes the kernel OOM killer end the process, and Kubernetes reports OOMKilled. Requests, not limits, are what the scheduler uses for placement.

23. Pod rejected by the restricted profile

A namespace is labelled pod-security.kubernetes.io/enforce=restricted. A Pod that runs as root with default settings is rejected. Which settings are needed to pass?

  1. A.A higher PriorityClass and a memory limit on every container
  2. B.An image pulled by digest instead of by tag
  3. C.runAsNonRoot, no privilege escalation, drop ALL caps, RuntimeDefault seccomp
  4. D.A ServiceAccount with cluster-admin rights
Show answer

Answer: C. runAsNonRoot, no privilege escalation, drop ALL caps, RuntimeDefault seccomp

The restricted Pod Security Standard requires non-root users, allowPrivilegeEscalation: false, dropping all Linux capabilities (only NET_BIND_SERVICE may be added) and a RuntimeDefault or Localhost seccomp profile. It also bans host namespaces, hostPath and privileged mode. These are set in securityContext.

24. Linux capabilities for a web app

A non-root web server needs to bind to port 80 and nothing else special. What capability setting follows least privilege?

  1. A.Keep the default set and add SYS_ADMIN
  2. B.Drop ALL, then add only NET_BIND_SERVICE
  3. C.Run with privileged: true to avoid errors
  4. D.Add NET_ADMIN so it can manage sockets
Show answer

Answer: B. Drop ALL, then add only NET_BIND_SERVICE

Containers start with a default set of capabilities that most apps never use. Dropping all and adding back only NET_BIND_SERVICE lets the server bind to low ports with nothing extra. Another option is to listen on 8080 and map port 80 at the Service.

25. KMS encryption for Kubernetes Secrets

You enable KMS encryption at rest for Secrets on your cluster. How does envelope encryption work in this setup?

  1. A.KMS stores every Secret and etcd keeps only a link
  2. B.Each Secret is base64 encoded twice before saving
  3. C.A data key encrypts each Secret; KMS encrypts the data key
  4. D.The API server sends Secrets to KMS on every read
Show answer

Answer: C. A data key encrypts each Secret; KMS encrypts the data key

The API server encrypts Secret data with a data encryption key, and that key is itself encrypted by a key held in KMS, which never leaves it. A stolen etcd backup is then useless without KMS access. Revoking or rotating the KMS key gives central control.

26. Mounting secrets straight from a vault

You want Pods to read secrets from Azure Key Vault as files, without first creating Kubernetes Secret objects. Which component does this?

  1. A.A ConfigMap that points to the Key Vault URL
  2. B.The Secrets Store CSI Driver with the provider for Key Vault
  3. C.An init container that runs kubectl create secret
  4. D.A Helm chart value with the secret in plain text
Show answer

Answer: B. The Secrets Store CSI Driver with the provider for Key Vault

The Secrets Store CSI Driver mounts secrets from providers such as Azure Key Vault, AWS Secrets Manager, GCP Secret Manager or Vault as a volume when the Pod starts. Syncing into a Kubernetes Secret is optional, so the value need not sit in etcd. The Pod authenticates with workload identity.

27. Pods that never call the API

Most of your app Pods never talk to the Kubernetes API, but each has a ServiceAccount token mounted. What is the hardening step?

  1. A.Set automountServiceAccountToken: false for those Pods
  2. B.Give the default ServiceAccount cluster-admin rights
  3. C.Delete the kube-system namespace
  4. D.Mount the token as an env var instead
Show answer

Answer: A. Set automountServiceAccountToken: false for those Pods

By default a token for the Pod's ServiceAccount is mounted at /var/run/secrets/kubernetes.io/serviceaccount. If an attacker gets into the Pod, that token is a first step toward the API. Turning off automount where it is not needed removes it; give API-using Pods a dedicated, minimal ServiceAccount.

28. Modern ServiceAccount tokens

In current Kubernetes, how do the ServiceAccount tokens mounted into Pods differ from the old Secret-based tokens?

  1. A.They expire, are bound to the Pod, and get refreshed
  2. B.They never expire and are stored as Secret objects
  3. C.They are shared by all of the Pods on one node
  4. D.They contain the user's password in clear text form
Show answer

Answer: A. They expire, are bound to the Pod, and get refreshed

Projected tokens from the TokenRequest API expire (about an hour by default), name an audience, and become invalid when the Pod is deleted; the kubelet refreshes them. Since 1.24, long-lived token Secrets are no longer created automatically. A stolen token is therefore useful for much less time.

29. What init containers guarantee

A Pod has two init containers (wait-for-db, then run-migrations) and one app container. How do they run?

  1. A.Init containers run one by one to success, then the app starts
  2. B.All three start together and the app waits for a signal
  3. C.Init containers run after the app container exits
  4. D.Init containers rerun every time the readiness probe fails
Show answer

Answer: A. Init containers run one by one to success, then the app starts

Regular init containers run in order, each must exit 0 before the next starts, and the app containers start only after all of them finish. If one fails, the kubelet retries it according to the Pod restart policy. This makes them good for one-time setup steps.

30. Declaring a native sidecar

You want a log shipper sidecar that starts before the app, keeps running alongside it, and does not block a Job from completing. In current Kubernetes, how do you declare it?

  1. A.As a second entry in containers with a startup probe
  2. B.As an ephemeral container added by kubectl debug
  3. C.As an init container with restartPolicy: Always
  4. D.As an init container with a longer timeout
Show answer

Answer: C. As an init container with restartPolicy: Always

Native sidecars (stable since Kubernetes 1.33) are init containers with restartPolicy: Always. They start before the app containers, keep running, and are stopped after the main containers finish, so Jobs can complete. A plain second container would keep a Job Pod running forever.

31. Changed ConfigMap, old value in app

You edit a ConfigMap. The app reads one key as an environment variable and another from a mounted file (no subPath). A few minutes later, what has the running Pod seen?

  1. A.The file shows the new value; the env var keeps the old one
  2. B.Both show the new value right away
  3. C.Neither changes until the node reboots
  4. D.The env var changes; the file keeps the old one
Show answer

Answer: A. The file shows the new value; the env var keeps the old one

Environment variables are set once when the container starts and never change. Mounted ConfigMap files are refreshed by the kubelet after a short delay. To apply env changes, restart the Pods, for example with kubectl rollout restart.

32. Checking a ServiceAccount permission

A Pod logs "forbidden: User system:serviceaccount:jobs:runner cannot list pods". You add a Role and RoleBinding. How do you verify the permission without redeploying?

  1. A.kubectl get rolebinding -n jobs -o yaml --verify-access=runner
  2. B.kubectl auth can-i list pods -n jobs --as=system:serviceaccount:jobs:runner
  3. C.kubectl describe serviceaccount runner -n jobs --show-permissions
  4. D.kubectl auth whoami -n jobs --serviceaccount=system:serviceaccount:jobs:runner
Show answer

Answer: B. kubectl auth can-i list pods -n jobs --as=system:serviceaccount:jobs:runner

kubectl auth can-i asks the API server to evaluate RBAC for a verb and resource, and --as lets you impersonate the ServiceAccount (you need impersonation rights). It answers yes or no right away. kubectl auth whoami only shows your own identity.

33. Quota rejects Pods without requests

A namespace has a ResourceQuota on requests.cpu. Developers now get "must specify requests.cpu" when they deploy charts that set no resources. How can admins fix this without editing every chart?

  1. A.Raise the ResourceQuota to an unlimited value
  2. B.Add a PriorityClass to the namespace
  3. C.Add a LimitRange that sets default requests and limits
  4. D.Label the namespace to skip quota checks
Show answer

Answer: C. Add a LimitRange that sets default requests and limits

When a quota covers a resource, every Pod must declare it. A LimitRange can inject default requests and limits into containers that leave them out, so those Pods are admitted and counted. Teams should still set real values from measured use.

34. Deleting a PVC deleted the disk

Someone deleted a PVC by mistake and the cloud disk with the data was deleted too. The StorageClass used the default settings. What setting would have kept the disk?

  1. A.volumeBindingMode: Immediate on the StorageClass
  2. B.accessModes: ReadOnlyMany on the PVC
  3. C.reclaimPolicy: Retain on the StorageClass or PV
  4. D.allowVolumeExpansion: true on the StorageClass
Show answer

Answer: C. reclaimPolicy: Retain on the StorageClass or PV

Dynamically provisioned volumes get the StorageClass reclaimPolicy, which defaults to Delete, so removing the PVC removes the disk. With Retain, the PV and disk remain and can be bound again by hand. Use Retain for important data, plus real backups or snapshots.

35. Scanning container images

A team pushes images to ECR and deploys them straight to production. What should be added to catch known vulnerable packages?

  1. A.Running containers as root so they can patch themselves
  2. B.Using the latest tag so images are always the newest
  3. C.Image scanning in the registry and CI, blocking critical findings
  4. D.Encrypting the registry with a customer managed key
Show answer

Answer: C. Image scanning in the registry and CI, blocking critical findings

Scanning images (ECR enhanced scanning with Inspector, Trivy, Grype and similar tools) finds CVEs in OS and language packages, and a CI gate can stop critical ones from shipping. Images also need rebuilding when new CVEs appear. The latest tag is mutable and makes deployments unpredictable.

36. Kubernetes access in EKS

Every developer is mapped to the system:masters group in an EKS cluster so they can debug. What is a better approach?

  1. A.Use EKS access entries with namespace-scoped Kubernetes RBAC roles
  2. B.Share one kubeconfig file with cluster-admin for the whole team
  3. C.Give each developer AdministratorAccess in IAM instead
  4. D.Disable Kubernetes RBAC so permissions are simpler to manage
Show answer

Answer: A. Use EKS access entries with namespace-scoped Kubernetes RBAC roles

system:masters is full cluster admin and cannot be limited by RBAC. EKS access entries map IAM principals to Kubernetes groups or access policies scoped to namespaces, so developers can view pods and logs in their own namespace only. IAM admin does not equal least privilege inside the cluster.

37. Unknown containers on a build host

A build server shows containers you never started, running "alpine" with a mining command. netstat shows dockerd listening on 0.0.0.0:2375. What is the most likely entry point?

  1. A.A developer typed a wrong password into the SSH prompt
  2. B.The Alpine image is always infected with a miner by default
  3. C.Port 2375 is used by antivirus updates that run containers
  4. D.The Docker API was exposed with no TLS or authentication at all
Show answer

Answer: D. The Docker API was exposed with no TLS or authentication at all

Port 2375 is the unencrypted, unauthenticated Docker API. Exposing it is like giving root on the host to the internet, and scanners find it within minutes. Bind it to a local socket or use TLS with client certificates (2376) behind a firewall, then treat the host as compromised.

38. Pod killed while loading the model

A pod has a memory limit of 2Gi. While loading a 3 GB model it restarts and kubectl describe shows "OOMKilled". What happened?

  1. A.The CPU limit was too low
  2. B.The readiness probe failed
  3. C.The container exceeded its memory limit, so the kernel killed it
  4. D.The image was too large to pull
Show answer

Answer: C. The container exceeded its memory limit, so the kernel killed it

Memory is not compressible: when a container goes over its memory limit it is killed. CPU behaves differently and is only throttled when over its limit. Set the memory request and limit from measured peak usage during model load and inference, with some headroom.

39. Purpose of a multi-stage build

What is the main benefit of this Dockerfile pattern?

FROM python:3.12 AS build
COPY requirements.txt .
RUN pip wheel --wheel-dir /wheels -r requirements.txt

FROM python:3.12-slim
COPY --from=build /wheels /wheels
RUN pip install --no-index /wheels/*
COPY app/ /app
  1. A.The final image has no compilers or build caches, so it is smaller and has less attack surface
  2. B.It makes the model more accurate
  3. C.It lets the container use a GPU
  4. D.It removes the need for a requirements file
Show answer

Answer: A. The final image has no compilers or build caches, so it is smaller and has less attack surface

The first stage has the full toolchain to build wheels, and only the built wheels are copied into a slim runtime image. The final image is smaller, pulls faster when scaling out and contains fewer packages that could have vulnerabilities.

40. CPU pods filling GPU nodes

Ordinary CPU workloads keep landing on expensive GPU nodes, leaving no room for GPU jobs. What is the standard Kubernetes fix?

  1. A.Delete the CPU workloads
  2. B.Taint the GPU nodes and give only GPU workloads a matching toleration
  3. C.Give every pod a GPU request
  4. D.Run all workloads on one node pool
Show answer

Answer: B. Taint the GPU nodes and give only GPU workloads a matching toleration

A taint repels pods that do not tolerate it, so ordinary pods stay off GPU nodes. GPU workloads get the toleration plus a GPU resource request or node affinity so they land on the right nodes. Managed GPU node pools often apply such a taint by default.

Kubernetes interview questions for experienced candidates hard

41. Autoscaling during a dependency outage

Workers autoscale on queue depth. When a downstream API went down, every job failed and was requeued, so the queue grew and workers scaled from 10 to 200, hammering the API as it tried to recover. What fixes this?

  1. A.Scale on CPU instead, since it stays the same
  2. B.Raise the maximum to 500 workers
  3. C.Delete the queue when it passes 10,000 jobs
  4. D.Back off or pause on dependency errors and cap scale
Show answer

Answer: D. Back off or pause on dependency errors and cap scale

Queue depth rose because of failures, not new demand, so scaling added load to the broken dependency. Workers should back off (or trip a breaker and pause) on dependency errors, and autoscaling should have a sane maximum or factor in error rate. Scaling only helps when the bottleneck is the workers themselves.

42. Container ignores SIGTERM

Pods with this image always take the full 30-second grace period to stop and are then SIGKILLed, dropping requests. What is the most likely cause?

FROM python:3.12-slim
COPY app.py .
CMD python app.py
  1. A.Shell form CMD runs /bin/sh -c as PID 1, which does not forward SIGTERM to the Python process; use exec form CMD ["python", "app.py"] and handle SIGTERM in the app.
  2. B.The python:3.12-slim base image blocks all signals by default.
  3. C.terminationGracePeriodSeconds must be set to 0 for signals to be delivered.
  4. D.Kubernetes sends SIGINT, not SIGTERM, so Python ignores it.
Show answer

Answer: A. Shell form CMD runs /bin/sh -c as PID 1, which does not forward SIGTERM to the Python process; use exec form CMD ["python", "app.py"] and handle SIGTERM in the app.

With shell form, the shell becomes PID 1 and Python is its child. The shell usually does not pass SIGTERM on, and PID 1 has no default signal handlers, so nothing stops until the kubelet sends SIGKILL. Exec form makes Python PID 1 directly; the app should still handle SIGTERM, or you can use an init such as tini.

43. Rolling update that never finishes

A Deployment uses maxUnavailable: 0 and maxSurge: 1. The cluster has no spare capacity and no autoscaler. What happens during a rollout?

  1. A.Kubernetes deletes an old Pod first to make room, then starts the new one.
  2. B.The rollout finishes instantly because maxSurge is ignored when the cluster is full.
  3. C.Kubernetes evicts Pods from other Deployments to make space.
  4. D.The new surge Pod stays Pending, no old Pod is removed, and the rollout stalls until progressDeadlineSeconds marks it as failed.
Show answer

Answer: D. The new surge Pod stays Pending, no old Pod is removed, and the rollout stalls until progressDeadlineSeconds marks it as failed.

With maxUnavailable: 0, the controller must keep the full replica count available, so it can only remove an old Pod after a new one is Ready. With no room, the surge Pod cannot be scheduled, so nothing progresses. Without PriorityClasses that allow preemption, other workloads are not evicted. Fixes include adding capacity, an autoscaler, or allowing maxUnavailable: 1.

44. Errors during every rollout

Your app handles SIGTERM correctly and stops accepting connections right away. Still, clients see a few 502 errors at every rollout. What is the most likely cause and fix?

  1. A.The readiness probe period is too long; set it to 1 second and the errors disappear.
  2. B.Endpoint removal reaches load balancers and kube-proxy asynchronously, so traffic still arrives after SIGTERM; add a short preStop sleep (or delay shutdown) so the Pod keeps serving until routing is updated.
  3. C.Kubernetes sends SIGKILL before SIGTERM; increase terminationGracePeriodSeconds to 300.
  4. D.The Service must be type LoadBalancer for graceful shutdown to work.
Show answer

Answer: B. Endpoint removal reaches load balancers and kube-proxy asynchronously, so traffic still arrives after SIGTERM; add a short preStop sleep (or delay shutdown) so the Pod keeps serving until routing is updated.

When a Pod is deleted, the kubelet sends SIGTERM while, in parallel, the endpoint is removed and that change spreads to kube-proxy, ingress controllers and cloud load balancers. For a few seconds traffic can still arrive at a Pod that has already stopped listening. A preStop sleep of a few seconds, plus continuing to serve in-flight requests, closes this gap.

45. Docker cache on fresh runners

You moved to ephemeral CI runners, and Docker builds that took 2 minutes now take 12 because every layer is rebuilt. How do you keep layer caching?

  1. A.Use docker build --no-cache so builds stay consistent
  2. B.Turn the ephemeral runners back into long-lived ones
  3. C.Export the BuildKit cache to a registry with --cache-to and reuse it
  4. D.Squash the image into one layer before pushing
Show answer

Answer: C. Export the BuildKit cache to a registry with --cache-to and reuse it

Each fresh runner starts with an empty local cache. BuildKit can push cache to a registry or the CI cache service (--cache-to type=registry,ref=..., or type=gha) and load it with --cache-from on the next build. You keep clean runners and get fast builds back.

46. Trusted registries and digests only

You want production Pods to run only images from your registry, pinned by digest, so a tag cannot be repointed after review. What enforces this for every deploy?

  1. A.A Dockerfile lint rule that checks each FROM line
  2. B.An admission policy allowing only your registry and digests
  3. C.A firewall rule that blocks Docker Hub on office laptops
  4. D.A CI step that prints the image name before each deploy
Show answer

Answer: B. An admission policy allowing only your registry and digests

An admission policy (Kyverno, Gatekeeper or ValidatingAdmissionPolicy) can reject any Pod whose image is outside the approved registry or lacks an @sha256 digest; Kyverno can also resolve tags to digests. It applies to every path into the cluster. Lint rules and laptop firewalls cover only part of the path.

47. Pod create rights reveal Secrets

A developer has no get or list rights on Secrets in namespace payments, but can create Pods there. Why can they still read the payments DB password Secret?

  1. A.They can make a Pod that mounts the Secret and prints it
  2. B.Pods inherit cluster-admin rights by default
  3. C.Secrets are shown in kubectl get pods output
  4. D.The scheduler sends Secret values to the Pod creator
Show answer

Answer: A. They can make a Pod that mounts the Secret and prints it

RBAC checks the creator's right to create Pods, not to read the Secrets those Pods mount, so a Pod can mount any Secret in its namespace. Pod create rights in a namespace effectively include reading its Secrets. Separate sensitive workloads into their own namespaces and limit who can create workloads there.

48. Namespace stuck in Terminating

You deleted a namespace an hour ago and it still shows Terminating. Its status says some resources have finalizers remaining, and a CRD's operator was uninstalled before the namespace was deleted. What is happening?

  1. A.The namespace is waiting for its ResourceQuota to reset
  2. B.Kubernetes deletes namespaces only once per day
  3. C.The API server is still downloading the namespace backup
  4. D.Objects wait on finalizers that no controller is left to clear
Show answer

Answer: D. Objects wait on finalizers that no controller is left to clear

A finalizer tells Kubernetes to wait for a controller to finish cleanup before deleting an object. If the operator is gone, nothing removes the finalizer, so those objects and the namespace never finish. Reinstall the operator to clean up, or, knowing the risk of leaked external resources, remove the finalizers by hand.

49. Changing a Deployment selector

You change `spec.selector.matchLabels` from app: web to app: web-frontend in a Deployment and apply it. The API server rejects it with "field is immutable". What is the safe way forward?

  1. A.Patch the selector with kubectl edit, which skips the check
  2. B.Delete the ReplicaSets so the selector can be changed
  3. C.Add --force-conflicts to kubectl apply
  4. D.Create a new Deployment with the new selector, then remove the old one
Show answer

Answer: D. Create a new Deployment with the new selector, then remove the old one

In apps/v1 the Deployment selector cannot change, because it decides which ReplicaSets and Pods the Deployment owns. To move labels, create a new Deployment (and adjust the Service selector), let it become ready, then delete the old one. Deleting and recreating the same name works too but causes downtime.

50. Restart delay in CrashLoopBackOff

A container crashes right after starting. The kubelet restarts it with a growing delay. Under the default settings, what happens to the delay as the crashes continue?

  1. A.It stays fixed at 30 seconds between every restart
  2. B.It grows without limit until the Pod is deleted
  3. C.It doubles from about 10 seconds and is capped at 5 minutes
  4. D.It resets to zero each time the node runs low on memory
Show answer

Answer: C. It doubles from about 10 seconds and is capped at 5 minutes

The kubelet uses exponential back-off: about 10s, 20s, 40s and so on, up to a 5-minute cap. The back-off resets after a container runs successfully for 10 minutes. Long waits between attempts are normal, so check kubectl logs --previous rather than waiting for the next try.

51. ConfigMap file mounted with subPath

A ConfigMap key is mounted at /etc/nginx/conf.d/app.conf using subPath, so the other files in that folder stay. After you edit the ConfigMap, the file inside the running Pod never changes. Why?

  1. A.subPath mounts copy the file once and do not receive updates
  2. B.ConfigMaps mounted as files never update in any form
  3. C.nginx locks the file so the kubelet cannot replace it
  4. D.Edits apply only to ConfigMaps in the kube-system namespace
Show answer

Answer: A. subPath mounts copy the file once and do not receive updates

Normal ConfigMap volumes are updated by swapping a symlink in the mounted folder. A subPath mount binds one file directly, so it misses those swaps and stays at the old content until the Pod restarts. Mount the whole ConfigMap in its own folder, or roll the Pods on config changes.

52. Spotting a Guaranteed QoS Pod

Each Pod below has one container. Which Pod gets the Guaranteed QoS class?

  1. A.requests cpu 500m / memory 512Mi, limits cpu 1 / memory 512Mi
  2. B.limits cpu 500m and memory 512Mi, with no requests set
  3. C.requests and limits memory 512Mi, with no CPU values set
  4. D.no requests or limits, but a high PriorityClass
Show answer

Answer: B. limits cpu 500m and memory 512Mi, with no requests set

Guaranteed needs CPU and memory limits on every container with requests equal to limits. If you set only limits, Kubernetes copies them into requests, so that Pod qualifies. The second Pod has different CPU values and the third lacks CPU, so both are Burstable; the last is BestEffort, as priority does not affect QoS.

53. Where the next Pod can go

A Deployment uses topologySpreadConstraints on zone with maxSkew: 1 and whenUnsatisfiable: DoNotSchedule. Current matching Pods: zone-a 4, zone-b 2, zone-c 1. Which zone can take the next Pod?

  1. A.zone-b or zone-c
  2. B.Only zone-c
  3. C.Any of the three zones
  4. D.None of them, so it stays Pending
Show answer

Answer: B. Only zone-c

For each candidate zone the skew is (Pods there + 1) − (lowest count among zones). zone-c gives 2 − 1 = 1, which is allowed; zone-b gives 3 − 1 = 2 and zone-a gives 5 − 1 = 4, both above maxSkew. The constraint pushes new Pods toward the emptiest zone, even when the current spread is already uneven.

54. EKS pods cannot get IP addresses

On EKS with the default VPC CNI, new pods stay in ContainerCreating with "failed to assign an IP address to container". The node subnets are small /24s and nearly full. What is the best fix?

  1. A.Use larger node instance types so each node can host more pods
  2. B.Change every Service to type LoadBalancer so pods need no IPs
  3. C.Delete the CoreDNS pods to free up addresses in the subnets
  4. D.Add pod address space via a secondary CIDR or prefix delegation
Show answer

Answer: D. Add pod address space via a secondary CIDR or prefix delegation

The AWS VPC CNI gives every pod a real VPC IP from the node subnet, so small subnets run out fast. Adding a secondary CIDR (for example from 100.64.0.0/10) with custom networking, or enabling prefix delegation with enough free contiguous space, solves it. Bigger nodes allow more pods per node but use up subnet IPs even faster.

55. Slow pods at 30% CPU

Pods on a managed Kubernetes cluster show only 30% average CPU, but latency spikes. Metrics show heavy CFS throttling. What is the likely cause?

  1. A.Requests are too high, so pods cannot schedule
  2. B.The node pool uses the wrong region
  3. C.CPU limits are too low, so bursts are throttled
  4. D.Memory limits throttle the CPU
Show answer

Answer: C. CPU limits are too low, so bursts are throttled

CPU limits are enforced in short periods; a bursty app hits its limit within a period and is paused, even if average use is low. Raise or remove CPU limits while keeping sensible requests for scheduling.

56. Throttled but not busy

A multithreaded service in a Kubernetes pod with a CPU limit of 1 core shows only 40% average CPU usage, but p99 latency is high and the container_cpu_cfs_throttled_periods_total metric keeps rising. What is the most likely cause?

  1. A.The node is out of memory and swapping
  2. B.The readiness probe is failing
  3. C.The CPU request is too high, so the scheduler gives it less CPU
  4. D.The CFS quota is enforced per 100 ms period; bursts across many threads use up the quota early in the period and the container is paused until the next period
Show answer

Answer: D. The CFS quota is enforced per 100 ms period; bursts across many threads use up the quota early in the period and the container is paused until the next period

CPU limits are enforced with the CFS quota in short periods (100 ms by default). Many threads can burn the whole quota in a few milliseconds, then wait, which adds latency even though the average looks low. Fixes include raising or removing the limit, matching thread counts to the limit, or tuning the runtime.

57. Which pods are evicted first?

A node is under memory pressure and the kubelet starts evicting pods. All pods use more memory than they request except the Guaranteed ones. Which are evicted first?

  1. A.BestEffort pods with no requests or limits
  2. B.Guaranteed pods because they use the most memory
  3. C.The pods that were scheduled most recently
  4. D.Pods in the kube-system namespace
Show answer

Answer: A. BestEffort pods with no requests or limits

Under node pressure the kubelet ranks pods by whether usage exceeds requests, then by priority, then by usage relative to requests. BestEffort pods have no requests, so any usage exceeds them and they go first, followed by Burstable pods over their requests. Guaranteed pods within their limits are the last to be evicted.

58. Many DNS queries per lookup in pods

In a Kubernetes pod, resolv.conf has "options ndots:5" and three search domains. Calls to api.partner.com are slow, and DNS logs show several NXDOMAIN queries before the real one. Why?

  1. A.ndots:5 forces five retries for every query
  2. B.The pod sends each query to five different servers
  3. C.Names with under 5 dots try the search domains first
  4. D.ndots:5 turns off caching for external names
Show answer

Answer: C. Names with under 5 dots try the search domains first

With ndots:5, a name with fewer than five dots is treated as relative, so the resolver tries each search suffix before the name as given. A trailing dot (api.partner.com.) or a lower ndots in the pod dnsConfig avoids the extra lookups.

59. Old run cannot be rebuilt

You must reproduce a model trained 8 months ago. Its Dockerfile used "FROM python:3.10-slim", and that build of the base image is no longer the same. What should the team have done?

  1. A.Used the "latest" tag so it was always kept current
  2. B.Rebuilt the image weekly from the very same Dockerfile
  3. C.Kept only the Dockerfile in Git and never the image
  4. D.Pinned the base image digest and mirrored it internally
Show answer

Answer: D. Pinned the base image digest and mirrored it internally

Public tags move as new patches ship, and old builds can disappear. Pinning base images by digest, keeping copies in an internal registry and storing the final image with the run make old environments recoverable.

60. Pods killed during a load test

Under load, Java pods restart with reason OOMKilled. The container memory limit is 2 GiB, and the JVM is started with -Xmx2g. What is the problem?

  1. A.The JVM needs a larger CPU limit to use memory
  2. B.Heap plus off-heap memory exceeds the 2 GiB container limit
  3. C.OOMKilled means the database ran out of disk
  4. D.The load test sent too many cookies
Show answer

Answer: B. Heap plus off-heap memory exceeds the 2 GiB container limit

The JVM uses memory beyond the heap: metaspace, thread stacks, code cache and direct buffers. With -Xmx equal to the container limit, total usage goes over it and the kernel kills the container. Set heap to a share of the limit (for example with MaxRAMPercentage) and leave room for the rest.

Ready to test yourself?

Take a 15-question Kubernetes MCQ test with a score at the end, or practise the full Kubernetes question bank and earn points on the leaderboard.