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. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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