RedHat

Red Hat OpenShift VM Micro-segmentation Using MultiNetworkPolicy


OpenShift Virtualization allows virtual machines (VMs) to run natively on Kubernetes alongside container workloads. Using Multus CNI, VMs can attach to secondary networks such as VLAN-backed networks to communicate directly with the physical network infrastructure.

MultiNetworkPolicy extends Kubernetes Network Policy functionality to these secondary networks, enabling administrators to implement workload-level micro segmentation and enforce granular traffic control for virtual machines and pods.

  • VM-level micro segmentation
  • Least-privilege network access
  • Kubernetes-native policy enforcement
  • OVN-Kubernetes distributed ACL enforcement
  • North-south traffic control
  • East-west traffic isolation capabilities

1. Secondary Network Must Use OVN-Kubernetes


MultiNetworkPolicy is supported only with OVN-Kubernetes secondary networks.


If the secondary network is created using Linux bridge, MultiNetworkPolicy not supported.



2. Enable MultiNetworkPolicy on OpenShift Cluster


Enable MultiNetworkPolicy support cluster-wide:


oc patch networks.operator.openshift.io cluster –type=merge -p ‘


spec:


useMultiNetworkPolicy: true


‘




As a virtual machine administrator, I want virtual machines connected to a secondary VLAN network (vlan20-net) to allow only approved application traffic (TCP/80) for both ingress and egress communication while blocking all other traffic, so that workloads are securely isolated and only authorized communication is permitted.

By default, OpenShift Virtualization VMs connected to secondary networks do not have any MultiNetworkPolicy applied.


Without a policy:

  • All ingress traffic is allowed
  • All egress traffic is allowed
  • Any reachable port/service remains accessible

The virtual machine vm1 was successfully deployed and connected to the secondary VLAN network (vlan20-net). After the VM was up and running, both the Apache HTTP server (httpd) and Cockpit management service were installed and enabled.



From the jump box located outside the OpenShift cluster, I was able to access both the Cockpit management console on port 9090 and the Apache HTTP service on port 80 running on the vm1 virtual machine.




Let’s create a MultiNetworkPolicy to block all traffic by default and allow only the required application ports. You can also download the sample policy YAML file from the Git repository provided below and customize it based on your environment and security requirements.

https://github.com/Dineshk1205/MultiNetworkPolicy.git




Apply network policy file.


oc apply -f policy.yaml



The policy was applied successfully. You can also validate the policy configuration from the OpenShift web console UI or CLI . In addition to CLI-based management, MultiNetworkPolicy objects can also be created and managed directly through the OpenShift UI.





After applying the policy, only the HTTP service running on port 80 remained accessible. Access to the Cockpit service on port 9090, along with all other inbound and outbound traffic, was successfully blocked based on the MultiNetworkPolicy rules.



Dineshreddy Kayithi

Rooted in a solid academic foundation with a Bachelor's Degree in Information Technology, my career has been deeply entrenched in designing, deploying, and managing enterprise-grade infrastructure across virtualization, cloud-native, and containerized environments. Industry certifications from VMware, AWS, Microsoft, and Kubernetes validate my hands-on expertise in architecting scalable, resilient systems spanning hypervisors, public/hybrid cloud platforms, and container orchestration frameworks. I'm driven by a relentless pursuit of emerging technologies — translating them into production-ready solutions that solve complex operational challenges.

Recent Posts

NVIDIA RAG Pipeline: Deploying on Your Own Kubernetes Platform

Retrieval-Augmented Generation (RAG) is a way of getting an LLM to answer questions using your…

3 weeks ago

OpenStack Multi-Node Deployment — Kolla-Ansible 2026.1

Kolla-Ansible is an official OpenStack project and a production-recommended deployment method. Ubuntu 24.04 · 3…

1 month ago

NVIDIA Base Command Manager Deployment

NVIDIA Base Command Manager (BCM) provides cluster management software for streamlining cluster provisioning, workload management,…

1 month ago

Canary Deployments on OpenShift with GitOps: A Practical Walkthrough

Shipping a new version of an application is always a small act of faith. Even…

2 months ago

OpenShift VM Backup and Restore

The following steps demonstrate how to back up and restore an OpenShift virtual machine using…

3 months ago

Red Hat OpenStack Services on OpenShift (RHOSO)

Red Hat OpenStack Services on OpenShift (RHOSO) provides the foundation to build a private or public…

6 months ago