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-avirtual machine,ConfigurationandNetwork, verify it’s usingexercise10-nadas secondary network
-
Click on
exercise10-bvirtual machine,ConfigurationandNetwork, verify it’s usingexercise10-nadas secondary network
-
On left side menu click
Networking→NetworkAttachmentDefinition
-
Click
exercise10-nadand check it’s usingLinux Bridge
-
O left side menu click
Networking→NodeNetworkConfigurationPolicyand verify that it is empty
-
O left side menu click
Networking→NodeNetworkConfiguration-→ click on thelistbutton on the top right, and check there’s alinux bridgeinterface on nodes
-
Click
linux bridge→br-userx
-
Verify that there are only
vethinterfaces. It means that there is no physical network attached on thislinux bridge
-
On left side menu click
Networking→NetworkAttachmentDefinitionsandCreate Network Attachment Definitionbutton.
-
Type
exercise10-nad-layer2as name and selectOVN Kubernetes L2 overlay networkonNetwork Typeand click onCreatebutton
-
On left side menu click
Virtualization→VirtualMachinesand stop virtual machineexercise10-a
-
On left side menu click
Virtualization→VirtualMachinesand stop virtual machineexercise10-b
-
Click on
exercise10-avirtual machine,ConfigurationandNetwork,
-
Edit the virtual machine network
-
Change
Networkfromexercise10-nadtoexercise10-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
occommand 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
br-userxinterface. Verify that thisLinux bridgeis 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 uselayer2networking instead ofLinux bridge. Createlayer2-nad.yamland apply it.
oc get nns -o yaml | grep -A 2 -B 73 br-userx | 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.