Creating a service
Kubernetes services provide a single stable name and address for a set of pods. They act as basic in-cluster load balancers.
Most pods are designed to be long-running, but when a single process dies, the pod dies with it. If it dies, the Deployment replaces it with a new pod. Every pod gets its own dedicated IP address, which allows containers to have the same port (the exception is when NodePort is used), even if they're sharing the same host. But when a pod is started by the Deployment, the pod gets a new IP address.
This is where services really help. A service is attached to the deployment. Each service gets assigned a virtual IP address that remains constant until the service dies. As long as we know the service IP address, the service itself will keep track of the pods created by the deployment and will distribute requests to the deployment pods.
By setting the service, we get an internal Kubernetes DNS name. Also, the service acts as an in-cluster...