Lesson 16 of 19 · 18m
kube-proxy and conntrack: What a ClusterIP Actually Is
A ClusterIP is a pile of iptables rules on every node, not an address that exists — and every DNAT'd flow lives in a conntrack table that fills up and drops packets silently.
kubectl get svc prints 10.96.0.10 and your brain files it under "IP address." There is no 10.96.0.10. No interface has it, no router knows it — ip addr on any node won't show it. It is a virtual IP that exists only as packet-rewriting rules on every node, installed by kube-proxy. A packet aimed at 10.96.0.10 gets DNAT'd to some endpoint pod IP before it leaves the node it started on. The "address" is the rule set.
iptables mode
kube-proxy's default mode programs iptables. Per Service, a chain KUBE-SVC-<hash>; per endpoint, a KUBE-SEP-<hash> chain that does the DNAT to podIP:port. The membership kube-proxy programs from is EndpointSlices — kubectl get endpointslices shows the real backend list — which the EndpointSlice controller keeps in sync with ready pods. Endpoint selection inside a chain is -m statistic --mode random --probability jumps — for three endpoints, probabilities 1/3, then 1/2, then always. Not uniform: the first endpoint catches a third of flows, the last a sixth. It evens out at flow volume; don't read it as a bug.
NodePort is just another hop. A packet to nodeIP:30080 hits a KUBE-EXT- chain that forwards into the same KUBE-SVC machinery — NodePort → ClusterIP rules → pod. That is why a NodePort service works from inside the cluster too, and why every node's iptables knows about every service.
The table that fills
iptables DNAT is conntrack's job. Every connection — TCP or UDP — gets an entry in nf_conntrack, and the table has a ceiling: net.netfilter.nf_conntrack_max (kernel-version-dependent; 262144 is common). When it fills, the kernel drops packets and writes nf_conntrack: table full, dropping packet in dmesg — silent to your app, which just sees timeouts. The usual filler is DNS: UDP/53 churn, thousands of short flows, each holding an entry for its timeout window. If your cluster does heavy DNS or many short-lived connections, read the count: conntrack -C, or /proc/sys/net/netfilter/nf_conntrack_count.
externalTrafficPolicy and what it costs
externalTrafficPolicy: Cluster — the default — accepts external traffic for the service on any node and DNATs onward; the extra hop SNATs, so pods see a node IP, not the client's. Local preserves the real client source IP and accepts only on nodes holding a ready endpoint; your load balancer health-checks healthCheckNodePort to learn which nodes those are. Local is what you want for source-IP allowlists and geo rules; Cluster is what silently defeats them while looking fine. internalTrafficPolicy: Local does the same job for in-cluster callers.
Two more dataplane facts: sessionAffinity: ClientIP pins a client to one endpoint via sessionAffinityConfig.clientIP.timeoutSeconds, and it is sticky-by-IP only — NAT'd office networks share it. And a pod reaching its own service VIP crosses hairpin NAT; kube-proxy programs it, but it fails on CNIs and setups where hairpin is deliberately disabled.
The modes past iptables
IPVS mode (stable since Kubernetes 1.11) swaps iptables for a kernel load balancer — O(1) lookup instead of walking chains, which matters once a cluster holds thousands of services. nftables mode arrived alpha in 1.29 and beta in 1.31 — same programming model, newer kernel machinery. iptables remains the default and the mode every debugging muscle is calibrated to — and since the rules live per-node, iptables-save on the node where traffic arrives is the ground truth.
What to actually do
- See the rules:
iptables-save | grep KUBE-SVCon a node. Chain names hash from service name and port. - Pods seeing node IPs where client IPs should be:
externalTrafficPolicy: Local, then confirm your LB health checks hit nodes that actually hold endpoints. - Cluster-wide "random" timeouts under load: check
nf_conntrack_countagainstnf_conntrack_maxbefore blaming the app — the table fills before it complains.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
What is Platform as a Service? The Sweet Spot Between "Too Easy" and "Too Much Work"
Platform as a Service sits between raw servers and fully managed software. You push code, the platform runs it. No Nginx config, no OS patches, no 3 AM server alerts. Here is what PaaS actually gives you, what it costs you in control, and how to decide if it is the right layer for your application.
The World now is Serverless and Container based
A new report from Datadog reveals that serverless computing could be entering the mainstream. This has already been the case in my world for the past few years. Results show that more than half of all organizations are using serverless on one of the three major public cloud providers: Amazon,
PostgreSQL 19 Is Out. REPACK Kept My Writes Running. The Docker Upgrade Will Stop Your App.
PostgreSQL 19 shipped on November 19 with REPACK (CONCURRENTLY), which removes table bloat without blocking writes. I measured it against VACUUM FULL, ran the upgrade from 18, and checked what breaks for self-hosters: Docker tags that refuse to start, a config setting that stops the server, and...
Self-Hosting Prometheus and Grafana: Infrastructure Monitoring That Actually Works
Build a production-grade monitoring stack with Prometheus and Grafana from scratch. Covers architecture, Docker Compose deployment, Node Exporter, alerting with Alertmanager, PromQL from basics to advanced, pre-built dashboards, and everything SudoSecurity uses to monitor its own infrastructure.