Interview Q&A / Docker & Kubernetes

INTERVIEW Q&A · 67 QUESTIONS

Docker & Kubernetes interview questions

Images, containers, Dockerfiles, pods and deployments, from first principles.

  1. What is the difference between a Pod, a Deployment and a Service in Kubernetes?

    A Pod is the smallest unit Kubernetes runs, one or more containers sharing an IP address. A Deployment keeps a chosen number of identical Pods running and handles rolling updates. A Service gives those changing Pods one stable name and IP and load-balances traffic across them.

    IntermediateIn-depth4 min read
  2. What is the difference between liveness, readiness and startup probes in Kubernetes?

    A liveness probe asks "is this container stuck?" and Kubernetes restarts it if the probe keeps failing. A readiness probe asks "can it take traffic right now?" and a failing Pod is removed from Service load balancing without a restart. A startup probe gives slow-starting apps time to boot before the other probes begin.

    AdvancedIn-depth4 min read
  3. Explain the main parts of a Kubernetes Deployment YAML.

    apiVersion and kind identify the object, metadata names it, spec.replicas sets the count, spec.selector says which Pods it owns, and spec.template is the Pod blueprint whose labels must match the selector.

    BeginnerQuick answer1 min read
  4. What are the different Service types in Kubernetes?

    ClusterIP exposes a Service only inside the cluster, NodePort opens a port on every node, LoadBalancer provisions a cloud load balancer, and ExternalName maps the Service to an external DNS name.

    BeginnerQuick answer1 min read
  5. What happens when you delete a Pod that belongs to a Deployment?

    The ReplicaSet notices the count is below the desired replicas and immediately creates a replacement Pod with a new name and IP. To really remove the app, delete or scale the Deployment instead.

    BeginnerQuick answer1 min read
  6. What is a Pod in Kubernetes and why is it not just a container?

    A Pod is the smallest deployable unit in Kubernetes: one or more containers that share an IP address, ports and volumes and are always scheduled together on the same node. Most Pods hold one main container.

    BeginnerQuick answer1 min read
  7. What is a ReplicaSet and how does it relate to a Deployment?

    A ReplicaSet keeps a specified number of identical Pods running, replacing any that die. A Deployment manages ReplicaSets, creating a new one for each version to enable rolling updates and rollbacks.

    BeginnerQuick answer1 min read
  8. What is an Ingress in Kubernetes and how does it differ from a LoadBalancer Service?

    An Ingress defines HTTP and HTTPS routing rules by host and path, handled by an Ingress controller. One load balancer can serve many services, while a LoadBalancer Service creates one external load balancer per Service.

    BeginnerQuick answer1 min read
  9. A Kubernetes Service is not routing traffic to your Pods. How do you debug it?

    Check kubectl get endpoints for the Service. If it is empty, the Service selector does not match the Pod labels, or the Pods are not ready. Also verify targetPort matches the container port.

    IntermediateQuick answer1 min read
  10. How do you enable HTTPS for an Ingress in Kubernetes?

    Store the certificate and key in a TLS Secret, and reference it under spec.tls in the Ingress for your host. With cert-manager, certificates from Let's Encrypt can be issued and renewed automatically.

    IntermediateQuick answer1 min read
  11. What are init containers in Kubernetes and when would you use them?

    Init containers run one after another, to completion, before the app containers start. Use them for setup such as waiting for a database, running migrations or fetching config. If one fails, the Pod restarts it.

    IntermediateQuick answer1 min read
  12. What is a sidecar container in a Kubernetes Pod?

    A sidecar is a helper container running in the same Pod as the main app, sharing its network and volumes. Common uses are log shippers, proxies such as Envoy, and config reloaders.

    IntermediateQuick answer1 min read
  13. What is the difference between port, targetPort and nodePort in a Service?

    port is where the Service listens inside the cluster, targetPort is the container port traffic is forwarded to, and nodePort is the port opened on each node for NodePort or LoadBalancer Services.

    IntermediateQuick answer1 min read
  14. What is the difference between RollingUpdate and Recreate deployment strategies?

    RollingUpdate replaces Pods gradually so the app stays available. Recreate kills all old Pods first and then starts new ones, causing downtime but guaranteeing two versions never run together.

    IntermediateQuick answer1 min read
  15. You created an Ingress but nothing works. What could be missing?

    Usually no Ingress controller is installed, so no one reads the rules. Also check ingressClassName, that the backend Service and port exist, DNS pointing to the controller's address, and that Pods are ready.

    IntermediateQuick answer1 min read