What is a Kubernetes Service and why do we need one?
BeginnerConceptServices, Networking, Ingress & Gateway API
Answer
Pod IPs change every time a Pod is replaced, so clients need a stable virtual IP and DNS name. A Service selects Pods by label and gives them a stable ClusterIP; kube-proxy (or eBPF) load-balances connections across ready endpoints.
kubectl expose deploy web --port=80 --target-port=8080
kubectl get endpointslices -l kubernetes.io/service-name=web
More on Services, Networking, Ingress & Gateway API
What are the Service types?BeginnerWhat is the difference between `port`, `targetPort` and `nodePort`?BeginnerHow does DNS work inside a cluster?BeginnerWhat is a headless Service and when do we use it?BeginnerWhat is an Ingress?BeginnerWhat is the difference between Ingress and Service type LoadBalancer?Beginner