liveBook · Manning

Service

As explained in Platform Engineering on Kubernetes

A Kubernetes Service is a stable network endpoint that exposes a set of Kubernetes workload instances to other clients inside a cluster.

A Kubernetes Service provides a stable logical endpoint for containers managed by Deployments. It routes traffic to matching Pods, balances requests across replicas, and lets clients use a service name instead of changing Pod IP addresses. section 2.1.2 section 2.3.4

A Service connects application workloads through several implementation elements:

  • A selector such as app=frontend links the Service to Pods created by a Deployment. section 2.3.5
  • A ClusterIP exposes the workload inside the cluster, while the Service forwards its port to a container target port. section 2.3.5
  • Other services can address the endpoint by name and port without knowing Pod IP addresses. section 2.3.6
  • Ingress handles traffic entering the cluster; it uses the Service as a backend rather than replacing it. section 2.3.6

Inspecting the frontend Service

Run kubectl get services to list endpoints, then kubectl describe service frontend to inspect its selector and endpoints. A frontend Service can select app=frontend, expose port 80, target port 8080, and route to multiple Pod addresses. section 2.3.5

Listing 2.6 Describing the Frontend service
Name:              frontend
Namespace:         default
Labels:            app.kubernetes.io/managed-by=Helm
Annotations:       meta.helm.sh/release-name: conference
                   meta.helm.sh/release-namespace: default
Selector:          app=frontend    #1
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.96.60.237
IPs:               10.96.60.237
Port:              <unset>  80/TCP
TargetPort:        8080/TCP
Endpoints:         10.244.1.6:8080,10.244.2.9:8080
Session Affinity:  None
Events:            <none>

Use the frontend description to inspect the selector, ClusterIP, ports, target port, and currently routed endpoints. section 2.3.5

How Platform Engineering on Kubernetes covers it

How deep it goes
Explains names, selectors, ports, ClusterIP routing, and endpoints, while deferring detailed resource management.
Examples
Uses frontend, PostgreSQL, Redis, and Kafka Services alongside kubectl listing and description commands.
What it assumes
Assumes familiarity with containers and Deployments, while establishing name-based communication without requiring fixed Pod addresses.
What you can do after
Operate/configure Services with kubectl and connect workloads through stable names, selectors, ports, and generated infrastructure endpoints.
How it connects
Connects Deployments, Pods, service discovery, load balancing, Ingress, and Kubernetes Secrets.

Also explained in

Compare how 12 books explain service →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Platform Engineering on Kubernetes. The section links point to the parts of the book it draws on.