Understanding Kubernetes Traffic Flow: External and Internal Types

Kubernetes Traffic Flow

Kubernetes traffic falls into two broad categories: traffic coming in from outside the cluster and traffic moving between services inside the cluster.


The Big Picture
External User
[ LoadBalancer / Ingress ]
[ Service ]
[ Pod (via kube-proxy / iptables / eBPF) ]
[ Container ]

1. External Traffic (North-South)

This is traffic entering the cluster from the outside world.

LoadBalancer Service

The simplest path. A cloud provider provisions an external LB that forwards traffic directly to a Kubernetes Service.

Internet → Cloud LB → NodePort (on any node) → Service → Pod
Ingress

A more sophisticated HTTP/HTTPS router. An Ingress Controller (e.g. NGINX, Traefik, AWS ALB) watches Ingress resources and routes based on host/path rules.

Internet → Cloud LB → Ingress Controller Pod → Service → Pod
# Example Ingress rule
spec:
rules:
- host: app.example.com
http:
paths:
- path: /api
backend:
service:
name: api-service
port:
number: 80
- path: /web
backend:
service:
name: web-service
port:
number: 80
Service Types for External Access
TypeHow it works
ClusterIPInternal only, no external access
NodePortOpens a port (30000–32767) on every node
LoadBalancerProvisions a cloud LB, routes to NodePort → Service
ExternalNameDNS alias to an external hostname

2. Internal Traffic (East-West)

Traffic between services inside the cluster.

The Role of kube-proxy

Every node runs kube-proxy, which programs iptables (or IPVS) rules. When a pod calls a Service ClusterIP, iptables intercepts the packet and rewrites the destination to one of the healthy pod IPs (load balancing happens here).

Pod A → Service ClusterIP → iptables/IPVS → Pod B (one of N replicas)
DNS Resolution

Every pod gets DNS from CoreDNS. A service named api in namespace default is reachable at:

api # within same namespace
api.default # short form
api.default.svc.cluster.local # fully qualified
Pod-to-Pod (direct)

Every pod gets its own IP (flat network). Pods can talk directly without NAT — this is the Kubernetes networking model. Implemented by the CNI plugin (Flannel, Calico, Cilium, etc.).

Pod A (10.244.1.5) → Pod B (10.244.2.8) # direct, no NAT

3. The Full Request Lifecycle (example)

A user hits https://app.example.com/api/users:

1. DNS resolves app.example.com → Cloud LB IP
2. Cloud LB receives request on port 443
→ forwards to Ingress Controller pod (e.g. nginx on port 443)
3. Ingress Controller terminates TLS
→ matches rule: host=app.example.com, path=/api
→ forwards to Service "api-service:80"
4. CoreDNS resolves "api-service" → ClusterIP (e.g. 10.96.45.12)
5. iptables on the node intercepts packet to 10.96.45.12
→ rewrites destination to a healthy pod IP (e.g. 10.244.2.7:8080)
→ load balances across replicas
6. Packet reaches Pod
→ container handles request on port 8080
7. Response travels back the same path in reverse

4. Network Policies

By default, all pods can talk to all other pods. NetworkPolicy resources let you lock this down:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: api-allow-only-frontend
spec:
podSelector:
matchLabels:
app: api
ingress:
- from:
- podSelector:
matchLabels:
app: frontend
ports:
- port: 8080

This says: only pods labeled app=frontend can reach app=api on port 8080. All other ingress is dropped.


5. Service Mesh (Advanced)

Tools like Istio or Linkerd inject a sidecar proxy (Envoy) into every pod. Traffic flows through the sidecar, enabling:

Pod A → Envoy sidecar → mTLS encrypted tunnel → Envoy sidecar → Pod B
FeatureWithout meshWith mesh
EncryptionManual TLS setupAutomatic mTLS
Retries/timeoutsApp codeProxy config
Traffic splittingNeeds ingress tricksNative (canary, A/B)
ObservabilityLimitedFull traces, metrics

Key Components Summary

ComponentRole
CoreDNSService discovery via DNS
kube-proxyPrograms iptables/IPVS rules for Service routing
CNI pluginPod-to-pod networking (Flannel, Calico, Cilium)
Ingress ControllerHTTP routing, TLS termination
Cloud LBExternal entry point
NetworkPolicyFirewall rules between pods
Service MeshmTLS, observability, advanced traffic control

Leave a Reply