1.14 Kubernetes Service Definition
A Kubernetes Service Definition is a resource that enables communication between pods by defining access points and routing rules within a cluster.
Kubernetes Service Definition is the precise characterization of a Service as an API object that defines a stable, addressable abstraction over a dynamically changing set of Pods, identified by a label selector, and distinguished from the Pods it fronts by the fact that its identity persists independently of any particular Pod's creation or destruction.
Service as a Stable Abstraction
Defined by What It Decouples
A Service is defined by the decoupling it provides: it separates the stable act of addressing a group of Pods from the unstable, ever-changing set of specific Pod IP addresses that currently satisfy that group, allowing clients to depend on the former without needing to track the latter.
Identity Independent of Backing Pods
A Service's own identity, its name, virtual IP, and DNS record, is defined independently of which Pods currently back it; a Service can exist, and be addressed, even at a moment when it has no matching Pods at all, since its definition does not require a non-empty backing set.
The Selector as the Defining Mechanism
Continuous Reevaluation, Not a Snapshot
A Service's set of backing Pods is defined not as a fixed list but as the continuously reevaluated result of applying its label selector against the current set of Pods in its namespace; this is what allows Service membership to update automatically as Pods are created or destroyed.
Selector-less Services as an Exception
A Service is not required to have a selector at all; when defined without one, its backing endpoints must instead be managed manually or point to an external resource, illustrating that the selector mechanism, while typical, is not itself part of the core definition of what a Service is.
Type as a Defining Property
ClusterIP as the Base Case
Every Service has a defined type governing how it is exposed, with ClusterIP as the base case: an internally routable virtual IP reachable only from within the cluster, upon which the other types, NodePort and LoadBalancer, are built as additional layers of exposure.
Headless as a Distinct Definition
A Service explicitly configured without a cluster IP is defined as headless, changing its fundamental behavior from load-balancing traffic to a virtual IP, to instead returning the individual addresses of its backing Pods directly through DNS.
What a Service Definition Does Not Include
Not the Pods Themselves
A Service does not own or manage the lifecycle of the Pods it selects; it neither creates them nor is responsible for their health, distinguishing it clearly from workload controllers such as Deployments, which do own and manage the Pods they create.