Ace Your Kubernetes Interview
Preparing for a Kubernetes-focused position? This guide covers common interview questions, advanced topics, and system design scenarios. Master these concepts to demonstrate your expertise and land your dream role.
Beginner Level Questions
Foundational concepts every engineer should know
What is Kubernetes and why is it important?
Answer: Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It's important because it enables automatic deployment and scaling across clusters, improves resource utilization, provides self-healing, and enables declarative configuration management for production environments.
Explain the difference between Pods and Containers
Answer: A Container is the smallest deployable unit (Docker/OCI image instance). A Pod is the smallest deployable unit in Kubernetes that can contain one or more containers. Pods share networking (same IP, port space) and storage. Containers are stateless and ephemeral; Pods provide an abstraction layer for container management.
What is a Deployment in Kubernetes?
Answer: A Deployment is a Kubernetes object that manages a set of replicated Pods. It ensures the specified number of Pod replicas are running at all times. Deployments support scaling, rolling updates, and rollbacks. They are managed by the controller-manager and use ReplicaSets as an intermediary layer.
Intermediate Level Questions
For experienced Kubernetes engineers
How does RBAC work in Kubernetes?
Answer: RBAC (Role-Based Access Control) uses four main objects: ServiceAccount (identity), Role/ClusterRole (permissions), RoleBinding/ClusterRoleBinding (grants roles to subjects). When a user/service account makes an API request, the API server checks if they have permission via RoleBinding. Permissions are additive only (no explicit deny except NetworkPolicies).
Explain the Pod lifecycle in Kubernetes
Answer: Pod lifecycle: Pending → Running → Succeeded/Failed. Detailed: Pending (scheduling/image pull), Running (at least one container), Succeeded (all containers exited 0), Failed (at least one container non-zero exit), Unknown (communication lost). Each stage has hooks: init containers, post-start hooks, pre-stop hooks for graceful shutdown.
What are Init Containers and when would you use them?
Answer: Init containers run before the main application container and must complete successfully. Use cases: wait for dependencies (databases), download configuration, setup application, check prerequisites. They ensure the environment is ready before the app starts. They can have different images and are useful for decoupling setup from runtime concerns.
Advanced & System Design Questions
For senior engineers and architects
Design a highly available e-commerce platform on Kubernetes
Answer:
Architecture: Multi-AZ/region deployment with service mesh for traffic management.
Components: API Gateway → Microservices (stateless) → Database (managed/HA) → Cache (Redis cluster) → Message queue (Kafka/RabbitMQ)
K8s specific: StatefulSets for databases, Deployments for services, HPA for scaling, pod disruption budgets, multi-zone node distribution, strong RBAC
Monitoring: Prometheus + Grafana, centralized logging, distributed tracing, alerting on SLOs
How would you troubleshoot a Pod stuck in CrashLoopBackOff?
Answer:
1. Check logs: kubectl logs pod-name --previous
2. Describe pod: kubectl describe pod pod-name (check events)
3. Check readiness/liveness probes (too strict?)
4. Verify resource requests/limits
5. Check environment variables and secrets
6. Verify image and tag are correct and accessible
7. Check init containers for errors
Explain how Network Policies work and their limitations
Answer: NetworkPolicies control pod-to-pod and pod-to-external traffic using labels and selectors. They are namespace-scoped and work on layers 3-4 (IP/port). Limitations: CNI plugin must support them, no DNS-based policies, not suitable for DDoS prevention, no rate limiting. For advanced control, use service mesh (Istio/Linkerd).
Interview Tips & Strategies
How to ace the interview