[BUG] NSG Rules Override Calico Network Policies in Azure CNI Overlay Setup in Multitenant AKS Cluster
Describe the bug Cluster Setup Overview
We are running a multitenant AKS cluster with the following configuration:
Network Plugin: Azure CNI Overlay Network Policy: Calico Node Pools: Each tenant has a dedicated user node pool, each in its own subnet. Namespaces: Each tenant gets multiple namespaces scheduled exclusively on their node pool using taints and tolerations. Security Layers: Calico Network Policies: Enforced at the Kubernetes network layer. NSG Rules: Enforced at the subnet level to provide an additional layer of protection.
Calico Network Policy Behavior
We have a default deny global network policy that blocks all inter-namespace traffic. Teams must explicitly allow traffic between namespaces using Calico network policies. This works as expected at the Kubernetes layer.
Expected behavior
NSG Configuration: System Node Pool Subnet: NSG allows full access. User Node Pool Subnets: NSG allows only intra-subnet traffic. Goal: Use NSG to block traffic between subnets (i.e., between tenant node pools), even if Calico allows it — enforcing a second layer of isolation.
Environment
- Kubernetes version: 1.32.2
Additional context Observed Behaviour:
- Scenario 1: In NSG Rule, Allow traffic between Node Pool A Subnet and Node Pool B Subnet. Calico policy is allow. Results: Traffic is blocked
- Scenario 2: In NSG Rule, Allow traffic between Pod CIDRs of Node A and Node B. Calico policy is allow. Results: Traffic allowed, but Calico policy is bypassed.
- In Scenario 2, allowing Pod CIDRs in NSG enables traffic regardless of Calico policies, effectively bypassing Kubernetes-level controls. This is not expected, as we assumed NSG would operate only at the subnet level, not at the Kubernetes Pod CIDR level.
Challenges: Each node gets a dynamic /24 Pod CIDR. Managing NSG rules for dynamically assigned Pod CIDRs is not scalable. We want Calico to remain authoritative at the Kubernetes layer, and NSG to act as a coarse-grained subnet-level control.
Question Is it possible to achieve two distinct layers of network control in Azure CNI Overlay mode:
- Calico for fine-grained, namespace-level traffic control.
- NSG for coarse-grained, subnet-level isolation between node pools.
If not, is there a recommended approach to enforce both layers without NSG rules unintentionally overriding Calico policies?
Reference: We followed the guidance here: https://learn.microsoft.com/en-us/azure/aks/azure-cni-overlay?tabs=kubectl#network-security-groups
Can someone look into this bug?
@danbosscher Can you please provide an update on this issue?
Hi Team,
I have by mistakenly closed the issue. I want the stale label to be removed and somehow actively check it.
@danbosscher Could you help with the issue?
Hi @AAFAYZ - having a look now. @sf-msft and I will get back to you shortly.
In an overlay you can't use nsgs to restrict pod communication between pods on different node pools because the overlay pod cidr is shared. You have to use node subnet or podsubnet if that is your goal.
But you should still be able to use cilium (or calico or azure npm) though to block access in overlay pods . we test the former most thoroughly and don't actually test CalicoNetworkPolciies at all just regulr netpols for calico)
if you are seeing nsg bypassing standard network policies file a support ticket on a particular cluster so we can takea closer look? Need to be able to see nsg setup and the policies you're using.
Hi there :wave: AKS bot here. This issue has been tagged as needing a support request so that the AKS support and engineering teams have a look into this particular cluster/issue.
Follow the steps here to create a support ticket for Azure Kubernetes Service and the cluster discussed in this issue.
Please do mention this issue in the case description so our teams can coordinate to help you. When you have created the support ticket, please add the case number as a comment to this issue to help us with tracking.
Thank you!
This issue will now be closed because it hasn't had any activity for 7 days after stale. @AAFAYZ feel free to comment again on the next 7 days to reopen or open a new issue after that time if you still have a question/issue or suggestion.