Enabling VM communication - Part 2

Scenario

The virtual machines exercise11-a and exercise11-b are operational and with their IP addresses configured. However, they are not communicating with each other as expected.

  • Virtual Machine exercise11-a IP’s addresses

11 break1
  • Virtual Machine exercise11-b IP’s addresses

11 break2
  • ping from exercise11-a to exercise11-b is not working.

11 break3
  • Your task is to identify and troubleshoot the issue preventing communication between the VMs. Resolve it to restore connectivity.

  • You can recreate any virtual machine if needed

  • Do not edit nothing inside the guest OS

The steps to fix exercise11 are:

Console

  1. Login to Openshift console using the assigned user account

Username
userx
Password
{password}
  1. Go to Virtualization - VirtualMachines and check the virtual machines IP addresses

11 break0
  1. Verify exercise11-a IP address

11 break1
  1. Verify exercise11-b IP address

11 break2
  1. Click on exercise11-a Virtual machine, open Console, login with user lab-user and password redhat1. Try to ping and verify it’s not working.

11 break4
  1. On exercise11-a virtual machine, click on ConfigurationInitial run

11 break5
  1. Click edit

11 break6
  1. Verify the IP address is configured as cloud-init.

11 break7
  1. Perform the same steps to exercise11-b virtual machine and verify that this IP address was misconfigured using a /32 netmask, which must be fixed.

11 break8
  1. Click on YAML tab and Download the yaml file. It will be used to recreate the virtual machine with the correct netmask.

11 break9
  1. Click ActionsDelete to delete the exercise11-b virtual machines

11 break10
  1. Click Delete

11 break11
  1. Wait for exercise11-b to be deleted.

11 break12
  1. Click + button to create a new virtual machine using the YAML downloaded on step 9.

11 break13
  1. Paste the YAML content and edit the IP configured to this VM from 192.168.0.11/32 to 192.168.0.11/24

11 break14
  1. Wait for exercise11-b Virtual Machine be recreated and verify that communication os working.

11 break15
Run grade to validate the exercise
lab grade exercise11

Command line (CLI)

  1. Login to Openshift server API using the assigned user account with oc command if not logged in.

OpenShift login command
{login_command}
  1. Go to the assigned namespace-userx

oc project namespace-userx
  1. List the virtual machines

oc get virtualmachine
  1. Verify the communication is not working

virtctl ssh lab-user@exercise11-a \
-c 'ping -c 3 192.168.0.11'
  1. Check the virtual machine exercise11-a and exercise11-b are with IP configured

virtctl ssh lab-user@exercise11-a \
-c 'ip -4 addr show dev eth1'
virtctl ssh lab-user@exercise11-b \
-c 'ip -4 addr show dev eth1'
  1. Check the virtual machines are configured with static IP on CRD VirtualMachine with cloud-init

oc get vmi exercise11-a -n namespace-userx \
-o jsonpath='{.spec.volumes[?(@.cloudInitNoCloud)].cloudInitNoCloud.networkData}'
oc get vmi exercise11-b -n namespace-userx \
-o jsonpath='{.spec.volumes[?(@.cloudInitNoCloud)].cloudInitNoCloud.networkData}'
  1. The issue is with the exercise11-b virtual machine, which is incorrectly configured with a /32 subnet mask but should be using a /24 subnet mask. Since the IP address is set using cloud-init, the virtual machine must be recreated to correct the configuration. Before recreating the virtual machine, use the command to save exercise11-b, removing some unnecessary fields.

oc get virtualmachine exercise11-b -o yaml |\
sed -e '/managedFields:/,/^[^ ]/d' \
-e '/creationTimestamp:/d' -e '/resourceVersion:/d' \
-e '/uid:/d' -e '/status:/,/^[^ ]/d' > exercise11-b.yaml
  1. Edit the IP on YAML file and change from /32 to /24.

vim exercise11-b.yaml
  1. Delete exercise11-b virtual machine

oc delete virtualmachine exercise11-b
  1. Apply the edited YAML file

oc apply -f exercise11-b.yaml
  1. Check the communication is working again

virtctl ssh lab-user@exercise11-a \
-c 'ping -c 3 192.168.0.11'

What you learned

In this exercise, you learned that to modify any cloud-init configuration defined in a VirtualMachine manifest, you must recreate the virtual machine. This is because cloud-init only executes during the first boot of the virtual machine.