Pcornel
Containers

Kubernetes Networking & Services

Cheat sheet · https://pcornel.dk/topic.php?topic=6081

Back to the Topic

Answer

Kubernetes networking gives every pod an IP on a flat network (CNI); Services give a stable virtual IP and DNS name over a set of pods selected by labels; Ingress/Gateway expose HTTP from outside.

Remember

A Service with no endpoints means its selector matches no ready pods. DNS name: <svc>.<ns>.svc.cluster.local. NetworkPolicies may block traffic once any policy selects a pod.

First checks

  • kubectl get svc,endpointslices -n <ns> — first check for this topic
  • kubectl get pods -o wide — pods, status, node, IP
  • kubectl describe pod <pod> — events and conditions
  • kubectl logs <pod> [-c <c>] [--previous] — container logs (incl. previous crash)
  • kubectl get events --sort-by=.lastTimestamp — recent cluster events

Verify in this order

client → DNS → Service VIP → kube-proxy/eBPF → ready endpoint pod

Where it usually breaks

Typical failures are empty endpoints from selector mismatch, wrong targetPort, DNS name/scope confusion, source-NAT assumptions, external load-balancer health checks hitting the wrong path, and NetworkPolicy allowing one direction but blocking reply/dependency traffic.

Kubernetes Networking & Services verification boundary matrix

BoundaryInspectHealthy interpretationDo not infer
IntentCluster networking modelIntended object/scope is explicit and versioned where relevantIntent is already effective
Owning runtime/control planeService ClusterIP/NodePort/LoadBalancer / kube-proxy responsibilityOwner accepts and reports the expected object stateDownstream dependencies are healthy
Effective stateCluster DNSIndependent read-back matches the intended stateEvery client sees the same result
Consumer outcomeIngress and Gateway conceptsThe original bounded check succeeds in the same time windowProduction correctness outside this scope

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6081

Confirmation

Confirm action

Continue?