A Service is an abstraction that defines a logical set of Pods and a policy to access them, typically through a stable virtual IP and DNS name. Services discover their backend Pods via a label selector, and the endpoints controller automatically updates the Service's backend list whenever matching Pods appear or disappear. In large clusters, the legacy Endpoints API has been superseded by EndpointSlices, which split backend Pods into multiple smaller objects, reducing update size and enabling scalable routing. kube-proxy on each node reads EndpointSlices (or Endpoints) and programs iptables, IPVS, or eBPF rules to implement the Service virtual IP and load-balance traffic to the right Pod IPs.
Kubernetes exposes several Service types for different access patterns. ClusterIP, the default, exposes the Service on a cluster-internal IP reachable only from within the cluster. NodePort exposes the Service on each node's IP at a static port (default range 30000-32767), making it reachable from outside the cluster as <NodeIP>:<NodePort>. LoadBalancer provisions a cloud-provider-specific external load balancer that routes traffic to backend nodes on a public IP. A Headless Service (clusterIP: None) does not allocate a virtual IP or perform load balancing; instead, DNS queries return the Pods' IPs directly, which is especially useful for StatefulSets and custom discovery. An ExternalName Service maps a Service to a CNAME DNS record, allowing Pods to reach an external service via a cluster-internal name.
Network security is controlled through NetworkPolicy resources, which specify how groups of Pods are allowed to communicate with each other and other network endpoints. NetworkPolicy enforcement requires a CNI plugin that supports it, such as Calico, Cilium, or Weave Net. A NetworkPolicy without a podSelector applies to all Pods in the namespace; if neither an ingress nor an egress rule list is provided, all matching traffic is allowed. The default cluster behavior is permissive: if no NetworkPolicy selects a Pod, all ingress and egress traffic is allowed. Cluster-internal name resolution is provided by kube-dns or coredns, and Service names resolve via the pattern <svc>.<ns>.svc.cluster.local.