Battle-tested Troubleshooting: Kubernetes Pod-to-Pod Failures Across Datacenter Fabrics Using Python Automation and Cisco Tools
Advanced kubernetes pod-to-pod failures in modern datacenters often span multiple layers: CNI dataplane (iptables/eBPF), node routing, VXLAN VTEPs, and BGP EVPN control-plane in the fabric. The fastest path to resolution is a repeatable workflow: classify the symptom, map it to likely layers, collect targeted evidence, and correlate state across Kubernetes and the fabric—preferably with automation.
This post provides a battle-tested troubleshooting approach and automation examples using kubernetes-client plus Cisco-oriented tooling (Netmiko/NAPALM), with a real incident teardown (VXLAN EVPN BGP leak across leafs).
Failure catalog and hypothesis workflow
Start by classifying the symptom. Most pod-to-pod issues fit a handful of patterns that strongly hint at where to look next.
1) Latency spikes (p95/p99) without obvious drops
Typical symptoms
- TCP connections survive but slow down; gRPC deadlines exceeded.
- ICMP works but slow; retransmissions increase.
Likely layers
- Underlay congestion / ECMP imbalance (leaf-spine links, queuing).
- MTU mismatch leading to fragmentation/PMTUD pain (esp. VXLAN).
- CNI policy / conntrack pressure (iptables scale, conntrack table full).
- Asymmetric routing causing firewall/stateful middlebox issues.
Fast hypotheses
- Is the issue path-specific (only certain node pairs)?
- Is MTU consistent from pod → veth → host NIC → fabric → remote node?
2) Drops / timeouts (hard failures)
Typical symptoms
- SYN retransmits, no SYN-ACK.
- One-way traffic works but return path fails.
Likely layers
- NetworkPolicy (kubernetes/CNI) denying traffic.
- Node routing missing routes or wrong next-hop.
- VXLAN VNI mapping wrong, missing flood-list/EVPN routes.
- BGP EVPN route missing/withdrawn/filtered.
- ARP/NDP resolution failures.
Fast hypotheses
- Is it namespace/pod selector related (policy)?
- Is it node-pair related (fabric/control-plane)?
3) Asymmetric routing / one-way traffic
Typical symptoms
- Pod A → Pod B works; Pod B → Pod A fails.
- Traceroute differs per direction; stateful ACLs drop return traffic.
Likely layers
- ECMP hashing differences + inconsistent anycast gateway behavior.
- EVPN RT import/export mismatch causing route to exist only on some leafs.
- Multiple VTEPs advertising same prefix (duplicate IP/MAC, stale routes).
Fast hypotheses
- Compare EVPN route presence on both leafs connected to the two nodes.
4) ARP/NDP issues (L2/L3 neighbor resolution)
Typical symptoms
- Intermittent connectivity; first packets drop; “incomplete” neighbors.
- IPv6 pods fail while IPv4 works (or vice versa).
Likely layers
- EVPN MAC/IP advertisement missing/incorrect.
- Proxy ARP/ND misbehavior (anycast gateway, distributed gateway).
- Duplicate address detection or IP conflicts in IPAM.
Fast hypotheses
- Check MAC/IP bindings in EVPN and local ARP/ND tables.
Data collection checklist (Kubernetes + CNI + Cisco fabric)
The goal is to gather evidence that can be correlated by: (pod, node, IP, MAC, VNI/VXLAN, VTEP, route-target, BGP peer, interface counters).
Kubernetes-side: minimal, high-signal commands
Identify where pods land and their IPs
kubectl -n <ns> get pod -o wide
kubectl -n <ns> get pod <pod> -o jsonpath='{.status.podIP}{"\n"}'
kubectl get node -o wide
Events and logs around the failure window
kubectl -n <ns> describe pod <pod>
kubectl -n <ns> get events --sort-by='.lastTimestamp'
kubectl -n kube-system logs -l k8s-app=kube-proxy --tail=200
Node-level networking (run on affected nodes)
- Routes and policy routing:
bash ip route ip rule - Interface state and MTU:
bash ip link ip addr - Conntrack pressure:
bash sysctl net.netfilter.nf_conntrack_max conntrack -S dmesg | egrep -i 'conntrack|nf_conntrack' - iptables (if kube-proxy iptables mode):
bash iptables -S iptables -t nat -S iptables -t mangle -S
CNI-specific checks (examples; adapt to your CNI)
Because CNI implementations differ, focus on: encapsulation mode, VTEP mapping, BPF/iptables programming, and policy enforcement path.
Calico (common EVPN/underlay integrations)
- Verify datastore objects and BGP sessions (if using Calico BGP):
bash calicoctl get nodes -o wide calicoctl node status calicoctl get ippools -o yaml calicoctl get bgppeer -o wide - Check Felix / dataplane logs:
bash kubectl -n kube-system logs -l k8s-app=calico-node --tail=200
Cilium (eBPF dataplane)
- Identity/policy and datapath visibility:
bash cilium status cilium endpoint list cilium monitor --type drop cilium bpf policy get - Node routing/encap mode sanity:
bash kubectl -n kube-system get cm cilium-config -o yaml
Cisco fabric collection (VXLAN EVPN underlay/overlay)
On relevant leafs/spines (or via automation):
- BGP EVPN control-plane
- NX-OS examples (adjust for platform/OS):
text
show bgp l2vpn evpn summary
show bgp l2vpn evpn route-type 2
show bgp l2vpn evpn route-type 5
show bgp l2vpn evpn <prefix>
show bgp vrf <vrf> ipv4 unicast <prefix>
- VXLAN/VTEP state
text
show nve peers
show nve vni
show vxlan interface nve1
- Neighbor tables
text
show ip arp vrf <vrf>
show ipv6 neighbor vrf <vrf>
show mac address-table vlan <vlan>
- Interface counters (drops, MTU clues)
text
show interface counters errors
show interface <int> | include MTU|rate|drop|error
show hardware internal errors (platform-specific)
Practical tip: for pod-to-pod, you almost always need:
- Leaf connected to Node A
- Leaf connected to Node B
- Any border/route-reflector if EVPN RR is used
Python automation for correlation (Kubernetes + Cisco)
Manual CLI hopping doesn’t scale when failures affect some pod pairs and not others. Automate collection and then correlate on stable keys: node name, pod IP, VTEP IP, VNI, and EVPN route-target.
Below is an example “thin collector” that:
1. Lists pods and their nodes from Kubernetes.
2. For a target pod IP, queries leaf switches for EVPN route presence and NVE peer state.
3. Flags mismatches (route present on one leaf but not the other, or peer down).
Example: Python correlation script (kubernetes-client + Netmiko)
#!/usr/bin/env python3
"""
Collect pod placement from Kubernetes and correlate with Cisco leaf EVPN/VXLAN state.
Prereqs:
pip install kubernetes netmiko
export KUBECONFIG=~/.kube/config
Notes:
- Commands are NX-OS flavored; adjust for your platform.
- For production, add retries, structured parsing, and secrets handling.
"""
from kubernetes import client, config
from netmiko import ConnectHandler
import re
from dataclasses import dataclass
LEAFS = {
"leaf1": {"device_type": "cisco_nxos", "host": "10.0.0.11", "username": "admin", "password": "REDACTED"},
"leaf2": {"device_type": "cisco_nxos", "host": "10.0.0.12", "username": "admin", "password": "REDACTED"},
}
@dataclass
class PodInfo:
namespace: str
name: str
pod_ip: str
node: str
def list_pods():
config.load_kube_config()
v1 = client.CoreV1Api()
pods = []
for p in v1.list_pod_for_all_namespaces(watch=False).items:
if not p.status.pod_ip or not p.spec.node_name:
continue
pods.append(PodInfo(
namespace=p.metadata.namespace,
name=p.metadata.name,
pod_ip=p.status.pod_ip,
node=p.spec.node_name
))
return pods
def nxos_cmd(hostvars, commands):
with ConnectHandler(**hostvars) as conn:
return conn.send_multiline(commands)
def evpn_has_prefix(output, prefix):
# Very lightweight heuristic: look for prefix in EVPN route outputs.
# Improve by using TextFSM/Genie parsing or JSON output if supported.
return prefix in output
def nve_peer_health(output):
# Example parse: look for "Up" in peer table
up = len(re.findall(r"\bUp\b", output))
down = len(re.findall(r"\bDown\b", output))
return {"up": up, "down": down}
def main(target_pod_ip):
pods = list_pods()
matches = [p for p in pods if p.pod_ip == target_pod_ip]
if not matches:
raise SystemExit(f"Pod IP {target_pod_ip} not found in cluster")
pod = matches[0]
print(f"Target: {pod.namespace}/{pod.name} ip={pod.pod_ip} node={pod.node}")
commands = [
"show nve peers",
f"show bgp l2vpn evpn {target_pod_ip}",
f"show bgp vrf all ipv4 unicast {target_pod_ip}",
]
results = {}
for leaf, hv in LEAFS.items():
out = nxos_cmd(hv, commands)
results[leaf] = out
print(f"\n--- {leaf} ---")
print(out)
# Correlate: EVPN visibility asymmetry is a common root of “some paths fail”.
leaf_presence = {leaf: evpn_has_prefix(out, target_pod_ip) for leaf, out in results.items()}
peer_health = {leaf: nve_peer_health(out) for leaf, out in results.items()}
print("\n=== Correlation ===")
for leaf in LEAFS.keys():
print(f"{leaf}: evpn_prefix_present={leaf_presence[leaf]} nve_peers_up={peer_health[leaf]['up']} down={peer_health[leaf]['down']}")
if len(set(leaf_presence.values())) > 1:
print("\nALERT: EVPN route visibility differs across leafs (likely RT import/export, RR leak, or per-VRF filtering).")
else:
print("\nEVPN visibility appears consistent; move focus to MTU, underlay drops, policy, or conntrack.")
if __name__ == "__main__":
# Example usage: python3 correlate.py 10.244.12.34
import sys
if len(sys.argv) != 2:
raise SystemExit(f"Usage: {sys.argv[0]} <pod_ip>")
main(sys.argv[1])
Parsing tips that save time
- Prefer structured outputs when available:
- NX-OS:
| jsonexists for manyshowcommands; some EVPN outputs remain text-heavy. - If you can, use Cisco pyATS/Genie parsers for robust parsing at scale.
- Normalize keys early:
- Always record:
pod_ip,node,leaf,vrf,vni,vtep,rt(route-target). - Treat “control-plane looks fine” as a hypothesis, not a conclusion:
- Route present doesn’t guarantee correct MAC/IP binding, VNI, or next-hop resolution.
Real incident teardown: VXLAN EVPN BGP leak across leafs
Incident summary (symptoms)
- Only some pod-to-pod flows failed: pods on Node group A could not reach pods on Node group B.
- Failures were consistent (not transient), with TCP SYN timeouts.
- No Kubernetes NetworkPolicy changes in the window.
- The fabric had recently introduced a new tenant VRF and route-reflector policy change.
Step 1 — Confirm the failure and scope in Kubernetes
- Identify two failing pods and nodes:
bash kubectl -n app get pod -o wide # PodA on node-a-12, IP 10.244.12.34 # PodB on node-b-07, IP 10.244.55.89 - Validate node-level routing didn’t obviously break:
bash # On node-a-12 ip route get 10.244.55.89 ping -c 3 10.244.55.89
Observation: routing decision on the node looked normal (next-hop via CNI / overlay), but packets never completed.
Step 2 — Identify the fabric leafs for the two nodes
From your DCIM/automation inventory (or LLDP), map:
- node-a-12 uplinks to leaf101
- node-b-07 uplinks to leaf118
Step 3 — Check EVPN route presence on both leafs
On leaf101 (near source):
show bgp l2vpn evpn 10.244.55.89
Result: route exists (Type-5 or Type-2 depending on design), with a valid next-hop VTEP.
On leaf118 (near destination):
show bgp l2vpn evpn 10.244.12.34
Result: missing. That’s the “aha”: asymmetric EVPN control-plane visibility.
At this point, stop looking at kube-proxy, iptables, or policy until EVPN is consistent.
Step 4 — Prove it’s an RT import/export (or RR policy) problem
On both leafs, confirm the VNI/VRF mapping:
show nve vni
show run vrf
show run bgp | section evpn
What was found:
- The VRF for the Kubernetes overlay (example: VRF-K8S) used L3VNI 50010.
- leaf101 had correct route-targets:
- export target:65000:50010
- import target:65000:50010
- leaf118 had an incorrect import RT, due to a templating error:
- import target:65000:50001 (typo/old value)
Additionally, the route-reflector policy applied a community filter that allowed only the intended RTs—so routes were present on some leafs, absent on others (classic “leak”/filter mismatch behavior during partial rollout).
Step 5 — Validate NVE peer status (avoid chasing ghosts)
Even with RT mismatch, it’s useful to verify VXLAN adjacency is healthy:
show nve peers
show nve peers detail
Result: peers were Up, confirming underlay reachability wasn’t the primary issue.
Step 6 — Apply the fix (Cisco CLI) and confirm convergence
On leaf118, correct VRF RT import:
conf t
vrf context VRF-K8S
address-family ipv4 unicast
route-target import 65000:50010
no route-target import 65000:50001
address-family ipv6 unicast
route-target import 65000:50010
no route-target import 65000:50001
end
copy run start
If RR policy was involved (example conceptually; exact syntax depends on design):
- Ensure RR allows the 65000:50010 RT community.
- Re-deploy consistent route-map/policy across all RRs.
Step 7 — Confirm the fix in both control-plane and dataplane
On leaf118:
show bgp l2vpn evpn 10.244.12.34
show ip arp vrf VRF-K8S | include 10.244.12.34
Then re-test pod-to-pod:
kubectl -n app exec -it <podA> -- sh -c "nc -vz -w2 10.244.55.89 8080"
kubectl -n app exec -it <podB> -- sh -c "nc -vz -w2 10.244.12.34 8080"
Outcome: connectivity restored immediately after EVPN routes imported correctly and BGP reconverged.
Hardening and runbook automation
Detection heuristics to add to monitoring
Add monitors that detect “partial control-plane” conditions early—before apps report outages.
EVPN/VRF consistency checks
- For each VRF/L3VNI used by kubernetes:
- All leafs should have identical RT import/export sets.
- All leafs should receive a minimum expected number of Type-5 routes (or at least non-zero, plus trend).
- Alert on:
- EVPN route count deviating sharply on a subset of leafs.
- BGP EVPN session flap frequency on a single leaf.
- NVE peer down events correlated with underlay interface errors.
MTU and drops
- Alert on:
- Rising giants, fragmentation needed, or encapsulation-related drops.
- Spine/leaf interface microburst indicators if available.
Kubernetes node signals
- Node conntrack usage > 80%
- kube-proxy sync latency spikes
- CNI agent restarts / programming failures
Automated remediation playbooks (Ansible + CLI validation)
Use Ansible to enforce VRF RT consistency and verify EVPN route presence. This example is intentionally minimal; adapt to your inventory and platform modules.
---
- name: Enforce EVPN RT consistency for Kubernetes VRF
hosts: leafs
gather_facts: no
vars:
vrf_name: "VRF-K8S"
rt_value: "65000:50010"
tasks:
- name: Configure VRF RT import/export (NX-OS example)
cisco.nxos.nxos_config:
lines:
- "vrf context {{ vrf_name }}"
- "address-family ipv4 unicast"
- "route-target import {{ rt_value }}"
- "route-target export {{ rt_value }}"
- "address-family ipv6 unicast"
- "route-target import {{ rt_value }}"
- "route-target export {{ rt_value }}"
- name: Validate BGP EVPN summary
cisco.nxos.nxos_command:
commands:
- "show bgp l2vpn evpn summary"
register: evpn_sum
- name: Fail if EVPN sessions not established (basic heuristic)
ansible.builtin.fail:
msg: "EVPN summary indicates sessions not established"
when: "'Idle' in evpn_sum.stdout[0] or 'Active' in evpn_sum.stdout[0]"
Postmortem checklist (prevent recurrence)
- Config drift
- Are RTs/VNIs/VRFs centrally generated and validated?
- Is there a pre-deploy lint step that blocks inconsistent RTs across leafs?
- Change safety
- Was the RR policy rolled out atomically (or safely staged with dual RT import during migration)?
- Were “canary leafs” used with automated route-count comparisons?
- Observability
- Are EVPN route counts and per-leaf deviations monitored?
- Do you have a one-command “pod IP → leafs → EVPN route presence” tool?
- Runbook readiness
- Is there a documented escalation tree: Kubernetes → node → CNI → fabric?
- Are known-good MTU values documented end-to-end (pod veth to spine links)?
Common pitfalls
- Assuming it’s a CNI issue because it’s “pod networking”: EVPN RT mismatch and RR policy leaks commonly present as pod-to-pod failures.
- Checking only one leaf: Many incidents are asymmetric. Always validate on both ends (source leaf and destination leaf).
- Ignoring MTU until late: VXLAN + inconsistent MTU can masquerade as random drops/latency.
- Treating “BGP is up” as sufficient: Sessions up don’t mean the right routes are imported into the right VRFs/VNIs.
- No stable correlation key: Without mapping pod IP → node → leaf → VTEP/VNI/VRF, troubleshooting becomes guesswork.
- Manual-only workflows: CLI spot checks don’t scale; automate collection and compare across the fabric.
Key takeaways
- Advanced kubernetes pod-to-pod outages often sit at the intersection of CNI dataplane and EVPN/VXLAN fabric control-plane.
- Classify symptoms first (drops, latency, asymmetric routing, ARP/NDP) to narrow the layer quickly.
- Collect evidence across both Kubernetes (pods/nodes/CNI) and Cisco fabric (EVPN routes, NVE peers, ARP/ND, counters).
- Automate correlation: a small Python collector can rapidly detect asymmetries like “EVPN route present on leaf A but missing on leaf B.”
- Harden with monitoring for EVPN route-count deviations, RT consistency checks, and runbook automation to prevent partial-rollout failures.