Flannel (Default CNI)

k3s ships with Flannel to give every Pod an IP address on a flat cluster network.

Kubernetes needs a CNI (Container Network Interface) plugin so Pods can talk to each other. k3s bundles Flannel and configures it automatically, using a VXLAN overlay by default.

What Flannel gives you

  • Every Pod gets a unique IP from the cluster CIDR (default 10.42.0.0/16).
  • Pods on different nodes can reach each other directly.
  • No manual setup — it just works after install.

If you prefer a different CNI such as Calico or Cilium, start the server with --flannel-backend=none and install your own.

Example

Example · bash
# See the Pod network in action
kubectl get pods -A -o wide

# Pod IPs come from the 10.42.0.0/16 range by default
# To disable Flannel and bring your own CNI:
# k3s server --flannel-backend=none --disable-network-policy

When to use it

  • A team relies on Flannel's VXLAN backend to provide pod-to-pod connectivity across three physical hosts without any extra CNI setup.
  • An operator switches the Flannel backend from VXLAN to host-gw on a flat L2 network to reduce encapsulation overhead for latency-sensitive workloads.
  • A developer troubleshoots pod networking by inspecting the Flannel subnet config to verify that each node received a unique /24 pod CIDR.

More examples

Verify Flannel pods are running

Checks that the Flannel DaemonSet pods are Running on every node and inspects recent logs for errors.

Example · bash
kubectl get pods -n kube-system -l app=flannel
kubectl logs -n kube-system -l app=flannel --tail=20

Inspect pod CIDR allocation

Shows the pod CIDR assigned to each node by Flannel, confirming there are no overlaps.

Example · bash
kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.podCIDR}{"\n"}{end}'

Change Flannel backend to host-gw

Installs k3s with the host-gw Flannel backend, which routes traffic directly between nodes without VXLAN encapsulation.

Example · bash
curl -sfL https://get.k3s.io | \
  INSTALL_K3S_EXEC='--flannel-backend=host-gw' sh -
kubectl get nodes -o wide

Discussion

  • Be the first to comment on this lesson.