Flannel — Commands & Recipes
Installation
# Install Flannel on K8s (standard)
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
# Install with custom CIDR
kubectl apply -f - <<EOF
kind: ConfigMap
apiVersion: v1
metadata:
name: kube-flannel-cfg
namespace: kube-flannel
data:
net-conf.json: |
{
"Network": "10.244.0.0/16",
"EnableIPv6": false,
"Backend": {
"Type": "vxlan"
}
}
EOF
Backend Configuration
// VXLAN (default)
{ "Type": "vxlan" }
// host-gw (best performance, requires same L2)
{ "Type": "host-gw" }
// WireGuard (encrypted)
{ "Type": "wireguard" }
Diagnostics
# Check flannel pods
kubectl get pods -n kube-flannel
# View subnet allocation
kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.podCIDR}{"\n"}{end}'
# Flannel logs
kubectl logs -n kube-flannel -l app=flannel -f
# Check VXLAN interface
ip -d link show flannel.1
# Check routes
ip route show | grep flannel
Sources