Enabling VM communication - Part 1
Scenario
The virtual machines exercise10-a
and exercise10-b
are operational and with their IP addresses correctly configured. However, they are not communicating with each other as expected.
|
The steps to fix exercise10 are:
Console
-
Login to Openshift console using the assigned user account
userx
{password}
-
Go to virtualization → Virtual Machines - select project for the assigned user account
-
Click on
exercise10-a
virtual machine,Configuration
andNetwork
, verify it’s usingexercise10-nad
as secondary network
-
Click on
exercise10-b
virtual machine,Configuration
andNetwork
, verify it’s usingexercise10-nad
as secondary network
-
On left side menu click
Networking
→NetworkAttachmentDefinition
-
Click
exercise10-nad
and check it’s usingLinux Bridge
-
O left side menu click
Networking
→NodeNetworkConfigurationPolicy
and verify that it is empty
-
O left side menu click
Networking
→NodeNetworkState
and check there’s alinux bridge
interface on nodes
-
Click
linux bridge
→br10
-
Verify that there are only
veth
interfaces. It means that there is no physical network attached on thislinux bridge
-
On left side menu click
Networking
→NetworkAttachmentDefinitions
andCreate Network Attachment Definition
button.
-
Type
exercise10-nad-layer2
as name and selectOVN Kubernetes L2 overlay network
onNetwork Type
and click onCreate
button
-
On left side menu click
Virtualization
→VirtualMachines
and stop virtual machineexercise10-a
-
On left side menu click
Virtualization
→VirtualMachines
and stop virtual machineexercise10-b
-
Click on
exercise10-a
virtual machine,Configuration
andNetwork
,
-
Edit the virtual machine network
-
Change
Network
fromexercise10-nad
toexercise10-nad-layer2
-
Start the virtual machine
exercise10-a
Repeat steps 15, 16, 17, and 18 for the exercise10-b
virtual machine
lab grade exercise10
Command line (CLI)
-
Login to Openshift server API using the assigned user account with
oc
command if not logged in.
{login_command}
-
Go to the assigned namespace-userx
oc project namespace-userx
-
List the virtual machines
oc get virtualmachine
-
Check the virtual machines are running on different nodes
oc get pods -o wide
-
Check communication is not working
virtctl ssh lab-user@exercise10-a \
-c 'ping -c 5 192.168.0.11'
-
Get the secondary network used on vms a and b
oc get vmi exercise10-a -n namespace-userx \
-o jsonpath='{.spec.networks[?(@.multus)].multus.networkName}'
oc get vmi exercise10-b -n namespace-userx \
-o jsonpath='{.spec.networks[?(@.multus)].multus.networkName}'
-
Get the secondary network yaml
oc get network-attachment-definitions.k8s.cni.cncf.io exercise10-nad -o yaml
-
Ensure that the NaD (NetworkAttachmentDefinition) is configured to use a
br10
interface. Verify that thisLinux bridge
is not attached to any physical port (one or more veth* port are used), meaning virtual machines will only be able to communicate if they are running on the same node. Therefore, you must recreate the NaD to uselayer2
networking instead ofLinux bridge
. Createlayer2-nad.yaml
and apply it.
oc get nns -o yaml | grep -A 2 -B 73 br10 | grep -A4 port
vim layer2-nad.yaml
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: exercise10-nad-layer2
namespace: namespace-userx
spec:
config: '{"name":"exercise10-nad-layer2","type":"ovn-k8s-cni-overlay","cniVersion":"0.3.1","topology":"layer2","netAttachDefName":"namespace-userx/exercise10-nad-layer2"}'
oc apply -f layer2-nad.yaml
-
shutdown the virtual machines exercise10-a and exercise10-b
virtctl stop exercise10-a
virtctl stop exercise10-b
-
change the virtual machines secondary network
oc patch vm exercise10-a -n namespace-userx --type='json' \
-p='[{"op": "replace", "path": "/spec/template/spec/networks/1/multus/networkName", "value": "exercise10-nad-layer2"}]'
oc patch vm exercise10-b -n namespace-userx --type='json' \
-p='[{"op": "replace", "path": "/spec/template/spec/networks/1/multus/networkName", "value": "exercise10-nad-layer2"}]'
11.Start the virtual machines
virtctl start exercise10-a
virtctl start exercise10-b
-
After virtual machines starts wait some time and check the communication again
virtctl ssh lab-user@exercise10-a \
-c 'ping -c 3 192.168.0.11'
What you learned
In this exercise, you learned that to enable communication between virtual machines, a secondary network using OVN layer2
must be configured instead of a Linux Bridge
.
The OVN localnet
and Linux Bridge
options are not viable because no NodeNetworkConfigurationPolicy
has been defined, which means the bridge does not have a physical port attached.