Skip to main content
Interviewpedia

What is the difference between a Deployment and a Service in Kubernetes?

Technical · Mid-level

Answer guide

Read the answer guide

A Deployment describes the desired state for identical Pods, such as the image and replica count, and manages rolling updates and rollbacks by replacing Pods gradually. A Service gives clients a stable name and virtual address and spreads traffic across the Pods its label selector matches, because Pod IPs change whenever Pods are replaced. The two connect only through matching labels, so a typo in a selector gives a Service with no endpoints. Use ClusterIP for internal traffic and a LoadBalancer or ingress for outside traffic; when troubleshooting, compare the selector with the Pod labels.

What the interviewer is assessing

Whether you separate workload management from networking in Kubernetes and know how the two link.

A strong answer covers

  • A Deployment declares desired state for identical Pods, such as image and replica count, and manages rolling updates and rollbacks.
  • A Service gives clients a stable name and virtual address and spreads traffic across matching Pods, because Pod IPs change.
  • They connect only through matching labels; a selector typo leaves a Service with no endpoints.
  • Use ClusterIP for internal traffic and LoadBalancer or ingress for external traffic.
  • When troubleshooting, compare the Service selector with the Pod labels.

Common mistakes

  • Thinking a Service is what creates or restarts the Pods.
  • Not knowing that label selectors link a Service to Pods, so mismatched labels route no traffic.

Practise a follow-up

  • What happens to traffic during a rolling update if readiness probes are missing?
  • When would you use a ClusterIP service and when a LoadBalancer or ingress?
Practise this question →

Related questions