Kubernetes Interview Questions and Answers
Beginner Level
Q: What is Kubernetes and why is it used?
A: Kubernetes is an open-source container orchestration platform used to automate the deployment, scaling, a
Q: What is a Pod in Kubernetes?
A: A Pod is the smallest deployable unit in Kubernetes, which can contain one or more containers.
Q: What is the difference between a Deployment and a StatefulSet?
A: A Deployment manages stateless applications, while a StatefulSet is used for stateful applications requiring
Q: How does a Service work in Kubernetes?
A: A Service provides a stable endpoint for accessing a set of Pods, enabling load balancing and service disco
Q: What is the role of kubelet and kube-proxy?
A: kubelet ensures containers are running in a Pod, while kube-proxy handles network routing to Pods.
Q: What is a Namespace and why is it useful?
A: A Namespace is a way to divide cluster resources between multiple users, providing isolation.
Q: How do you expose a Pod to external traffic?
A: You can expose a Pod using a Service of type NodePort, LoadBalancer, or Ingress.
Q: What is the difference between ConfigMap and Secret?
A: ConfigMap is used to store non-sensitive configuration data, while Secret is used to store sensitive informat
Q: What is a ReplicaSet?
A: A ReplicaSet ensures a specified number of Pod replicas are running at any given time.
Q: What is the purpose of a Node in Kubernetes?
A: A Node is a worker machine (VM or physical) where Pods run.
Intermediate Level
Q: How does Kubernetes handle rolling updates and rollbacks?
A: Kubernetes uses Deployments to perform rolling updates and rollbacks, ensuring minimal downtime.
Q: What is an Ingress and how does it differ from a Service?
A: An Ingress manages external access to services, typically HTTP, while a Service provides internal access w
Q: How does kube-proxy route traffic to Pods?
A: kube-proxy uses iptables or IPVS to route traffic to the correct Pod based on Service rules.
Q: What are taints and tolerations?
A: Taints prevent Pods from being scheduled on certain nodes, while tolerations allow Pods to be scheduled o
Q: How do you persist data in Kubernetes?
A: You can persist data using PersistentVolumes and PersistentVolumeClaims.
Q: What is the difference between Horizontal Pod Autoscaler and Cluster Autoscaler?
A: Horizontal Pod Autoscaler scales the number of Pods based on resource usage, while Cluster Autoscaler s
Q: How does Kubernetes perform service discovery?
A: Kubernetes uses DNS and environment variables to enable service discovery.
Q: What is a DaemonSet and when would you use it?
A: A DaemonSet ensures a copy of a Pod runs on all (or selected) nodes, useful for logging and monitoring.
Q: How do you troubleshoot a Pod stuck in `CrashLoopBackOff`?
A: Check the Pod logs, events, and resource limits to identify the issue.
Q: What are the different types of Services in Kubernetes?
A: ClusterIP (default), NodePort, LoadBalancer, and ExternalName.
Advanced Level
Q: How does Kubernetes networking work under the hood?
A: Kubernetes networking uses a flat network model where all Pods can communicate with each other, typicall
Q: Explain the control plane components in Kubernetes.
A: The control plane consists of etcd (key-value store), kube-apiserver (API server), kube-scheduler (schedule
Q: How does etcd work and what is its role in Kubernetes?
A: etcd is a distributed key-value store that provides a reliable way to store cluster state and configuration data
Q: What are the security best practices in Kubernetes?
A: Use RBAC, Network Policies, Secrets, Pod Security Policies, and regular security audits.
Q: How do Network Policies work in Kubernetes?
A: Network Policies define rules for how Pods can communicate with each other and external endpoints.
Q: What is the difference between init containers and sidecar containers?
A: Init containers run before the main container starts, while sidecar containers run alongside the main contain
Q: How do you manage secrets securely in Kubernetes?
A: Use Kubernetes Secrets, encrypt them at rest, and restrict access using RBAC.
Q: What is the role of the scheduler in Kubernetes?
A: The scheduler assigns Pods to nodes based on resource requirements and constraints.
Q: How do you debug networking issues in a Kubernetes cluster?
A: Use tools like kubectl, network plugins' diagnostics, and check kube-proxy and CNI configurations.
Q: What are Custom Resource Definitions (CRDs) and Operators?
A: CRDs allow you to define custom resources, and Operators automate the management of these resources.