Skip to content
Cloud Computing

Kubernetes Interview Questions and Answers: Scenarios

Prepare for Kubernetes interviews with practical scenarios covering Pending Pods, CrashLoopBackOff, Services, rollouts, RBAC and AKS. Learn how to gather evidence, make targeted changes and verify recovery safely.

Updated 21 min read 9 views
Kubernetes Interview Questions and Answers: Scenarios

Kubernetes Interview Questions and Answers

Kubernetes interviews often test more than definitions. Experienced candidates should explain how they diagnose failures, protect workloads and make changes safely. A strong answer describes the symptoms, the evidence you would collect, the likely causes and a low-risk fix.

Each concept becomes easier to explain when you tie it to an operational decision. Start with what the system should do. Then use events and workload status to find what is happening. Finally, explain how you would verify a fix without disrupting healthy workloads.

What setup do you need before practising these scenarios?

You need a working cluster and a current kubectl. Every answer in this article is verified with commands, so practise the commands rather than relying on memory. The examples target Kubernetes 1.29 or later, with a kubectl within one minor version of the cluster. The AKS section uses AKS 1.29. The commands rely on the discovery.k8s.io/v1 EndpointSlice API, which is stable from Kubernetes 1.21.

Install or upgrade the client, then confirm that you are connected to the cluster you intended:

kubectl version --client
kubectl config current-context
kubectl cluster-info
kubectl get nodes -o wide

Expected output looks like this:

Client Version: v1.29.7
Kustomize Version: v5.0.4
Kubernetes control plane is running at https://YOUR_SERVER_IP:443
NAME                                STATUS   ROLES    AGE   VERSION
aks-nodepool1-12345678-vmss000000   Ready    <none>   12d   v1.29.7

Create a practice namespace and the sample workload. Caution: the examples use a namespace called production to look realistic. Run them only in a test cluster or in a namespace you own. Never run the deliberate-failure exercises in a real production namespace.

kubectl create namespace production

Save this manifest as manifests/web-demo.yaml. It includes requests, limits and all three probes, so the later sections have real settings to inspect:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-demo
  namespace: production
  labels:
    app.kubernetes.io/name: web-demo
spec:
  replicas: 2
  revisionHistoryLimit: 5
  progressDeadlineSeconds: 600
  minReadySeconds: 10
  selector:
    matchLabels:
      app.kubernetes.io/name: web-demo
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app.kubernetes.io/name: web-demo
    spec:
      containers:
        - name: web
          image: nginx:1.27-alpine
          ports:
            - name: http
              containerPort: 80
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              memory: 256Mi
          startupProbe:
            httpGet:
              path: /
              port: http
            failureThreshold: 30
            periodSeconds: 2
          readinessProbe:
            httpGet:
              path: /
              port: http
            periodSeconds: 5
          livenessProbe:
            httpGet:
              path: /
              port: http
            periodSeconds: 10
            failureThreshold: 3
---
apiVersion: v1
kind: Service
metadata:
  name: web-demo
  namespace: production
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: web-demo
  ports:
    - name: http
      port: 80
      targetPort: http
      protocol: TCP

The targetPort: http value refers to the named container port. If you change the container port number, the Service keeps working as long as the name stays the same. The manifest sets no CPU limit on purpose. CPU limits cause CFS throttling, and the scheduler uses requests, not limits, to place Pods.

Apply the manifest, then confirm that the workload is healthy and the Service has backends:

kubectl apply -f manifests/web-demo.yaml
kubectl rollout status deployment/web-demo -n production --timeout=120s
kubectl get pods -n production -l app.kubernetes.io/name=web-demo -o wide
kubectl get endpointslices -n production -l kubernetes.io/service-name=web-demo -o wide

Expected output shows two Ready Pods and one EndpointSlice with two ready addresses:

deployment "web-demo" successfully rolled out
NAME                        READY   STATUS    RESTARTS   AGE   IP           NODE
web-demo-6b7c9f8d4b-2xj7p   1/1     Running   0          42s   10.244.1.7   aks-nodepool1-12345678-vmss000000
web-demo-6b7c9f8d4b-q9w4n   1/1     Running   0          42s   10.244.2.4   aks-nodepool1-12345678-vmss000001
NAME                 ADDRESSTYPE   PORTS   ENDPOINTS                   AGE
web-demo-abc12       IPv4          80      10.244.1.7,10.244.2.4       45s

If the EndpointSlice shows <unset> under ENDPOINTS, stop and fix readiness before you continue. Every later section assumes this baseline works. When you finish, delete only what you created:

kubectl delete -f manifests/web-demo.yaml

How should you structure Kubernetes interview questions and answers for scenarios?

A scenario answer should follow a repeatable sequence: clarify the impact, inspect the relevant resources, identify evidence, apply the smallest safe change and verify recovery. This approach shows disciplined troubleshooting. It also keeps you from guessing at a root cause before you check the cluster.

Kubernetes is an open-source system for deploying and managing containerised applications across a cluster. A Pod is the smallest deployable unit in Kubernetes. It can contain one or more containers that share network and storage resources. The Kubernetes architecture overview explains how the control plane and worker nodes coordinate those workloads.

Use this structure in an interview:

  1. Clarify the symptom: Is the problem affecting one Pod, one service, a namespace or the whole cluster?
  2. Gather evidence: Check status, events, logs and recent changes before you propose a fix.
  3. State likely causes: Link each possible cause to the evidence that would confirm or rule it out.
  4. Make a safe change: Prefer a targeted, reversible action over a broad restart or deletion.
  5. Verify and prevent recurrence: Confirm the workload is healthy, then explain which monitoring or configuration change would help.

Steps 1 and 2 use a command set you should be able to recite, because it applies to almost every symptom:

kubectl get pods -n production -o wide
kubectl get events -n production --sort-by=.lastTimestamp | tail -n 30
kubectl describe pod <pod-name> -n production
kubectl logs <pod-name> -n production --tail=100
kubectl rollout history deployment/<deployment-name> -n production

kubectl describe prints an Events: block and the container states. It is usually faster than reading raw YAML. kubectl get events --sort-by=.lastTimestamp shows a cluster-wide timeline of the most recent changes. If the namespace is noisy, narrow the events to one object:

kubectl get events -n production --field-selector involvedObject.name=<pod-name>

Which Kubernetes basics should you explain before tackling a scenario?

Scenario questions often test whether you understand the controller or resource involved. Explain what each resource is for and how it relates to the behaviour you observe.

Interview question Strong short answer
What is a Deployment? A Deployment manages stateless application Pods and supports controlled updates and rollbacks.
What is a ReplicaSet? A ReplicaSet maintains a specified number of matching Pods; a Deployment normally manages ReplicaSets for an application.
What is a Service? A Service provides a stable network endpoint for a set of Pods selected by labels.
What is a namespace? A namespace separates namespaced Kubernetes resources within a cluster; it is not, by itself, a strong security boundary.
What is a StatefulSet? A StatefulSet manages applications that need stable Pod identities or ordered deployment and scaling.

These definitions are starting points, not complete answers. A Service can exist and still receive no traffic. This happens when its selector does not match the Pod labels, or when the selected Pods are not ready. The Kubernetes Services documentation explains how selectors and endpoints work.

State one distinction explicitly. A controller is a reconciliation loop. It compares the desired state (the spec) with the observed state (the status). A resource is the stored object. This is why kubectl apply rarely fails right away when a workload is broken. It records your intent. The controller reports problems later through status conditions and events.

What do you do when a Pod stays Pending?

A Pending Pod has not reached the Running phase, but the status alone does not tell you why. Check the Pod's events and scheduling details before you change its resource requests or move workloads.

kubectl get pods -n production
kubectl describe pod <pod-name> -n production
kubectl get nodes
kubectl get nodes -o wide
kubectl describe node <node-name> | sed -n '/Allocated resources/,/Events/p'
kubectl get pvc -n production
kubectl get storageclass

The describe output can reveal scheduling constraints, insufficient requested CPU or memory, an unbound PersistentVolumeClaim, or a taint the Pod does not tolerate. The scheduler checks a node's available capacity against requests, not against current usage. Read about resource requests and limits and taints and tolerations in the Kubernetes documentation.

The Events: section at the bottom of kubectl describe pod often gives the reason in one line:

Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  18s   default-scheduler  0/3 nodes are available: 1 Insufficient memory,
                                                        2 node(s) had untolerated taint {workload: batch}.

The node's Allocated resources block shows requests as a percentage of allocatable capacity. Allocatable is lower than total capacity because kubelet-reserved and system-reserved resources are subtracted:

Allocated resources:
  Resource           Requests      Limits
  --------           --------      ------
  cpu                1850m (48%)   400m (10%)
  memory             2458Mi (35%)  1024Mi (14%)

To run a Pod on a tainted node, add a matching toleration:

spec:
  template:
    spec:
      tolerations:
        - key: workload
          operator: Equal
          value: batch
          effect: NoSchedule

A good answer links each finding to a targeted fix. For example, if requests exceed the capacity on eligible nodes, check whether the requests match what the application actually needs. If they do, the cluster needs more capacity. Do not lower requests just to get the Pod scheduled. Check the application's real needs first.

Caution

adding a taint with kubectl taint nodes <node-name> workload=batch:NoSchedule can make existing Pods unschedulable. Lowering requests can overcommit a node and cause it to evict Pods. Verify the fix with:

kubectl get pod <pod-name> -n production -w

A healthy transition goes from Pending to ContainerCreating to Running, with READY 1/1.

How do you troubleshoot CrashLoopBackOff or OOMKilled?

CrashLoopBackOff means Kubernetes keeps restarting a container that exits, and it adds a growing delay between attempts. The term describes the restart pattern. It does not name the cause. OOMKilled means the container was terminated after it exceeded its memory limit. Investigate usage and configuration first. Do not assume every restart is an application bug.

kubectl describe pod <pod-name> -n production
kubectl logs <pod-name> -n production --previous
kubectl logs <pod-name> -n production --previous -c <container-name>
kubectl get pod <pod-name> -n production -o jsonpath='{.status.containerStatuses[*].lastState.terminated}'
kubectl top pod <pod-name> -n production --containers

The --previous flag shows logs from the last terminated container. You must target the correct container in a multi-container Pod. If the container has never finished a run, the command fails with previous terminated container "<container-name>" in pod "<pod-name>" not found. The jsonpath query below prints the termination record that Kubernetes stores:

{"containerID":"containerd://...","exitCode":137,"finishedAt":"...","reason":"OOMKilled","startedAt":"..."}

Read the exit code before you form a theory:

Exit code Meaning Common cause
0 Process exited cleanly Entrypoint is a one-shot command; wrong workload type or restartPolicy
1 Application error Bad config, missing env var, failed dependency connection
137 SIGKILL (128 + 9) OOMKilled memory limit, or a failed liveness probe
143 SIGTERM (128 + 15) Probe-triggered restart, eviction or a normal delete

Check the previous container's logs, the termination reason, the events, the probe configuration and any recent application changes. For OOMKilled, compare the configured memory request and limit with observed usage. Then look for a leak, an unexpected traffic spike or a limit that is set too low. Raising the limit may restore service. Do it only after you have evidence, and pair it with monitoring.

kubectl top needs metrics-server. On a cluster without it, the command fails with error: Metrics API not available. Install metrics-server, then confirm that kubectl get apiservice v1beta1.metrics.k8s.io reports Available: True.

If the restarts are not OOMKilled, check three things. Does the process exit on its own? Does it fail to load its configuration? Is a liveness probe restarting a healthy but slow application? A readiness probe controls whether a Pod receives Service traffic. A liveness probe can restart a container. A startup probe gives a slow-starting application more time before the liveness and readiness checks begin. The Kubernetes probe guidance covers the details.

The startup budget equals failureThreshold × periodSeconds. In the sample manifest, that is 30 × 2 = 60 seconds before the liveness probe can kill the container. Check for probe-triggered restarts directly:

kubectl get events -n production --sort-by=.lastTimestamp | grep -iE 'unhealthy|backoff|oom'
kubectl get pods -n production --field-selector=status.phase=Failed

Caution

raising a memory limit without checking the node's allocatable memory can push the node into MemoryPressure. That can evict unrelated Pods. Before and after the change, run kubectl describe node <node-name> | sed -n '/Allocated resources/,/Events/p' to confirm the node has room.

Why does a Kubernetes Service receive no traffic?

A Service with no working backends usually has a selector that does not match the Pod labels, or Pods that are not ready. Check the Service, its selector and its EndpointSlices before you change any network rules.

kubectl get service <service-name> -n production -o yaml
kubectl get endpointslices -n production -l kubernetes.io/service-name=<service-name> -o wide
kubectl get pods -n production --show-labels
kubectl get pods -n production -l app.kubernetes.io/name=web-demo \
  -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}'

Compare the Service selector with the labels on the Pods you expect it to select. If the selector matches, check Pod readiness, the target port and whether the application listens on the expected interface and port. If the EndpointSlices list ready backends but clients still cannot connect, investigate DNS, NetworkPolicy rules, ingress configuration or the network path from the client.

An empty EndpointSlice query is the key clue. It means Kubernetes selected no Pods. When backends exist, the slice lists them under endpoints[].addresses with conditions.ready: true. Unready addresses appear only when publishNotReadyAddresses: true is set.

Test connectivity from inside the cluster by resolving the Service DNS name:

kubectl run netcheck --rm -it --restart=Never --image=nicolaka/netshoot -n production -- \
  curl -sS -m 5 -o /dev/null -w '%{http_code}\n' http://web-demo.production.svc.cluster.local

A 200 response means the path works. Could not resolve host points to DNS. A timeout points to a NetworkPolicy or the wrong port. Connection refused means the port is reachable but nothing is listening, which usually indicates a targetPort mismatch. You can also bypass the Service and test a Pod directly:

kubectl port-forward svc/web-demo 8080:80 -n production
curl -I http://127.0.0.1:8080

Breaking the Service on purpose is a quick way to learn this. In the practice namespace only, change the selector to a value that matches nothing. Watch the EndpointSlice empty out, then revert the change:

kubectl patch svc web-demo -n production -p '{"spec":{"selector":{"app.kubernetes.io/name":"wrong"}}}'
kubectl get endpointslices -n production -l kubernetes.io/service-name=web-demo
kubectl patch svc web-demo -n production -p '{"spec":{"selector":{"app.kubernetes.io/name":"web-demo"}}}'

Caution

if you expose the Service through an Ingress or a LoadBalancer, you publish the workload to the internet. Before you expose anything, confirm authentication, TLS and NetworkPolicy:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-demo
  namespace: production
spec:
  ingressClassName: nginx
  rules:
    - host: your_domain
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web-demo
                port:
                  number: 80

This answer shows a useful boundary. First establish whether Kubernetes has selected healthy backends. Then investigate connectivity beyond the Service. Do not assume that restarting Pods will fix a selector or port mismatch.

How do you handle a failed Deployment rollout?

Investigate a failed rollout through the Deployment conditions, the ReplicaSet status, the Pod events and the application logs. Roll back only after you confirm the new revision caused the problem and that reverting is safer than fixing forward.

kubectl rollout status deployment/<deployment-name> -n production --timeout=120s
kubectl get deployment <deployment-name> -n production -o wide
kubectl describe deployment <deployment-name> -n production
kubectl get replicasets -n production
kubectl rollout history deployment/<deployment-name> -n production
kubectl annotate deployment/<deployment-name> -n production \
  kubernetes.io/change-cause="image nginx:1.27-alpine, ticket OPS-1234"

A stalled rollout reports a deadline error. kubectl describe shows the condition that blocks it:

error: deployment "web-demo" exceeded its progress deadline
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    False   ProgressDeadlineExceeded

Check whether the new Pods fail to become ready, cannot be scheduled or keep terminating. Also review the image reference, recent configuration changes and the probe settings. Kubernetes supports pausing, resuming and undoing Deployment rollouts. The Deployment rollout documentation lists the available controls.

The --record flag is deprecated. Record the reason for a change with the kubernetes.io/change-cause annotation, as shown above. That annotation makes kubectl rollout history readable. To halt a rollout in progress instead of guessing, run:

kubectl rollout pause deployment/<deployment-name> -n production
kubectl rollout resume deployment/<deployment-name> -n production

To roll back to the previous revision, or to a specific one, run:

kubectl rollout undo deployment/<deployment-name> -n production
kubectl rollout undo deployment/<deployment-name> -n production --to-revision=3
kubectl rollout status deployment/<deployment-name> -n production --timeout=120s

Caution

rollout undo restores only the previous Pod template. It does not revert a ConfigMap or Secret that you edited in place under the same name. It also does not reverse database migrations. Deleting the Deployment to "reset" it destroys the revision history you need. Roll back instead.

A strong answer includes safeguards. Confirm that the previous revision still works. Check whether a database or API change is backward-compatible. Monitor the service after the rollback. Rolling back the application image does not undo data changes.

Verify recovery with the same evidence you used to diagnose the problem:

kubectl get pods -n production -l app.kubernetes.io/name=web-demo -o wide
kubectl get endpointslices -n production -l kubernetes.io/service-name=web-demo

Both replicas should show Running and 1/1. The EndpointSlice should list two ready addresses.

How do you approach access and security questions?

Grant Kubernetes access on the principle of least privilege. Give each person or workload only the permissions the task requires. Role-Based Access Control (RBAC) is the Kubernetes mechanism for granting permissions to users and service accounts through roles and bindings.

If an engineer cannot list Pods, check the identity and authorization path before you grant broad cluster-admin access:

kubectl auth can-i list pods -n production --as=<user>
kubectl auth can-i --list -n production --as=system:serviceaccount:production:web-sa
kubectl get role,rolebinding -n production
kubectl get clusterrole,clusterrolebinding
kubectl describe rolebinding <rolebinding-name> -n production

kubectl auth can-i prints yes or no. Add --list to print the effective rules for the impersonated identity. This is the fastest way to show that a binding is wrong. Caution: --as requires the impersonate verb on users, groups or serviceaccounts. Audit impersonation rights carefully and do not hand them out casually.

A namespaced Role grants permissions within one namespace. A ClusterRole defines permissions at cluster scope, or you can reuse it inside a single namespace through a RoleBinding. Before you change access, verify the binding's subject, namespace and verbs. The Kubernetes RBAC documentation describes how these resources relate.

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: pod-reader
  namespace: production
rules:
  - apiGroups: [""]
    resources: ["pods", "pods/log"]
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: pod-reader-binding
  namespace: production
subjects:
  - kind: User
    name: <user>
    apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io

The roleRef field is immutable. To point a binding at a different Role, delete the binding and create it again. Expect a brief authorization gap while you do.

In a production security interview, also cover secrets handling, image provenance, network boundaries and auditability. Name the specific control you would apply and explain how you would confirm it works. Avoid saying only that you would "secure the cluster."

  • Secrets are base64-encoded, not encrypted, unless encryption at rest is configured. Restrict get and list on secrets with RBAC, then verify with kubectl auth can-i get secrets -n production --as=<user>.
  • A default-deny NetworkPolicy blocks all traffic until you add matching allow rules. Apply it in a staging namespace first, and test it with the netcheck command above.
  • On AKS, use Workload Identity and the Secrets Store CSI driver instead of static credentials. Enable both with az aks update --name your_cluster_name --resource-group your_resource_group --enable-oidc-issuer --enable-workload-identity.

What changes in Azure Kubernetes Service interview scenarios?

Azure Kubernetes Service (AKS) is Microsoft Azure's managed Kubernetes service. An AKS scenario still requires Kubernetes troubleshooting. You also need to separate cluster-level symptoms from issues in Azure-managed infrastructure, identity, networking or integrations.

Start with the same evidence: Pod events, node status, workload health and recent changes. Then check the AKS configuration and the Azure dependencies. These include node-pool capacity, identity permissions, network setup and access to a container registry. The official AKS overview describes the service and its managed components.

kubectl config current-context
az aks show --resource-group your_resource_group --name your_cluster_name \
  --query "{k8sVersion:currentKubernetesVersion,nodePools:agentPoolProfiles[].{name:name,count:count,vmSize:vmSize,mode:mode}}" -o json
az aks nodepool list --cluster-name your_cluster_name --resource-group your_resource_group -o table
az aks check-acr --name your_cluster_name --resource-group your_resource_group --acr your_registry.azurecr.io
kubectl get nodes -o wide
kubectl get events -A --sort-by=.lastTimestamp | tail -n 20

az aks show returns the control-plane version that your kubectl version must be compatible with. The node-pool table shows whether a pool is scaled to zero. A zero-node pool is a common reason Pods stay Pending on AKS even when the manifest is correct. az aks check-acr tests whether the kubelet identity can pull from the registry. This separates an ImagePullBackOff caused by a missing AcrPull role from one caused by a bad image tag.

AKS nodes do not allow direct SSH by default. For node-level investigation, run a privileged debug Pod instead. Caution: this mounts the host filesystem and runs privileged. Limit it to a single node, and delete it when you finish:

kubectl debug node/<node-name> -it --image=mcr.microsoft.com/azurelinux/base/core:3.0

For questions about "AKS Kubernetes interview questions and answers," do not assume a provider-specific issue has the same fix as on a self-managed cluster. First say what you would check in Kubernetes. Then name the Azure resource or setting you would inspect next. This distinction also helps with Docker and Kubernetes interview questions and answers. Docker builds and runs containers. Kubernetes orchestrates containerised workloads across a cluster. The two tools solve related but different problems.

If credentials are stale or you are pointing at the wrong cluster, refresh the context. Caution: --overwrite-existing replaces the existing kubeconfig entry for that cluster name:

az aks get-credentials --resource-group your_resource_group --name your_cluster_name --overwrite-existing
kubectl get nodes

How can experienced candidates prepare scenario-based answers?

Practise explaining your decisions. Do not memorise long lists of definitions. The most useful preparation pairs common failure modes with a clear account of the evidence, the trade-offs and the verification steps.

Scenario Evidence to mention Safe response to describe
Pods cannot schedule Pod events, requests, node capacity, taints and affinity Address the constraint or capacity issue, then verify scheduling.
Container keeps restarting Previous logs, termination reason, probes and resource limits Fix the confirmed cause and monitor restarts and readiness.
Service has no backends Selector, Pod labels, readiness and EndpointSlices Correct the mismatch or readiness issue, then test connectivity.
Rollout is unhealthy Deployment conditions, ReplicaSets, events and revision history Roll back or fix forward based on impact and compatibility.

If you are preparing from a Kubernetes interview questions and answers PDF, turn this table into a one-page revision sheet. Keep the reasoning next to each command. For a wider operational interview framework, read DevOps interview questions with practical scenarios and 10 strong Kubernetes interview answers.

Troubleshooting

These are the errors candidates most often hit while rehearsing the commands above. Each entry gives the likely cause and the fix.

error: You must be logged in to the server (Unauthorized) means your token has expired, your credentials were revoked or you are using the wrong context. Refresh your credentials and confirm the context before you change anything:

kubectl config get-contexts
az aks get-credentials --resource-group your_resource_group --name your_cluster_name --overwrite-existing
kubectl auth can-i list pods -n production

Error from server (Forbidden): pods is forbidden: User "..." cannot list resource "pods" in API group "" in the namespace "production" is an RBAC error. Identify the missing verb, then add the narrowest rule that works:

kubectl auth can-i list pods -n production --as=<user>
kubectl describe rolebinding <rolebinding-name> -n production

error: the server doesn't have a resource type "endpointslices" means the cluster predates EndpointSlice v1, or your RBAC blocks API discovery. Confirm which one applies, then use the fallback:

kubectl api-resources | grep -i endpointslice
kubectl get endpoints <service-name> -n production

ErrImagePull or ImagePullBackOff with Failed to pull image ... 401 Unauthorized points to missing private registry credentials. On AKS, check that the kubelet identity has the AcrPull role. Elsewhere, attach an imagePullSecret to the Pod's serviceAccountName:

kubectl describe pod <pod-name> -n production | sed -n '/Events:/,$p'
az aks check-acr --name your_cluster_name --resource-group your_resource_group --acr your_registry.azurecr.io

0/3 nodes are available: 3 Insufficient cpu means the requests exceed the allocatable CPU on every candidate node. Compare the requests with the node's allocated resources before you edit the manifest:

kubectl describe node <node-name> | sed -n '/Allocated resources/,/Events/p'
kubectl get pods -A -o jsonpath='{range .items[*]}{.spec.nodeName}{"\t"}{.spec.containers[*].resources.requests.cpu}{"\n"}{end}' | sort

error: unable to forward port because pod is not running. Current status=Pending means port-forward needs a Running Pod, or a Service with ready endpoints. Fix scheduling or readiness first.

error: Metrics API not available means metrics-server is missing or unhealthy:

kubectl get apiservice v1beta1.metrics.k8s.io
kubectl get pods -n kube-system -l k8s-app=metrics-server

Error from server (NotFound): namespaces "production" not found means the namespace does not exist. Create it, or target one that does:

kubectl get namespaces
kubectl create namespace production

DNS failures inside a Pod, such as dial tcp: lookup web-demo.production.svc.cluster.local on 10.0.0.10:53: no such host, mean the lookup failed. Confirm that CoreDNS is healthy, then retest from a debug Pod in the same namespace:

kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl run netcheck --rm -it --restart=Never --image=nicolaka/netshoot -n production -- dig +short web-demo.production.svc.cluster.local

Key takeaways

  • A Kubernetes scenario answer moves from impact and evidence to a targeted fix, then to verification.
  • A Pending Pod, a restarting container and a Service with no traffic are different symptoms. Each needs different checks.
  • Events, resource status and logs give you better evidence than guessing from a status label.
  • Explain the safety considerations, the conditions for a rollback and how you will confirm recovery.
  • AKS adds Azure-specific infrastructure and identity checks, but the Kubernetes fundamentals still apply.

Kubernetes interviews reward clear, evidence-based reasoning. Ritik Barnwal's practical hosting guides can help developers and sysadmins build the operational foundations behind those answers.

Frequently asked questions

What Kubernetes version should I use to practise interview questions?

Use Kubernetes 1.29 or later, with a kubectl client within one minor version of the cluster. The examples use AKS 1.29, and the discovery.k8s.io/v1 EndpointSlice API has been stable since Kubernetes 1.21. Confirm the active context with kubectl config current-context, and practise deliberate failures in a test namespace, not production.

Why is my Kubernetes pod stuck in Pending?

A Pending Pod has not reached the Running phase. Run kubectl describe pod -n production and inspect the Events section for scheduling clues such as insufficient requested CPU or memory, an unbound PersistentVolumeClaim, or an untolerated taint. The scheduler evaluates requests against eligible nodes; check those constraints before changing resource requests.

What does CrashLoopBackOff mean and how do I fix it?

CrashLoopBackOff is a restart pattern in which Kubernetes repeatedly restarts a container, with a growing delay between attempts; it does not identify the cause. Run kubectl logs -n production --previous and inspect the termination reason, events and probes. For OOMKilled, compare observed memory use with the configured request and limit.

Why is my Kubernetes service not getting traffic?

A Kubernetes Service usually has no working backends because its selector does not match Pod labels or the selected Pods are not ready. Check kubectl get endpointslices -n production -l kubernetes.io/service-name= -o wide, then compare the Service selector with Pod labels and readiness. If ready backends exist, investigate the target port and network path.

How do I safely roll back a failed Kubernetes deployment?

Roll back when evidence shows the new revision caused the failure and reverting is safer than fixing forward. Run kubectl rollout undo deployment/ -n production, then verify with kubectl rollout status deployment/ -n production --timeout=120s. A rollback restores the previous Pod template; it does not revert in-place ConfigMap or Secret edits or database migrations.

Comments

Loading comments…

Leave a comment

All articles