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.

Share
Published by
Dineshreddy Kayithi

Recent Posts

Red Hat OpenStack Services on OpenShift (RHOSO)

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

1 month ago

Kubernetes Cluster Deployment

Kubernetes (often shortened to “K8s”) is an open-source system for automating the deployment, scaling, and…

2 months ago

Ceph cluster on a single machine

Ceph is an open-source, distributed storage platform that provides object, block, and file storage in…

2 months ago

vSphere to OpenShift VM Migration

Prerequisites Red Hat OpenShift cluster deployed and operational You can refer to my earlier post…

2 months ago

Installing OpenShift 4.21 in an air-gapped on-premises/BareMetal environment using Agent-based deployment

Agent-Based Installation The Agent-based installation method provides the flexibility to boot your on-premise servers in…

4 months ago

OpenShift Virtualization Configuration, Secondary VM Network Setup, and Live Migration configuration

You can check the earlier post regarding cluster setup and ODF setup https://kdinesh.in/deployment-of-openshift-4-20-with-using-the-assistant-installer/ https://kdinesh.in/openshiftodf/ Login…

6 months ago