liveBook · Manning

Service

As explained in Learn Docker in a Month of Lunches, Second Edition

A Kubernetes Service is a network abstraction that exposes selected Pods and routes traffic to them.

A Kubernetes Service gives applications a stable networking layer when Pods may run on different nodes. It accepts traffic and routes it to matching Pods, avoiding direct connections to changing Pod addresses. Port forwarding remains useful for testing, but Services model application traffic for regular exposure. section 15.2

A Service connects to Pods through labels and selectors:

  • No matching Pods means the Service cannot forward traffic. section 15.2
  • One matching Pod receives all traffic. section 15.2
  • Several matching Pods receive distributed traffic, making the Service act as a load balancer. section 15.2

Route traffic to the numbers API

Label the Pod with app=numbers and component=api. Configure the Service to listen on port 8015, target the Pod's named http port, and select those labels. Apply the Service, inspect it with kubectl describe svc numbers-api, then test it with curl http://localhost:8015/rng.

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains selectors, zero-to-many Pod matches, port mapping, and load balancing without detailing networking internals.
Examples
Uses a labeled numbers API Pod, a Service manifest, kubectl inspection, and a curl request to verify routing.
What it assumes
Assumes familiarity with Pods, Pod labels, YAML manifests, kubectl, and basic HTTP requests.
What you can do after
Operate/configure a Service with kubectl, select Pods by labels, and verify routed HTTP traffic.
How it connects
Connects Pods, labels, selectors, port forwarding, endpoints, and load balancing.

Also explained in

Compare how 12 books explain service →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.