← Back to Engineering Blog
πŸ—“οΈ Apr 12, 2022⏱️ 4 min read

Translating Kubernetes NetworkPolicies to NSX-T Distributed Firewall Rules

Why guest OS container CNIs create security blind spots, and how NCP CNI translates Kubernetes NetworkPolicy YAML into hypervisor-level Distributed Firewall rules.

πŸŽ™οΈ Listen to ArticleREADY
AI Audio Synthesis Narrator
Share Post:

β€œRunning Kubernetes inside virtual machines creates a dangerous security blind spot if pod traffic is handled purely by in-guest CNI plugins. NSX Container Plugin (NCP CNI) translates Kubernetes NetworkPolicies directly into hypervisor-level Distributed Firewall rules.”

In April 2022, during my tenure as Systems Integration Advisor at NTT Data, we were architecting an enterprise Kubernetes platform for a major banking client.

The application architecture featured 30 Kubernetes clusters running high-volume payment processing microservices across VMware vSphere virtual machine worker nodes.

The client’s Chief Information Security Officer (CISO) handed down a non-negotiable security requirement:

Enforce strict Zero-Trust microsegmentation between individual Kubernetes pod namespaces (payment-prod, analytics-dev, auth-service), and provide centralized security auditability.


The In-Guest CNI Blind Spot

The initial Kubernetes deployment used a standard open-source CNI plugin (Flannel with Calico iptables policy enforcement).

Application developers wrote standard Kubernetes NetworkPolicy YAML manifests to restrict traffic between pods.

On paper, the policies worked inside the Linux guest kernel.

To the enterprise Security Operations Center (SOC) monitoring the infrastructure, however, container pod traffic was completely invisible.

Because standard CNIs process packets inside the guest OS of the worker node virtual machines:

  1. Zero Hypervisor Visibility: The hypervisor saw all container traffic coming from the worker node VM’s single physical IP (10.100.20.15), masking individual pod identities (172.16.1.42).
  2. Guest OS Compromise Risk: If an attacker exploited a container vulnerability and gained root access on the Linux worker node VM, he could flush the local iptables rules and compromise every pod running on that host!

The SOC team panicked and tried to mandate manual ticket requests for every container deployment. Deployment velocity ground to a halt.


The Mess: The 50-Page Spreadsheet Security Review

The security team attempted to maintain a 50-page manual spreadsheet mapping container pod labels to static IP addresses.

Every time a developer deployed a new microservice pod scaling event:

# Developer scales pods from 3 to 20 replicas:
kubectl scale deployment/payment-api --replicas=20
# Result: 17 new pod IPs generated dynamically. Manual security spreadsheet outdated in 3 seconds!

Because Kubernetes pods spin up and die dynamically in seconds, static security spreadsheets and traditional perimeter firewall rules were completely useless.

The SOC team threatened to halt the entire cloud-native migration project unless pod traffic was rendered visible and auditable inside NSX-T Manager.


The Solution: Automated NCP CNI DFW Translation

We solved the visibility gap and unblocked developer pipelines by replacing the generic CNI plugin with the NSX Container Plugin (NCP CNI).

NCP runs as an automated controller daemon inside the Kubernetes control plane, watching the Kubernetes API for NetworkPolicy, Namespace, and Pod events.

# NCP CNI Automated Policy Translation Architecture

1. **Developer Action:** Pushes a native Kubernetes `NetworkPolicy` YAML file via `kubectl apply`.
2. **NCP Interception:** NCP CNI intercepts the policy object and extracts pod labels (`role: db`, `role: frontend`).
3. **Hypervisor DFW Sync:** NCP translates the YAML policy into native **NSX-T Distributed Firewall (DFW)** rules executed directly inside the ESXi hypervisor kernel (`vnic-tx/rx`).
# Kubernetes NetworkPolicy Automatically Synced to NSX-T DFW
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: restrict-db-access
  namespace: payment-prod
spec:
  podSelector:
    matchLabels:
      role: db
  ingress:
    - from:
        - podSelector:
            matchLabels:
              role: frontend
      ports:
        - protocol: TCP
          port: 5432
# Querying the translated NSX-T DFW rule via REST API
GET https://nsx-manager.sddc.lab/policy/api/v1/infra/domains/default/security-policies/k8s-payment-prod
{
  "display_name": "k8s-payment-prod-restrict-db-access",
  "rules": [
    {
      "action": "ALLOW",
      "source_groups": ["/infra/domains/default/groups/k8s-pod-role-frontend"],
      "destination_groups": ["/infra/domains/default/groups/k8s-pod-role-db"],
      "services": ["/infra/services/TCP-5432"]
    }
  ]
}

Why Hypervisor Enforcement Defends Against Root Exploits

Because NCP CNI pushes the translated rules down to the ESXi hypervisor kernel (vnic-tx/rx):

  • Security enforcement happens outside the guest OS.
  • Even if an attacker gains root privileges inside a Linux worker node VM and flushes iptables, the ESXi hypervisor kernel continues blocking unauthorized pod-to-pod traffic on the wire!
  • The SOC team gets 100% real-time visibility into pod flow logs inside NSX-T Manager and vRealize Network Insight (vRNI) without developer intervention.

The Impact

  • 100% Policy Automation: Eliminated manual security review tickets; NetworkPolicy YAML files sync to NSX-T DFW in sub-seconds.
  • Hypervisor-Enforced Security: Delivered true Zero-Trust isolation between container pods outside the guest OS boundary.
  • SOC Visibility: Provided full microservice flow tracing and audit compliance for regulatory banking requirements.

Key Takeaway

Enforce Kubernetes Pod Microsegmentation at the Hypervisor Layer.

Do not rely on guest OS in-container CNI plugins for critical security compliance. Deploy NSX Container Plugin (NCP CNI) to translate developer-native Kubernetes NetworkPolicy YAML files into hypervisor-level NSX-T Distributed Firewall (DFW) rules, protecting container workloads even if worker node virtual machines are compromised.


Architecture and decisions: mine. Debugging sessions at odd hours: mine. AI assistance: structure, syntax, first draft. β€” Sachin

SKS

Sachin Kumar Sharma

Associate Director (Infrastructure & Cloud Architecture Strategy) | 20+ Yrs Exp

Architecting resilient multi-cloud enterprise landing zones, SDN overlay fabrics, DevSecFinOps automation pipelines, and autonomous Agentic AI platforms.

πŸ“¬

πŸ“¬ Stay Updated on Tech Releases

Sign up to get notified when I publish new production war stories, agentic AI architecture blueprints, or open-source infrastructure tools.

⚑ Theme Adaptive Shift
Switching layouts matching domain reading affinity...