Skip to main content
RunBook Academy

KubernetesCXI · Kubernetes Networking Advanced TopicsAdvanced networking

Network anti-patterns — the most common mistakes

Advanced⏱ ~16 minkubectlcilium-cli

What you'll learn

  • Identify the most common network anti-patterns
  • Explain why each anti-pattern is a problem
  • Apply the fixes for each anti-pattern
  • Build the operational discipline of avoiding network anti-patterns

Prerequisites

Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16

Not yet marked complete on this device.

Network anti-patterns are the most common mistakes when configuring Kubernetes networking. This lesson walks the anti-patterns, the fixes, and the operational discipline.

Anti-pattern 1: Default-allow NetworkPolicy

flowchart LR
    A[Cluster without NetworkPolicy] --> B[Every Pod talks to every Pod]
    B --> C[Production talks to dev]
    B --> D[Backend talks to frontend's DB]
    A --> E[No isolation]

The intent is “get things working first”; the result is no isolation.

The fix: default-deny NetworkPolicy in every namespace, with explicit allow rules.

Anti-pattern 2: Cilium without Hubble

# Anti-pattern
helm install cilium cilium/cilium --version 1.16.0 \
  # No Hubble enabled

The intent is “minimal install”; the result is no L7 visibility or flow logs.

The fix: enable Hubble from the start. Hubble is the observability layer for Cilium.

Anti-pattern 3: Single CNI choice without testing

# Anti-pattern: install CNI without testing alternative
kubectl apply -f https://docs.cilium.io/install

The intent is “use the popular one”; the result is no fallback if the CNI has a bug or incompatibility.

The fix: test multiple CNIs in staging; have a documented migration path.

Anti-pattern 4: No BGP on bare metal

flowchart LR
    A[Bare metal cluster] --> B[LoadBalancer Service]
    B --> C{Cloud provider?}
    C -->|No| D[No external IP]
    D --> E[Users can't reach]
    A --> F[Need BGP]
    F --> G[MetalLB or Cilium BGP]

The intent is “use NodePort”; the result is poor performance and operational complexity.

The fix: install MetalLB or Cilium BGP for LoadBalancer Service advertisement.

Anti-pattern 5: No IPv6 planning

# Anti-pattern: install kubeadm with IPv4-only
kubeadm init --pod-network-cidr=10.244.0.0/16

The intent is “IPv6 not needed yet”; the result is a later migration when IPv6 becomes a requirement.

The fix: install with dual-stack from the start, even if the workloads are IPv4-only. Migration to dual-stack after the fact is harder.

Anti-pattern 6: Custom CNI scripts

# Anti-pattern
#!/bin/bash
# Custom CNI configuration script
ip link add ...
ip addr add ...
iptables -A ...

The intent is “exactly what we need”; the result is a debugging nightmare when things break.

The fix: use a supported CNI (Cilium, Calico). Custom CNI scripts are unsupported and undebuggable.

Anti-pattern 7: No NetworkPolicy documentation

# Anti-pattern: NetworkPolicy exists but is not documented
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: ???
spec:
  podSelector: {}

The intent is “the rules are obvious”; the result is rules that rot because no one understands them.

The fix: document every NetworkPolicy in the runbook. Each policy should have a name that describes its purpose, comments in the YAML, and a runbook entry.

Quiz

Knowledge check · 4 questions

  1. Q1. Why is a cluster with no NetworkPolicy at all a security problem?

  2. Q2. A NetworkPolicy that selects Pods but specifies no ingress rules denies all ingress to them.

  3. Q3. Introduce default-deny isolation into a running namespace without breaking the workloads in it.

    The prod-app namespace has never had a NetworkPolicy. A security review shows that any Pod in it can open a connection to the Postgres StatefulSet in prod-data, and that a compromised log-shipping sidecar did exactly that last month. The namespace runs 14 Deployments; frontend talks to api on 8080, api talks to Postgres on 5432, and everything resolves Service names through CoreDNS.

  4. Q4. Give the podSelector and policyTypes of a NetworkPolicy that denies all ingress and egress in a namespace, and name the one rule that must be added immediately afterwards.

Passing score: 75%. Answers are checked in this browser.

The operational discipline

Network anti-patterns in production rest on five non-negotiable elements:

  • Default-deny NetworkPolicy. Every namespace starts with deny-all + explicit allow.
  • Cilium with Hubble enabled. Observability is the primary benefit.
  • Test CNI alternatives. Have a documented migration path.
  • BGP for bare metal. MetalLB or Cilium BGP.
  • Document every NetworkPolicy. In the runbook.

Networking is production infrastructure. The discipline is to choose the CNI deliberately, enable observability, and document every policy.