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.
The solution provides:–
Important Prerequisites:-
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
‘
User Story
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.
Important Note
By default, OpenShift Virtualization VMs connected to secondary networks do not have any MultiNetworkPolicy applied.
Without a policy:
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.
Since no MultiNetworkPolicy was applied at that stage, all inbound and outbound traffic was allowed by default on the secondary network, making the VM services externally reachable without any restrictions.
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.
Red Hat OpenStack Services on OpenShift (RHOSO) provides the foundation to build a private or public…
Kubernetes (often shortened to “K8s”) is an open-source system for automating the deployment, scaling, and…
Ceph is an open-source, distributed storage platform that provides object, block, and file storage in…
Prerequisites Red Hat OpenShift cluster deployed and operational You can refer to my earlier post…
Agent-Based Installation The Agent-based installation method provides the flexibility to boot your on-premise servers in…
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…