Kubernetes Pods are created and destroyed to match the desired state of your cluster. Pods are nonpermanent
resources. If you use a Deployment to run your app, it can create and destroy Pods dynamically.
Each Pod gets its own IP address, however in a Deployment, the set of Pods running in one moment in time could
be different from the set of Pods running that application a moment later.
This leads to a problem: if some set of Pods (call them "backends") provides functionality to other Pods (call them
"frontends") inside your cluster, how do the frontends find out and keep track of which IP address to connect to,
so that the frontend can use the backend part of the workload?
Service:
1. When using RC,RS,deployement, pods are terminated and created during scaling or replication operations
When using deployment , while updating the image version the pods are terminated and new pods take the
place of other pods.
2.
Pods are very dynamic i.e. they come & go on the k8s cluster and on any of the available nodes & it would
be difficult to access the pods as the pods IP changes its recreated.
3.
4. Service objects is an logical bridge between pods and end user, which provide virtual IP
5. Service allow client to reliably connect to the the containers running in the pod using the VIP
The VIP is not a actual IP connected to a network interface, but its purpose is purely forward traffic to one or
more pods
6.
kube proxy is the one which keeps the mapping between the VIP and pods up to date, which queries the API
server to learn about new services in the cluster
7.
8. Although each pod having unique IP address, but those are not accessible outside the cluster.
9. Services help to expose the VIP mapped to the pod & allow application to receive traffic
10. Label are used to select which are the pods to be put under the service
11. Creating a service will create an endpoint to access the pods/application in it.
Service can be expose in 3 different way be specifying a type in the service spec
a. Cluster IP
b. Node Port
c. Load Balancer
12.
13. By default service can run only between ports 30,000 - 32767.
14. The set of pods targeted by a service usually determined by a selector