22

After reading thru Kubernetes documents like this, deployment , service and this I still do not have a clear idea what the purpose of service is.

It seems that the service is used for 2 purposes:

  1. expose the deployment to the outside world (e.g using LoadBalancer),
  2. expose one deployment to another deployment (e.g. using ClusterIP services).

Is this the case? And what about the Ingress?

------ update ------

Connect a Front End to a Back End Using a Service is a good example of the service working with the deployment.

2
  • 1
    Deployment is one of the Controllers - to manage pods / containers - scale up, down, start, stop, replicas etc. Service is Load Balancer - to manage connectivity between the pods (ClusterIP) and outside world (Load Balancer, NodePort) Commented Jul 5, 2019 at 4:26
  • So we are on the same page.
    – Qiulang
    Commented Jul 5, 2019 at 4:29

1 Answer 1

17

Service

A deployment consists of one or more pods and replicas of pods. Let's say, we have 3 replicas of pods running in a deployment. Now let's assume there is no service. How do other pods in the cluster access these pod replicas? Through IP addresses of these pods. What happens if we say one of the pods goes down. Kubernetes bring up another pod. Now the IP address list of these pods changes and all the other pods need to keep track of the same. The same is the case when there is auto scaling enabled. The number of the pods increases or decreases based on demand. To avoid this problem services come into play. Thus services are basically programs that manages the list of the pods ip for a deployment.

And yes, also regarding the uses that you posted in the question.

Ingress

Ingress is something that is used for providing a single point of entry for the various services in your cluster. Let's take a simple scenario. In your cluster there are two services. One for the web app and another for documentation service. If you are using services alone and not ingress, you need to maintain two load balancers. This might cost more as well. To avoid this, ingress when defined, sits on top of services and routes to services based on the rules and path defined in the ingress.

1
  • the nested scheme is like this: e.g. 3 pods are exposed into a service. 2 pods in another service and on top of these services there is ingress that load balances traffic. correct?
    – ERJAN
    Commented Jan 27, 2022 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.