Three pods, and their addresses keep changing
Three shop app pods are running. A pod gets a new address every time it is recreated, so callers cannot rely on pod addresses.
So you put one stable address and port in front of the pods. That is a Service.
A Service groups pods by label
A Service has a pod selector (a rule that picks pods by label). Here it is app=shop.
Whatever pods match at the moment become targets. As pods come and go, the Service config needs no changes as long as the labels match.
Key ideaA Service does not name its pods. It just says "all pods with this label".
ClusterIP — an address for calls inside the cluster
If you do not set a type, ClusterIP (a stable address used only inside the cluster) is the default. Other pods in the same cluster call it by this address or by the Service name.
The Service forwards each request to one of its pods. Callers do not need to know how many pods are behind it.
This address is unreachable from outside the cluster
An external user cannot reach the ClusterIP address. It means something only on the cluster's internal network.
For Services that pods call each other through, that is enough. To expose it outside, change the type or put an entry (Ingress) in front.
NodePort — opens the same port on every node
Switch to NodePort and every node opens the same port number (one from 30000-32767 by default). Requests from outside to a node IP and that port go to the Service.
The ClusterIP address stays too. NodePort adds an outside door to the in-cluster address.
LoadBalancer — an external load balancer attaches an address
Switch to LoadBalancer and a load balancer outside the cluster gets an external address and attaches it to the Service. Users come in through that address without knowing any node IP.
The load balancer forwards requests to nodes, and the nodes forward them to the Service. Use it in clouds or environments with a separate load balancer implementation.
With nothing to hand out addresses, the external address stays empty
If there is no load balancer implementation or no free address to assign, the Service is created but stays without an external address.
kubectl get svc shows EXTERNAL-IP stuck at <pending>. On-premises, check that you have a load balancer implementation such as MetalLB and an address pool.
Watch out"The Service was created" and "it is reachable from outside" are different states. Check separately that EXTERNAL-IP is filled in.
A wrong selector leaves zero targets
If you mistype the selector as app=shpo, no pods match. The Service still exists but has nowhere to send requests.
This does not show up as an error. kubectl get endpointslices shows no pod addresses attached.
Watch outIf you cannot connect, check the endpoints first. If they are empty, compare the selector with the pod labels side by side.
The selector sets the targets; the type sets the reach
Fix the selector and the three pods become targets again. A Service picks pods with its selector and decides how far it is exposed with its type.
ClusterIP reaches inside the cluster, NodePort adds node ports, and LoadBalancer adds an external address. Exposing by domain and path is the job of Ingress.
SummaryThe selector sets the target pods; the type sets how far it is exposed. Endpoints and external addresses can be empty with no error, so check them separately.