Bookmark this page

Lab: Deploying OpenShift Virtualization and Configuring External Network

Deploy the Red Hat OpenShift Virtualization operator, configure node networking, and connect a VM to an additional network.

Outcomes

  • Deploy the OpenShift Virtualization operator.

  • Configure cluster nodes with additional networks.

  • Prepare projects for additional networks.

  • Deploy virtual machines with multiple network interfaces.

If you did not reset your workstation and server machines at the end of the last chapter, then save any work you want to keep from earlier exercises on those machines, and reset them now.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command ensures that the cluster API is reachable and then creates the review-cr1 namespace.

[student@workstation ~]$ lab start review-cr1

Specifications

The Red Hat OpenShift cluster API endpoint is https://api.ocp4.example.com:6443 and the OpenShift web console is available at https://console-openshift-console.apps.ocp4.example.com. Log in to your OpenShift cluster as the admin user with redhatocp as the password. The oc command is available on the workstation machine.

  • Install the OpenShift Virtualization Operator in the openshift-cnv namespace. Use the stable channel and configure the operator for automatic update approval. Use the default options when creating the HyperConverged instance.

    Note

    If the kubevirt-hyperconverged resource exists, then an error message is displayed. Skip the step and continue with the exercise.

  • Add the orgnet=true label to the worker01 and worker02 cluster nodes.

  • The worker01 and worker02 cluster nodes have an ens4 network interface, which is connected to an additional network. Create a Linux bridge named br0 on each node, and then add the ens4 interface to that bridge. Configure the bridge interface to request an IPv4 address from DHCP. Use the orgnet: true label to select the nodes to configure.

  • Create a network attachment definition resource in the review-cr1 namespace with the following characteristics:

    ParameterValue
    Project review-cr1
    Resource name ext-net
    Network type CNV Linux bridge
    Bridge br0
  • Create a virtual machine named web1 in the review-cr1 namespace from the Red Hat Enterprise Linux 8.0 VM template. Use the http://utility.lab.example.com:8080/openshift4/images/helloworld.qcow2 URL for the boot source. Add a second network interface named nic-0, which is connected to the bridge that you declared in the ext-net network attachment definition resource.

  • Ensure that the web1 VM is running before grading your work.

  1. Open a web browser and log in to the OpenShift web console at https://console-openshift-console.apps.ocp4.example.com. Log in to your OpenShift cluster as the admin user with redhatocp as the password.

    1. Open a web browser and navigate to https://console-openshift-console.apps.ocp4.example.com. Select htpasswd_provider and log in as the admin user with redhatocp as the password.

  2. Install the OpenShift Virtualization operator in the openshift-cnv namespace.

    1. Navigate to OperatorsOperatorHub.

    2. Type virtualization in the OperatorHub search bar and then click the OpenShift Virtualization card.

    3. Click Install. Verify the following default options, and then click Install:

      • Update channel is set to stable.

      • Installation mode is set to A specific namespace on the cluster.

      • Installed Namespace is set to openshift-cnv.

      • Update approval is set to Automatic.

    4. After the OpenShift Virtualization operator installation completes, click Create HyperConverged. Accept the default options and then click Create.

      If the kubevirt-hyperconverged resource exists, then an error message is displayed. Click Cancel and continue with the exercise.

    5. Navigate to OperatorsInstalled Operators and then wait for the OpenShift Virtualization operator to report the Succeeded status.

  3. Label the nodes worker01 and worker02 with the orgnet=true label.

    1. From the OpenShift web console, navigate to ComputeNodes, click the vertical ellipsis icon next to worker01, and then click Edit labels.

    2. Type orgnet=true in the field and click Save.

    3. Repeat this step with the worker02 node.

    4. On the ComputeNodes page, select Label from the drop-down menu, type orgnet in the Search by label field, and select the orgnet=true label.

    5. Verify that the node list contains only the worker01 and worker02 nodes.

  4. Configure a Linux bridge named br0 for each cluster node with the orgnet=true label. The Linux bridge has the following requirements:

    ParameterValue
    Name br0-ens4-policy
    Interface name br0
    Interface type Bridge
    IPv4 Enabled
    DHCP Enabled
    Bridge port ens4
    Node selector orgnet=true
    1. Navigate to NetworkingNodeNetworkConfigurationPolicy and click Create NodeNetworkConfigurationPolicy.

    2. Complete the Create NodeNetworkConfigurationPolicy form with the provided specifications.

    3. Select the node selector checkbox to open the node selector.

    4. Click Add Label, and type orgnet as the key and true as the value.

    5. Click Save and then click Create to create the node network configuration policy.

    6. Confirm that the policy is successfully configured on the nodes by verifying its status on the NetworkingNodeNetworkConfigurationPolicy page. Wait until the node network state is 2 Available.

  5. Create a network attachment definition resource named ext-net in the review-cr1 namespace.

    1. From the OpenShift web console, navigate to NetworkingNetworkAttachmentDefinitions, select the review-cr1 project, and then click Create network attachment definition.

    2. Complete the form by using the following information and then click Create.

      ParameterValue
      Name ext-net
      Namespace review-cr1
      Network type CNV Linux bridge
      Bridge name br0
  6. Use the Red Hat Enterprise Linux 8.0 VM template to create the web1 VM in the review-cr1 namespace. Add a second network interface named nic-0.

    1. Navigate to VirtualizationCatalog.

    2. Select the Red Hat Enterprise Linux 8 VM template and click the Customize VirtualMachine button.

    3. Specify web1 as the VM name.

    4. Select the Disk sourceURL (creates PVC) menu option.

    5. Specify http://utility.lab.example.com:8080/openshift4/images/helloworld.qcow2 in the Import URL field.

    6. Click the Customize VirtualMachine parameters button.

    7. Click the Network Interfaces tab to display the network interfaces that are connected to the VM.

    8. Click Add Network Interface, complete the form by using the following information, and then click Save.

      ParameterValue
      Name nic-0
      Model virtio
      Network review-cr1/ext-net
      Type Bridge
    9. Click Create Virtual Machine.

    10. Navigate to VirtualizationVirtualMachines and then wait for the web1 VM to have the Running status.

    11. Click web1 to open the Overview tab for the web1 vm. Locate the Network interfaces (2) panel and confirm that the nic-0 interface on the VM has an IP address in the 192.168.51.0/24 address range.

Evaluation

As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.

[student@workstation ~]$ lab grade review-cr1

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish review-cr1

Revision: do316-4.14-d8a6b80