K8s Interview Questions

Kubernetes interviews often begin with architecture because it sets the foundation for many later questions. Candidates who explain the system clearly at each layer tend to sound more confident and practical.

Architecture and Core Components

Kubernetes follows a layered design. The two primary layers are the control plane and the worker nodes.

The control plane acts as the cluster’s decision-making layer. It does not always run application workloads directly, but it manages the state and coordinates the cluster.

Key components include:

  • API Server: The unified entry point for all components and users.
  • etcd: Distributed key-value store that holds cluster state.
  • Scheduler: Assigns pods to suitable nodes.
  • Controller Manager: Runs controllers that reconcile desired and actual state.

Worker nodes are where containers actually run. They typically contain:

  • Kubelet: Node agent that manages pod lifecycle.
  • Kube-proxy: Network proxy for service forwarding and load balancing.
  • Container Runtime: Such as containerd or CRI-O.

A common interview question is how high availability is achieved. Strong answers mention multi-node control planes and the distributed nature of etcd.

Declarative Management and Core Objects

Kubernetes is declarative. Users describe the desired state in YAML, and controllers work to make the cluster match that state.

Core objects include:

  1. Pod: The smallest deployable unit, often containing one or more containers.
  2. Deployment: The most common workload resource for stateless applications, handling replicas and rolling updates.
  3. Service: Provides a stable network endpoint and load balancing for pods.
  4. ConfigMap and Secret: Separate configuration and sensitive data from container images.

The comparison between Deployment and StatefulSet is a frequent interview topic. Deployment is preferred for stateless workloads, while StatefulSet is designed for stateful applications that need stable identity and storage.

Networking and Service Discovery

Kubernetes networking often follows a model where each pod has its own IP address. Services provide stable access to pods.

Service types include:

  • ClusterIP: Internal only.
  • NodePort: Exposes a port on each node.
  • LoadBalancer: Integrates with cloud load balancing.
  • ExternalName: Maps to an external DNS name.

Ingress is used for HTTP and HTTPS traffic. It often works with an Ingress Controller like Nginx and supports host and path based routing. CoreDNS plays a key role in service discovery.

Storage and Persistence

Containers are temporary, so data must be persisted. Kubernetes uses PersistentVolume and PersistentVolumeClaim.

  • PersistentVolume: Cluster level storage, manually created or dynamically provisioned.
  • PersistentVolumeClaim: User request for storage.

Interviewers may ask about local, network, and cloud storage. Understanding AccessModes and StorageClass is important.

Scheduling and Resource Management

The scheduler considers resource requests and limits. Candidates should explain:

  • Requests: Resources reserved for scheduling.
  • Limits: Maximum resources a container can use.

Affinity and anti-affinity are advanced topics. Anti-affinity can spread replicas across nodes. Taints and Tolerations control pod placement.

Observability and Troubleshooting

Production environments require monitoring and logging. Prometheus is common, often paired with Grafana. Logs may be collected through Fluentd or Fluent Bit.

Common troubleshooting scenarios include:

  1. Pod Pending: Check resources and scheduling constraints.
  2. CrashLoopBackOff: Inspect logs and startup failures.
  3. Service inaccessible: Check endpoints and NetworkPolicy.

Useful kubectl commands include describe, logs, exec, and get events.

Security and Best Practices

Kubernetes security relies on RBAC. Understand ServiceAccount, Role, ClusterRole, and RoleBinding.

Best practices include:

  • Set resource requests and limits.
  • Use liveness and readiness probes.
  • Follow least privilege.
  • Backup etcd regularly.

A strong interview answer connects architecture, workloads, networking, storage, and operations. That holistic understanding helps candidates stand out.