Networking

Kubernetes nodes with kube-proxy in IPVS mode cause long-lived TCP connections to stall when conntrack entries exceed kernel limit

Environment

Environment

Self-managed Kubernetes cluster: kube-proxy running in IPVS mode on Debian 11 nodes, kernel 5.15. Cluster services with NodePort and ClusterIP; many short-lived and some long-lived TCP connections (WebSockets, SSH tunnels). Nodes handle ~200k concurrent ephemeral flows during peak.

Symptoms

Symptoms

Long-lived TCP connections (WebSocket sessions and long-poll HTTP) hang after several minutes to tens of minutes: client sees connection freeze though TCP stays ESTABLISHED; small/short requests continue to succeed. Restarting kube-proxy on an affected node immediately restores connectivity for connections routed via that node. New connections are accepted until the stall recurs.

Observations

Observations

On affected nodes /proc/sys/net/netfilter/nf_conntrack_count frequently approaches or reaches /proc/sys/net/netfilter/nf_conntrack_max around the time stalls start. dmesg occasionally shows 'nf_conntrack: table full, dropping packet' and 'xt_conntrack: expect entry without conntrack' messages. ipvsadm -L shows many entries but not excessive CPU utilization on nodes. Increasing nf_conntrack_max from 65536 to 200000 reduced stall frequency but did not eliminate them. conntrack -L shows many connections in UNREPLIED or ESTABLISHED states with large durations.

Already attempted

Already attempted

Raised nf_conntrack_max and tuned nf_conntrack_tcp_timeout_established from default to a shorter timeout as an experiment (reversible sysctl changes). Temporarily switched a test node to kube-proxy iptables mode to validate; iptables node did not exhibit the same stalls under similar load. Performed kube-proxy rollout (restart) on two nodes which temporarily cleared the issue. Enabled conntrack monitoring (exporter) to track trend.

Question

Question

Given the evidence of conntrack table saturation and IPVS-specific behavior, what diagnostic steps and configuration changes should I apply to determine whether this is conntrack table exhaustion, an IPVS conntrack bug, or kube-proxy misconfiguration, and what safe mitigations can I apply without a large cluster-wide restart?

COMMUNITY RESPONSES

Verified community troubleshooting

0 replies

No answers yet..

Showing 0 of 0 community responses
AI DIAGNOSTICS

Incident analysis

Updated 1mo ago• Trouble ID

Most likely causes

Conntrack table saturation due to high number of connections and insufficient nf_conntrack_max / timeouts, causing kernel to drop or not track new/existing flows 80%
IPVS + conntrack interaction bug in the kernel or ip_vs module causing orphaned conntrack entries or preventing GC of certain connection states (e.g., UNREPLIED), especially under heavy churn 55%
kube-proxy misconfiguration (e.g., overly long timeouts, Service/sessionAffinity settings, or NodePort churn) producing many ephemeral flows that exhaust conntrack 40%

Summary

The kernel conntrack table reaching its max and log messages indicating table full strongly point to conntrack exhaustion as a primary contributor. IPVS relies on conntrack for NAT-ed service flows; when conntrack entries are dropped, existing long-lived flows can hang because replies are no longer associated with a conntrack entry. The fact that switching to iptables on a test node avoided the problem suggests an IPVS/conntrack interaction issue or differences in connection lifetime handling. Raising nf_conntrack_max reduced frequency but did not cure the root cause, indicating either leaks (entries not expiring due to timeouts or stuck entries), an IPVS bug preventing normal conntrack GC, or application behavior creating an excessive number of half-open/long-lived ephemeral flows.

Suggested Fixes

Diagnostic step 1
Monitor /proc/sys/net/netfilter/nf_conntrack_count and nf_conntrack_max closely alongside connection churn metrics (Connections/s, new flows) to correlate peaks to stalls. These are read-only sysfs metrics and safe to read.
Diagnostic step 2
Dump conntrack entries (conntrack -L) at times of failure and inspect for many UNREPLIED or TIME_WAIT entries; export a sample (redact IPs if sending to vendors) and look for patterns tied to specific services or source ranges.
Diagnostic step 3
Temporarily adjust nf_conntrack_max upward on a single node and observe if stalls disappear; this is reversible (sysctl -w). If that helps, consider a controlled cluster-wide increase with capacity planning and memory checks (conntrack uses kernel memory).

Continue troubleshooting

Matched from the title, description and tags