- Cluster one runs Flannel.
- Cluster two runs Canal (Flannel + Calico).
What Flannel does
Flannel (originally from CoreOS) is designed for simplicity. It creates an overlay network so Pods behave as if they are on the same flat network even when they live on different nodes. Because Flannel runs on top of the host network, it’s easy to set up and doesn’t require special hardware. However, Flannel by itself does not implement NetworkPolicy enforcement. That means NetworkPolicy objects you create in the Kubernetes API server are only effective if a CNI datapath that supports policy enforcement is present (for example, Calico or Cilium).NetworkPolicy objects are API resources only. They only take effect if the underlying CNI plugin (or an additional datapath) enforces them. If the CNI lacks policy enforcement, policies are accepted by Kubernetes but do nothing.
What Canal is
Canal packages two pieces:- Flannel — provides the simple overlay network.
- Calico — provides policy enforcement and other datapath features.
Bob’s experiment (reproducible steps)
Bob uses identical workloads and tests on both clusters. The only difference is the installed CNI:- Deploy two nginx Pods in the
defaultnamespace on each cluster.- Cluster one: Pods named
KodeKloudandCommunity. - Cluster two: Pods named
AlphaandBeta.
- Cluster one: Pods named
- Test connectivity by running curl from one Pod to the other Pod’s IP.
- Apply a
deny-allNetworkPolicy to thedefaultnamespace on both clusters. - Re-run the same curl tests.
The deny-all NetworkPolicy
Bob applies the same policy YAML to both clusters:podSelector: {}selects all pods in the namespace.policyTypesincludes bothIngressandEgressso the policy governs incoming and outgoing traffic.- Empty
ingress: []andegress: []effectively allow no traffic to/from the selected pods.
Key questions Bob wants to answer
- What is the role of the CNI?
- The CNI standardizes how container networking is configured. Individual CNI plugins implement datapath behavior and may optionally enforce NetworkPolicy.
- Which plugin is running on cluster one?
- Flannel.
- Which plugin actually enforces NetworkPolicy?
- Calico (or another policy-capable CNI such as Cilium) enforces NetworkPolicy. Flannel on its own does not.
Quick comparison
Expected vs. actual behavior
- Before the
deny-allpolicy: curl tests should succeed on both clusters (Kubernetes allows pod-to-pod traffic by default). - After applying
deny-all:- On the Canal cluster (Flannel + Calico): NetworkPolicy enforcement should block the curl requests.
- On the Flannel-only cluster: Because Flannel does not enforce NetworkPolicy, the curl requests may still succeed even though the
deny-allobject exists in the API.
Applying a NetworkPolicy object does not guarantee traffic is blocked. If your cluster’s CNI plugin does not implement policy enforcement, the NetworkPolicy resource will be ignored at datapath time. Always verify behavior after applying policies.
deny-all is applied, will curl still return the welcome page? The answer depends on whether the CNI enforces NetworkPolicy—on Flannel-only it likely will, on Canal it should not.