Helm Deployment vs Service

8/4/2018

I am trying to understand k8s and helm.

When I create a helm chart, there are 2 files: service.yaml and deployment.yaml. Both of them have a name field.

If I understand correctly, the deployment will be responsible for managing the pods, replicasets, etc and thus the service.

Basically, why am I allowed use a separate name for the service and for the deployment? Under what scenario would we want these 2 names to differ? Can a deployment have more than 1 service?

-- Ufder
deployment
kubernetes
kubernetes-helm
service

1 Answer

8/4/2018

The "service" creates a persistent IP address in your cluster which is how everything else connects it. The Deployment creates a ReplicaSet, which creates a Pod, and this Pod is the backend for that service. There can be more than 1 pod, in which case the service load balances, and these pods can change over time, change IP's, but your service remains constant.

Think of the service as a load balancer which points to your pods. It's analogous to interfaces and implementations. The service is like an interface, which is backed by the pods, the impementations.

The mapping is m:n. You can have multiple services backed by a single pod, or multiple pods backing a single service.

-- Marcin Romaszewicz
Source: StackOverflow