Top 50 Kubernetes Interview Question and Answers
-
What is Kubernetes?
Kubernetes is an open-source container orchestration platform designed to automate the deployment, scaling, and management of containerized applications. -
What is a Kubernetes Pod?
A pod is the smallest deployable unit in Kubernetes, typically containing one or more containers with shared storage and network resources. -
What are the main components of Kubernetes architecture?
- Master Node (API Server, Controller Manager, Scheduler, etcd)
- Worker Nodes (Kubelet, Kube-Proxy, Container Runtime)
-
What is etcd in Kubernetes?
etcd
is a distributed key-value store that stores the cluster state and configuration data, enabling Kubernetes to maintain cluster consistency. -
What is the role of a Kubelet?
The Kubelet is an agent on each node that ensures containers are running as expected and manages pod operations. -
Explain the Kubernetes API Server.
The API server is the frontend for the Kubernetes control plane, handling REST requests to manage and retrieve the state of resources. -
What is a Namespace in Kubernetes?
A namespace is a virtual cluster within Kubernetes, used to divide cluster resources between multiple users or teams. -
How does Kubernetes handle networking?
Kubernetes uses networking models such as CNI plugins (like Calico, Flannel) to provide a flat network for communication between pods. -
What is a Service in Kubernetes?
A Service is an abstract way to expose an application running in a set of pods as a network service, providing stable access. -
What is a ReplicaSet?
A ReplicaSet ensures a specified number of pod replicas are running at all times, aiding in load balancing and availability. -
What is a StatefulSet?
StatefulSet manages stateful applications, where each pod has a unique identifier and stable, persistent storage. -
Explain DaemonSet in Kubernetes.
A DaemonSet ensures that a copy of a pod runs on all or specific nodes, commonly used for logging and monitoring. -
What is a Persistent Volume (PV)?
PV is a storage resource in a cluster, allowing pods to store data beyond their lifecycle. -
What is a Persistent Volume Claim (PVC)?
PVC is a request for storage by a user, which binds to a PV to meet the claim’s specified storage needs. -
How does Horizontal Pod Autoscaling work?
Horizontal Pod Autoscaler adjusts the number of pod replicas based on CPU/memory metrics, improving resource utilization. -
What is Ingress in Kubernetes?
Ingress is an API object that manages external access to services, typically HTTP/HTTPS, providing routing rules. -
Explain ConfigMap in Kubernetes.
ConfigMap allows external configuration of application settings without rebuilding images. -
What is Secret in Kubernetes?
A Secret is an object that stores sensitive information, like passwords, in a secure and base64-encoded format. -
What are Labels in Kubernetes?
Labels are key-value pairs attached to objects like pods, used for organizing and selecting subsets of objects. -
Explain Taints and Tolerations.
Taints and tolerations work together to control which pods can run on specific nodes. -
What is Helm?
Helm is a package manager for Kubernetes, used to manage, install, and update applications as charts. -
Explain Node Affinity.
Node affinity allows scheduling constraints on which pods can run on specific nodes based on labels. -
What is a Custom Resource Definition (CRD)?
CRD allows users to define custom resources that extend the Kubernetes API. -
What is the role of the Scheduler?
The Scheduler assigns pods to nodes based on resource requirements, policies, and constraints. -
How does Kubernetes handle high availability?
By replicating critical components, like etcd and the API server, across multiple nodes. -
What is Kubectl?
kubectl
is a command-line tool to interact with Kubernetes clusters for managing resources. -
What is Minikube?
Minikube is a tool that enables running Kubernetes clusters locally on a single node. -
Explain RBAC in Kubernetes.
Role-Based Access Control (RBAC) restricts access to Kubernetes resources based on roles and role bindings. -
What is the purpose of a ServiceAccount?
A ServiceAccount provides an identity for pods to interact with the Kubernetes API securely. -
What is the difference between a Deployment and a StatefulSet?
Deployment manages stateless applications, while StatefulSet manages stateful applications, ensuring pod identity and persistent storage. -
How to troubleshoot a pod in Kubernetes?
Usekubectl logs
,kubectl describe pod
, andkubectl get events
to diagnose issues. -
What is Pod Disruption Budget (PDB)?
PDB specifies the minimum number of pods that must be up, preventing disruptions below a certain threshold. -
How does Kubernetes handle secrets?
Secrets are stored in base64 format and can be mounted as volumes or environment variables. -
What is a Kubernetes Operator?
Operators are applications that extend Kubernetes, encapsulating complex operational knowledge for managing resources. -
How does Kubernetes handle scaling?
Kubernetes scales applications horizontally using the Horizontal Pod Autoscaler and node scaling via Cluster Autoscaler. -
What are Init Containers?
Init containers run before application containers to perform setup tasks like configuration or dependency checks. -
Explain the role of Cluster Autoscaler.
The Cluster Autoscaler adds or removes nodes based on the scheduling requirements of pending pods. -
How can you create a Kubernetes cluster?
Use tools likekubeadm
,kops
, or cloud providers (EKS, GKE, AKS) to create a Kubernetes cluster. -
What is the function of Kube-Proxy?
Kube-Proxy handles network rules on nodes, managing traffic routing for services within the cluster. -
How to restrict network communication in Kubernetes?
Network Policies control communication between pods, allowing restrictions based on labels and namespaces. -
How do you secure a Kubernetes cluster?
Implement RBAC, limit API access, use network policies, secure etcd, and regularly update components.
-
What is a Sidecar Container?
A sidecar container runs alongside the main container to assist with tasks like logging, monitoring, or proxying. -
What is a Headless Service?
A Headless Service provides direct access to individual pod IPs without load balancing, enabling stateful applications. -
What is the purpose of Kubernetes Audit Logs?
Audit logs record actions taken by users or other components in the Kubernetes API server. -
How does Kubernetes handle multi-tenancy?
By using namespaces, RBAC, and network policies, Kubernetes isolates resources between tenants. -
Explain Blue-Green Deployment in Kubernetes.
In Blue-Green Deployment, two environments run simultaneously, allowing one to be live while the other is updated. -
How does Kubernetes support canary deployments?
By gradually shifting traffic to new versions using multiple services, Ingress, or tools like Istio. -
What is an Admission Controller in Kubernetes?
Admission controllers are plugins that validate and modify requests before they reach the API server. -
How to back up etcd in Kubernetes?
Useetcdctl
commands to create backups and store them securely, essential for cluster recovery. -
What is K8s Federation?
Kubernetes Federation manages multiple clusters, enabling workloads to be distributed across clusters for high availability and disaster recovery.