Fix Virtual Machine is not starting

Scenario

The user tried to deploy and run a virtual machine and is facing an issue.

01 step2
The primary goal in this scenario is to investigate the cause of the failure and take corrective action to get exercise2 virtual machine back into the Running state.

The steps to fix exercise2 are:

Console

  1. Login to Openshift console using the assigned user account

Username
userx
Password
{password}
  1. Go to Virtualization - Virtual Machines and check the VM status.

01 step2
  1. Check the Virtual Machine is failing with error ErrorUnschedulable.

02 step3
  1. Go to tab YAML and check the status of the Virtual Machine. It is failing with error message:

message: '0/6 nodes are available: 3 node(s) didn''t match Pod''s node affinity/selector, 3 node(s) had untolerated taint {node-role.kubernetes.io/master: }. preemption: 0/6 nodes are available: 6 Preemption is not helpful for scheduling.'
  1. Check the NodeSelector and Tolerations assigned to this virtual machine.

    nodeSelector:
      node-role.kubernetes.io/baremetal: ''
    tolerations:
      - effect: NoSchedule
        key: bare_metal
        value: 'true'
  1. These NodeSelectors and Tolerations refer to nodes that do not match those in the cluster. Remove them.

  1. Restart the virtual machine to apply the changes.

  1. Wait for the virtual machine to start and check that now the virtual machine is in Running state.

03 step8
Run grade to validate the exercise
lab grade exercise2

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. Check there is a virtual machine running in this namespace and it’s status. The output should be similar to the following one:

oc get pod,vm
NAME                                READY   STATUS    RESTARTS   AGE
pod/virt-launcher-exercise2         0/1     Pending   0          19s

NAME                                   AGE   STATUS               READY
virtualmachine.kubevirt.io/exercise2   20s   ErrorUnschedulable   False
  1. Check which the the Virtual Machine status to get more details about the error:

oc describe vm exercise2
Status:
  Conditions:
    Last Probe Time:       2024-11-26T16:38:19Z
    Last Transition Time:  2024-11-26T16:38:19Z
    Message:               Guest VM is not reported as running
    Reason:                GuestNotRunning
    Status:                False
    Type:                  Ready
    Last Probe Time:       <nil>
    Last Transition Time:  <nil>
    Message:               Not all of the VMI's DVs are ready
    Reason:                NotAllDVsReady
    Status:                False
    Type:                  DataVolumesReady
    Last Probe Time:       <nil>
    Last Transition Time:  2024-11-26T16:38:19Z
    Message:               0/6 nodes are available: 3 node(s) didn't match Pod's node affinity/selector, 3 node(s) had untolerated taint {node-role.kubernetes.io/master: }. preemption: 0/6 nodes are available: 6 Preemption is not helpful for scheduling.
    Reason:                Unschedulable
    Status:                False
    Type:                  PodScheduled
  Created:                 true
  Desired Generation:      1
  Observed Generation:     1
  Printable Status:        ErrorUnschedulable
  Run Strategy:            Always
  1. Inspect the virtual machine and check the NodeSelector and Tolerations assigned to this virtual machine.

oc get vm exercise1 -oyaml
    nodeSelector:
      node-role.kubernetes.io/baremetal: ''
    tolerations:
      - effect: NoSchedule
        key: bare_metal
        value: 'true'
  1. These NodeSelectors and Tolerations refer to nodes that do not match those in the cluster. Edit the virtual machine configuration file and remove them.

oc edit vm exercise1
  1. Restart the virtual machine

virtctl restart exercise1
  1. Wait until the virtual machine is started and make sure it is in running state

oc get pod,vm
NAME                                READY   STATUS    RESTARTS   AGE
pod/virt-launcher-exercise2         1/1     Running   0          40s

NAME                                   AGE    STATUS    READY
virtualmachine.kubevirt.io/exercise2   5m9s   Running   True

What you learned

In this exercise, you learned that virtual machines cannot be started if a nodeSelector is defined and no nodes match the specified label in the nodeSelector.