Kubernetes Interview Master
The ultimate collection of 100+ meticulously curated Kubernetes & Container Orchestration questions to help you ace your DevOps interview.
What is Kubernetes?
BeginnerKubernetes (K8s) is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications.
Comprehensive Explanation
Why do we need Kubernetes?
BeginnerAs applications grew from single monoliths to microservices, managing thousands of containers manually became impossible. Kubernetes provides a framework to run...
Comprehensive Explanation
What are the main components of Kubernetes Architecture?
BeginnerKubernetes follows a client-server architecture. It has a control plane (Master Node) consisting of kube-apiserver, etcd, kube-scheduler, and kube-controller-ma...
Comprehensive Explanation
What is a Pod?
BeginnerA Pod is the smallest and simplest execution unit in Kubernetes. It encapsulates one or more containers, storage resources, a unique network IP, and options tha...
Comprehensive Explanation
What is a Node in Kubernetes?
BeginnerA Node is a worker machine in Kubernetes (previously known as a minion). It may be a VM or a physical machine, depending on the cluster. Each node contains the ...
Comprehensive Explanation
What is kubelet?
BeginnerThe kubelet is the primary 'node agent' that runs on each worker node. It registers the node with the apiserver and ensures that containers described in PodSpec...
Comprehensive Explanation
What is kube-proxy?
Beginnerkube-proxy is a network proxy that runs on each node in your cluster, implementing part of the Kubernetes Service concept. It maintains network rules on nodes, ...
Comprehensive Explanation
What is the role of kube-apiserver?
BeginnerThe API server is the front end for the Kubernetes control plane. It exposes the Kubernetes API, handles REST operations, and provides the frontend to the clust...
Comprehensive Explanation
What is etcd?
Beginneretcd is a consistent, highly-available key-value store used as Kubernetes' backing store for all cluster data. It holds the desired state and current state of t...
Comprehensive Explanation
What is kube-scheduler?
BeginnerThe scheduler watches for newly created Pods that have no Node assigned. For every unassigned Pod, the scheduler finds the best Node for that Pod to run on base...
Comprehensive Explanation
What is a ReplicaSet?
BeginnerA ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. It guarantees the availability of a specified number of identical ...
Comprehensive Explanation
What is a Deployment in Kubernetes?
BeginnerA Deployment provides declarative updates for Pods and ReplicaSets. You describe a desired state in a Deployment, and the Deployment Controller changes the actu...
Comprehensive Explanation
What is a Kubernetes Service?
BeginnerA Service is an abstract way to expose an application running on a set of Pods as a network service. It provides a stable IP address and DNS name to access the ...
Comprehensive Explanation
What are the different types of Kubernetes Services?
BeginnerThe main types are: ClusterIP (default, internal only), NodePort (exposes on each Node's IP at a static port), LoadBalancer (provisions a cloud provider's load ...
Comprehensive Explanation
What are Namespaces?
BeginnerNamespaces provide a mechanism for isolating groups of resources within a single cluster. They are intended for use in environments with many users spread acros...
Comprehensive Explanation
What is kubectl?
Beginnerkubectl is the command-line tool for interacting with the Kubernetes API server. It allows you to run commands against Kubernetes clusters to deploy apps, inspe...
Comprehensive Explanation
How do you view all pods in the default namespace?
BeginnerYou use the `kubectl get pods` command.
Comprehensive Explanation
Command / Code
kubectl get podsHow do you view pods across all namespaces?
BeginnerYou use the `--all-namespaces` or `-A` flag.
Comprehensive Explanation
Command / Code
kubectl get pods -AWhat is a Container Runtime?
BeginnerThe container runtime is the software that is responsible for running containers. Kubernetes supports several runtimes: containerd, CRI-O, and any implementatio...
Comprehensive Explanation
What is Minikube?
BeginnerMinikube is a tool that allows you to run a single-node Kubernetes cluster locally on your personal computer (including Windows, macOS, and Linux PCs) so that y...
Comprehensive Explanation
What is a DaemonSet?
BeginnerA DaemonSet ensures that a copy of a Pod runs on all (or some) Nodes in the cluster. As nodes are added to the cluster, Pods are added to them. It is typically ...
Comprehensive Explanation
What is a StatefulSet?
BeginnerStatefulSet is the workload API object used to manage stateful applications. It manages the deployment and scaling of a set of Pods, and provides guarantees abo...
Comprehensive Explanation
What are Labels and Selectors?
BeginnerLabels are key/value pairs attached to objects, such as pods, used to specify identifying attributes. Label Selectors are the core grouping primitive in Kuberne...
Comprehensive Explanation
What is a ConfigMap?
BeginnerA ConfigMap is an API object used to store non-confidential data in key-value pairs. Pods can consume ConfigMaps as environment variables, command-line argument...
Comprehensive Explanation
What is a Secret in Kubernetes?
BeginnerA Secret is an object that contains a small amount of sensitive data such as a password, a token, or a key. This allows you to manage sensitive information sepa...
Comprehensive Explanation
How does a Rolling Update work in deployments?
IntermediateA Rolling Update allows Deployments' update to take place with zero downtime by incrementally replacing Pods instances with new ones. The new Pods are scheduled...
Comprehensive Explanation
What is an Ingress in Kubernetes?
IntermediateIngress is an API object that manages external access to the services in a cluster, typically HTTP/HTTPS. It provides load balancing, SSL termination, and name-...
Comprehensive Explanation
What is an Ingress Controller?
IntermediateAn Ingress controller is responsible for fulfilling the Ingress, usually with a load balancer (like NGINX or HAProxy). Unlike other controllers that run as part...
Comprehensive Explanation
Explain Liveness and Readiness Probes.
IntermediateA Liveness probe checks if a container is running. If it fails, kubelet kills the container and it is subject to its restart policy. A Readiness probe checks if...
Comprehensive Explanation
What is a Job in Kubernetes?
IntermediateA Job creates one or more Pods and ensures that a specified number of them successfully terminate. It tracks successful completions. When a specified number of ...
Comprehensive Explanation
What is a CronJob?
IntermediateA CronJob creates Jobs on a repeating schedule. It is meant for performing regular scheduled actions such as backups, report generation, etc., similar to the `c...
Comprehensive Explanation
What is Role-Based Access Control (RBAC)?
IntermediateRBAC is a method of regulating access to computer or network resources based on the roles of individual users within an enterprise. In Kubernetes, it uses Role,...
Comprehensive Explanation
What is the difference between a Role and a ClusterRole?
IntermediateA Role always sets permissions within a particular namespace; when you create a Role, you have to specify the namespace it belongs in. A ClusterRole, by contras...
Comprehensive Explanation
What is a Persistent Volume (PV)?
IntermediateA PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically via Storage Classes. It is an abstract...
Comprehensive Explanation
What is a Persistent Volume Claim (PVC)?
IntermediateA PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a Pod (Pods consume node resources, PVCs consume PV resources). PVCs can requ...
Comprehensive Explanation
What are Storage Classes?
IntermediateA StorageClass provides a way for administrators to describe the "classes" of storage they offer. It enables dynamic provisioning of PersistentVolumes. When a P...
Comprehensive Explanation
What is Helm in the context of Kubernetes?
IntermediateHelm is a package manager for Kubernetes. Helm uses a packaging format called charts (a collection of files that describe a related set of Kubernetes resources)...
Comprehensive Explanation
Explain Horizontal Pod Autoscaler (HPA).
IntermediateHPA automatically updates a workload resource (like a Deployment or StatefulSet), aiming to automatically scale the workload to match demand based on observed C...
Comprehensive Explanation
What is the Cluster Autoscaler?
IntermediateThe Cluster Autoscaler automatically adjusts the size of the Kubernetes cluster (adding or removing nodes) when there are pods that failed to run due to insuffi...
Comprehensive Explanation
What is a Headless Service?
IntermediateA Headless Service is a service where `clusterIP` is set to `None`. It does not allocate an IP address or provide load balancing. Instead, it allows direct acce...
Comprehensive Explanation
What are Taints and Tolerations?
IntermediateTaints allow a node to repel a set of pods (node says "don't schedule here"). Tolerations are applied to pods, and allow them to schedule onto nodes with matchi...
Comprehensive Explanation
What is Node Affinity?
IntermediateNode affinity is a set of rules used by the scheduler to determine where a pod can be placed. It allows you to constrain which nodes your pod is eligible to be ...
Comprehensive Explanation
What is Pod Affinity/Anti-Affinity?
IntermediateThese allow you to constrain which nodes your pod is eligible to be scheduled on based on labels on *other pods* that are already running on the node, rather th...
Comprehensive Explanation
What is an Init Container?
IntermediateInit containers are specialized containers that run before app containers in a Pod. They can contain utilities or setup scripts not present in an app image. The...
Comprehensive Explanation
What is a Service Account?
IntermediateA Service Account provides an identity for processes that run in a Pod. When you access the cluster (e.g., using kubectl), you are authenticated by the apiserve...
Comprehensive Explanation
How does resource limits and requests work?
IntermediateRequests specify the minimum resources guaranteed for a container. The scheduler uses requests to find a node. Limits specify the maximum resources a container ...
Comprehensive Explanation
What is a Multi-container Pod?
IntermediateA Pod that houses multiple tightly coupled containers sharing resources (like network namespace and volumes). Common patterns include sidecar (e.g., logging age...
Comprehensive Explanation
What is the pause container in a Pod?
IntermediateIn Kubernetes, the pause container (sometimes called the infra container) serves as the 'parent container' for all containers in a Pod. Its primary roles are to...
Comprehensive Explanation
How do you rollback a Deployment?
IntermediateYou can use the `kubectl rollout undo` command to rollback a deployment to a previous revision/state.
Comprehensive Explanation
Command / Code
kubectl rollout undo deployment/my-deploymentWhat is Kubeadm?
Intermediatekubeadm is a tool built to provide `kubeadm init` and `kubeadm join` as best-practice "fast paths" for creating Kubernetes clusters. It performs the actions nec...
Comprehensive Explanation
What is the Control Plane failure impact?
AdvancedIf the control plane fails, you cannot deploy new Pods, scale applications, or change the cluster state. However, the existing Pods on worker nodes will continu...
Comprehensive Explanation
Explain the role of Mutating and Validating Admission Controllers.
AdvancedAdmission controllers intercept requests to the API server prior to persistence. Mutating controllers may modify the objects they admit (e.g., injecting sidecar...
Comprehensive Explanation
How does Kubernetes implement Service Discovery internally?
AdvancedKubernetes uses CoreDNS (by default). When a Service is created, a DNS record is created (e.g., `my-svc.my-namespace.svc.cluster.local`). Pods can resolve this ...
Comprehensive Explanation
What are Custom Resource Definitions (CRDs)?
AdvancedThe CRD API allows you to create custom resources. They are extensions of the Kubernetes API. Once you install a CRD in the cluster, the API server handles the ...
Comprehensive Explanation
What is the Kubernetes Operator Pattern?
AdvancedOperators are software extensions to Kubernetes that make use of custom resources (CRDs) to manage applications and their components. They encapsulate human ope...
Comprehensive Explanation
Explain Network Policies.
AdvancedBy default, pods are non-isolated (they accept traffic from any source). NetworkPolicies allow you to specify how a pod is allowed to communicate with various n...
Comprehensive Explanation
What is priority and preemption in Kubernetes?
AdvancedPod Priority enables you to indicate the importance of a Pod relative to other Pods via PriorityClasses. Preemption is the mechanism where the scheduler evicts ...
Comprehensive Explanation
What happens during a graceful pod termination?
Advanced1. The pod state is set to Terminating. 2. PreStop hook (if defined) executes. 3. SIGTERM is sent to the main process in each container. 4. Simultaneously, the ...
Comprehensive Explanation
What is a PodDisruptionBudget (PDB)?
AdvancedA PDB limits the number of Pods of a replicated application that are down simultaneously from voluntary disruptions (like node draining during upgrades). It ens...
Comprehensive Explanation
How do you achieve zero downtime during Node upgrades?
AdvancedYou cordon the node (marking it unschedulable). Then you drain the node (`kubectl drain`), which safely evicts all pods (respecting PDBs). High-availability dep...
Comprehensive Explanation
What is the Container Network Interface (CNI)?
AdvancedCNI is a Cloud Native Computing Foundation project containing specifications and libraries for writing plugins to configure network interfaces in Linux containe...
Comprehensive Explanation
What is the Container Storage Interface (CSI)?
AdvancedCSI is a standard for exposing arbitrary block and file storage storage systems to containerized workloads on Kubernetes. It moves storage volume plugins out of...
Comprehensive Explanation
What is etcd backup and why is it critical?
Advancedetcd holds the entire cluster state. If etcd is lost without a backup, the cluster is irrecoverable. Backing up etcd requires using `etcdctl snapshot save`. It ...
Comprehensive Explanation
Explain how Service Mesh integrates with Kubernetes.
AdvancedA service mesh (like Istio or Linkerd) is a dedicated infrastructure layer for handling service-to-service communication. It intercepts traffic (usually by inje...
Comprehensive Explanation
What is a StatefulSet's VolumeClaimTemplate?
AdvancedUnlike Deployments which share exactly the same PVCs among replicas, StatefulSets feature a `volumeClaimTemplates` field. It dynamically provisions a unique PV/...
Comprehensive Explanation
What is OOMKilled and why does it happen?
AdvancedOOMKilled stands for Out Of Memory Killed. It happens when a container tries to consume more memory than its assigned `limits.memory` in the Pod spec, causing t...
Comprehensive Explanation
What is a LimitRange?
AdvancedA LimitRange is a policy to constrain resource allocations (to Pods or Containers) in a namespace. It is used to enforce minimum/maximum resource usage per cont...
Comprehensive Explanation
What is a ResourceQuota?
AdvancedWhile LimitRange applies constraints to individual Pods/Containers, a ResourceQuota provides constraints that limit aggregate resource consumption per Namespace...
Comprehensive Explanation
How does iptables relate to kube-proxy?
AdvancedIn the default `iptables` proxy mode, kube-proxy watches the control plane for Service and Endpoint objects. It then creates iptables rules on the host node to ...
Comprehensive Explanation
What are Ephemeral Containers?
AdvancedEphemeral containers are a special type of container that runs temporarily in an existing Pod to accomplish user-initiated actions such as troubleshooting or de...
Comprehensive Explanation
Explain the `ImagePullPolicy`.
AdvancedIt determines when kubelet should attempt to pull the image: `Always` (pull every time, forces registry check), `IfNotPresent` (pull only if not cached locally)...
Comprehensive Explanation
What are EndpointSlices?
AdvancedEndpointSlices provide a more scalable and extensible alternative to Endpoints. In large clusters, a single Endpoints object containing thousands of IPs becomes...
Comprehensive Explanation
How does Kubernetes handle certificates?
AdvancedKubernetes uses PKI (Public Key Infrastructure) internally. Components authenticate to the API server using x509 certificates. The cluster has a CA (Certificate...
Comprehensive Explanation
What is Server-Side Apply?
AdvancedServer-Side Apply moves the responsibility of merging and conflict resolution of object configuration from the `kubectl` client to the Kubernetes API server its...
Comprehensive Explanation
What is the Downward API?
AdvancedThe Downward API allows containers to consume information about themselves or the cluster without coupling to the Kubernetes API. You can expose details like th...
Comprehensive Explanation
How do you forcefully delete a Pod that is stuck in Terminating status?
ScenarioYou use the `--force` and `--grace-period=0` flags.
Comprehensive Explanation
Command / Code
kubectl delete pod <pod-name> --grace-period=0 --forceHow do you check the resource usage (CPU/Memory) of Pods?
ScenarioYou use the `kubectl top` command (requires metrics-server to be installed).
Comprehensive Explanation
Command / Code
kubectl top podsHow do you check the logs of a specific container in a multi-container pod?
ScenarioUse `kubectl logs` and specify the container name using the `-c` flag.
Comprehensive Explanation
Command / Code
kubectl logs <pod-name> -c <container-name>You deployed an app, but the pods are in 'CrashLoopBackOff'. How do you troubleshoot?
Scenario1. Check the logs (`kubectl logs pod-name`). 2. Look at previous container logs (`kubectl logs pod-name --previous`). 3. Describe the pod to see events (`kubect...
Comprehensive Explanation
How do you quickly create a pod for testing without writing YAML?
ScenarioUse the imperative `kubectl run` command.
Comprehensive Explanation
Command / Code
kubectl run test-pod --image=nginx --restart=NeverHow do you execute a shell inside a running pod?
ScenarioUse `kubectl exec` with the interactive (`-it`) flags.
Comprehensive Explanation
Command / Code
kubectl exec -it <pod-name> -- /bin/bashHow do you forward a local port to a port on a pod for debugging?
ScenarioUse `kubectl port-forward` to map a local port to the pod port.
Comprehensive Explanation
Command / Code
kubectl port-forward pod/<pod-name> 8080:80How do you generate a YAML template for a deployment without actually creating it?
ScenarioUse the `--dry-run=client` and `-o yaml` flags.
Comprehensive Explanation
Command / Code
kubectl create deploy web --image=nginx --dry-run=client -o yaml > deployment.yamlHow do you scale a deployment imperatively to 5 replicas?
ScenarioUse the `kubectl scale` command.
Comprehensive Explanation
Command / Code
kubectl scale deployment/web --replicas=5Your pod is 'Pending'. What is the most likely cause?
ScenarioA 'Pending' pod usually means the scheduler cannot find a suitable node to place the pod. Common causes are lack of CPU/Memory resources on nodes, untolerated t...
Comprehensive Explanation
How do you update the image of a deployment imperatively?
ScenarioUse the `kubectl set image` command.
Comprehensive Explanation
Command / Code
kubectl set image deployment/web nginx=nginx:1.19How do you watch resources in real-time?
ScenarioUse the `-w` or `--watch` flag with the get command.
Comprehensive Explanation
Command / Code
kubectl get pods -wHow do you extract a secret's base64 decoded value?
ScenarioGet the secret in JSON/YAML, extract the base64 string, and pipe it to `base64 -d`. Or use go-templates directly.
Comprehensive Explanation
Command / Code
kubectl get secret my-secret -o jsonpath='{.data.password}' | base64 --decodeHow do you drain a node for maintenance?
ScenarioUse `kubectl drain`. You may need to ignore daemonsets.
Comprehensive Explanation
Command / Code
kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-dataHow do you mark a node as schedulable again?
ScenarioUse the `kubectl uncordon` command.
Comprehensive Explanation
Command / Code
kubectl uncordon <node-name>How do you temporarily pause a deployment's rollout?
ScenarioUse the `kubectl rollout pause` command. Subsequent updates to the deployment will not trigger a rollout until resumed.
Comprehensive Explanation
Command / Code
kubectl rollout pause deployment/webHow do you query the CPU and memory requests of all pods on a specific node?
ScenarioDescribe the node. The output includes an 'Allocated resources' section which lists requests and limits for the node.
Comprehensive Explanation
Command / Code
kubectl describe node <node-name>How do you copy a file from your local machine to a pod?
ScenarioUse the `kubectl cp` command.
Comprehensive Explanation
Command / Code
kubectl cp ./localfile.cfg <pod-name>:/path/in/container/A deployment fails to rollout and gets stuck. How do you check the rollout status?
ScenarioUse the `kubectl rollout status` command.
Comprehensive Explanation
Command / Code
kubectl rollout status deployment/webHow do you apply a directory containing multiple YAML files?
ScenarioUse `kubectl apply` pointing to the directory.
Comprehensive Explanation
Command / Code
kubectl apply -f ./my-manifests/How do you find which pod is using the most memory?
ScenarioUse `kubectl top pods` and sort by memory.
Comprehensive Explanation
Command / Code
kubectl top pods --sort-by=memoryHow do you modify an existing resource interactively in your editor?
ScenarioUse the `kubectl edit` command. It opens the resource manifest in your default terminal editor (like vi).
Comprehensive Explanation
Command / Code
kubectl edit deployment/webYou lost access to your cluster. Where can you find your Kubeconfig file?
ScenarioThe standard kubelet configuration file (kubeconfig) is located at `~/.kube/config`. If you are using Cloud providers, you fetch it via their CLI (e.g., `aws ek...
Comprehensive Explanation
How to see the history of a deployment's revisions?
ScenarioUse the `kubectl rollout history` command.
Comprehensive Explanation
Command / Code
kubectl rollout history deployment/webHow do you list all pods that have a specific label, e.g., 'app=nginx'?
ScenarioUse the `-l` selector flag.
Comprehensive Explanation
Command / Code
kubectl get pods -l app=nginx