6

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?

1 Answer 1

12

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Ah, so the service and the deployment are different entities. The deployment doesn't exactly "contain" the service and vice versa. So Kubernetes uses the "service" to expose the service offered by the "deployment". Does my understanding now seem right?
Yes, you've got it.
If service is load balancer then ingress is?
@user960567 It's more like: Pod is a single or a group of containers | Deployment is a deployment manager for Pods | Service is an Internet Interface of Kubernetes (Allows for communication in and out of Kubernetes Cluster - highly coupled with kube-proxy) | Ingress is a Load Balancer (It allows to create multiple target groups with a single entry point)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.