Simple definition#
Kubernetes networking answers four questions: how Pods talk to each other, how clients find a stable address for a changing set of Pods (Services), how external traffic gets in (Gateway API / Ingress), and how traffic is restricted (NetworkPolicy).
The network model — three rules#
- Every Pod gets its own IP address.
- Pods can reach all other Pods without NAT, on any node.
- Agents on a node can reach all Pods on that node.
A CNI (Container Network Interface) plugin implements these rules — for example Cilium (eBPF), Calico, cloud-native CNIs such as the AWS VPC CNI and Azure CNI, or OVN-Kubernetes on OpenShift.
flowchart LR
subgraph N1["Node 1"]
P1["Pod A<br/>10.0.1.5"] --- V1["veth"] --- B1["CNI data plane"]
end
subgraph N2["Node 2"]
B2["CNI data plane"] --- V2["veth"] --- P2["Pod B<br/>10.0.2.7"]
end
B1 <-->|"routed or overlay<br/>(VXLAN / Geneve)"| B2
Services: stable addresses for changing Pods#
Pods come and go; their IPs change. A Service gives a stable virtual IP and DNS name and load-balances to the ready Pods that match its label selector (tracked in EndpointSlices).
| Type | Reachable from | Use |
|---|---|---|
| ClusterIP (default) | Inside the cluster | Service-to-service calls |
| NodePort | Each node’s IP on a high port | Rarely directly; building block for LBs |
| LoadBalancer | Outside, via a cloud load balancer | Exposing gateways or TCP services |
Headless (clusterIP: None) |
DNS returns Pod IPs | StatefulSets, client-side load balancing |
| ExternalName | DNS alias | Point to an external service |
How Service routing is implemented: kube-proxy programs iptables or nftables rules on every node (IPVS mode is deprecated as of 1.35), or an eBPF data plane (Cilium) replaces kube-proxy for better performance and observability.
DNS: CoreDNS resolves orders.shop.svc.cluster.local to the Service IP. Within a namespace, orders is enough.
Getting traffic in: Ingress → Gateway API#
Ingress was the original API for HTTP routing, but it is limited (one resource for everything, routing details hidden in vendor annotations). The Gateway API is its successor: role-oriented, expressive and portable.
flowchart TB
GC["GatewayClass<br/>which implementation<br/>owner: infrastructure provider"] --> GW["Gateway<br/>listeners, ports, TLS<br/>owner: platform team"]
GW --> R1["HTTPRoute<br/>/orders → orders Service<br/>owner: app team"]
GW --> R2["GRPCRoute / TLSRoute / TCPRoute"]
R1 --> S1["Service: orders"]
- GatewayClass — the implementation (Envoy Gateway, Istio, Cilium, NGINX Gateway Fabric, Kong, HAProxy, cloud gateways).
- Gateway — listeners, hostnames, certificates; owned by the platform team.
- HTTPRoute / GRPCRoute — path, header and weight-based routing (canaries), owned by app teams; ReferenceGrant controls cross-namespace references.
A request traced end to end#
- DNS (often managed by external-dns) resolves the hostname to the cloud load balancer.
- The load balancer forwards to the gateway’s Pods.
- The Gateway terminates TLS; the matching HTTPRoute selects the backend Service.
- The Service (kube-proxy or eBPF) picks a ready endpoint Pod.
- The response returns along the same path.
Network policies: default-deny#
By default every Pod can talk to every Pod. NetworkPolicy restricts traffic by labels, namespaces and ports (enforced by the CNI).
# 1. Deny all ingress in the namespace
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: default-deny-ingress, namespace: shop }
spec:
podSelector: {}
policyTypes: [Ingress]
---
# 2. Allow only the gateway to reach the orders Pods on 8080
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: allow-gateway-to-orders, namespace: shop }
spec:
podSelector: { matchLabels: { app: orders } }
ingress:
- from:
- namespaceSelector: { matchLabels: { kubernetes.io/metadata.name: gateway } }
ports: [{ port: 8080, protocol: TCP }]
- Start with default deny, then allow known flows (including DNS egress to CoreDNS).
- Advanced CNIs add L7 rules, FQDN-based egress, cluster-wide policies and the upcoming AdminNetworkPolicy for platform teams.
Multi-cluster and egress#
- Egress control: egress gateways or FQDN policies so workloads reach only approved external hosts.
- Multi-cluster networking: Cilium Cluster Mesh, Submariner, service mesh multi-cluster, or global load balancing at the edge.
- IP planning: size Pod and Service CIDRs for growth; avoid overlaps with on-premises networks; consider IPv6/dual-stack.
Common mistakes#
Quick check#
What are the three rules of the Kubernetes network model? Every Pod has its own IP; Pods reach each other without NAT across nodes; node agents reach local Pods.
Why do we need Services? Pod IPs change; a Service provides a stable virtual IP and DNS name and load-balances to ready Pods selected by labels.
What problem does the Gateway API solve over Ingress? It separates roles (GatewayClass, Gateway, Routes), supports richer routing (headers, weights, gRPC, TCP) natively instead of vendor annotations, and is portable across implementations.
What happened to ingress-nginx? The community controller was retired in March 2026; teams should migrate to the Gateway API or another maintained controller.
How do you isolate a namespace? A default-deny NetworkPolicy, then explicit allow policies for required flows, including DNS.
kube-proxy vs eBPF data plane? kube-proxy programs iptables/nftables rules for Services; eBPF data planes (such as Cilium) implement Services and policies in the kernel more efficiently with better visibility, and can replace kube-proxy.
Summary#
- CNI plugins give every Pod an IP and connect Pods across nodes.
- Services give stable addresses; kube-proxy or eBPF implements them; CoreDNS names them.
- Use the Gateway API for north-south traffic; ingress-nginx is retired.
- Default-deny NetworkPolicies; control egress; plan IP ranges.
References#
- Kubernetes documentation, Services, load balancing and networking.
- Gateway API.
- Kubernetes blog, Ingress NGINX retirement: what you need to know, November 2025.
- CNCF blog, Navigating the ingress-nginx retirement, 2026.