Enable or disable VM Runtime on Google Distributed Cloud

This document shows you how to enable or disable VM Runtime on Google Distributed Cloud by either updating the VMRuntime custom resource or running bmctl commands.

Before you begin

To enable or disable VM Runtime on Google Distributed Cloud, you need access to the following resources and tools:

Enable VM Runtime on Google Distributed Cloud

VM Runtime on Google Distributed Cloud is automatically installed in GKE on Bare Metal version 1.10 or higher, but is disabled by default. Before you can run VM resources in your GKE on Bare Metal, you must enable the VM Runtime on Google Distributed Cloud.

bmctl

  • To enable the runtime, use the bmctl tool:

    bmctl enable vmruntime --kubeconfig KUBECONFIG_PATH
    

    Provide the path to the kubeconfig file for your cluster. GKE on Bare Metal generates the kubeconfig file on the admin workstation when you create a cluster. By default, the path is bmctl-workspace/CLUSTER_NAME/CLUSTER_NAME-kubeconfig.

    If VM Runtime on Google Distributed Cloud is already enabled, the command returns an error.

Additional settings, such as for emulation or image format, can be configured by editing the VMRuntime custom resource.

Custom resource

To enable the runtime, update the VMRuntime custom resource. This custom resource is installed by default.

  1. Edit the VMRuntime custom resource:

    kubectl edit vmruntime
    
  2. Set enabled:true in the spec:

    apiVersion: vm.cluster.gke.io/v1
    kind: VMRuntime
    metadata:
      name: vmruntime
    spec:
      enabled: true
      # useEmulation defaults to "false" if not set.
      useEmulation: true
      # vmImageFormat defaults to "qcow2" if not set.
      vmImageFormat: qcow2
    

    In the preceding spec section, the following values can be set:

    • enabled: set to true to enable VM Runtime on Google Distributed Cloud
    • useEmulation: If your node doesn't support hardware virtualization, or you aren't sure, set the value to true. If available, hardware virtualization provides better performance than software emulation. The useEmulation field defaults to false, if it isn't specified.
    • vmImageFormat: Supports two disk image format values: raw and qcow2. If you don't set vmImageFormat, the VM Runtime on Google Distributed Cloud uses the raw disk image format to create VMs. The raw format may provide improved performance over qcow2, a copy on write format, but may use more disk. For more information about the image formats for your VM, see Disk image file formats in the QEMU documentation.
  3. Save the custom resource in your editor.

  4. Verify that the VMRuntime custom resource is enabled:

    kubectl describe vmruntime vmruntime
    

    The details of the VMRuntime custom resource include a Status section. VM Runtime on Google Distributed Cloud is enabled and working when VMRuntime.Status.Ready shows as true.

Disable VM Runtime on Google Distributed Cloud

When you no longer need to use VM Runtime on Google Distributed Cloud, you can disable this feature.

bmctl

  • To disable the runtime, use the bmctl tool:

    bmctl disable vmruntime --kubeconfig KUBECONFIG_PATH \
      --force=true
    

    Provide the path to the kubeconfig file for your cluster and values for the following configuration options:

    • --force: Set to true to confirm you want to delete existing VM resources. The default value is false.

Custom resource

To disable the runtime, update the VMRuntime custom resource:

  1. Edit the VMRuntime custom resource:

    kubectl edit vmruntime
    
  2. Set enabled:false in the spec:

    apiVersion: vm.cluster.gke.io/v1`
    kind: VMRuntime
    metadata:
      name: vmruntime
    spec:
      enabled: false
      useEmulation: true
      vmImageFormat: qcow2
    
  3. Save the updated custom resource specification in your editor.

  4. To verify that the VMRuntime custom resource is disabled, view the pods that run in the vm-system namespace:

    kubectl get pods --namespace vm-system
    

    VM Runtime on Google Distributed Cloud is disabled when only the pods that belong to the vmruntime-controller-manager deployment are running in the namespace.

Understand the behavior for running VMs

The baremetal.cluster.gke.io/vmrumtime-force-disableannotation can be used on VM Runtime on Google Distributed Cloud resource to define the behavior when the runtime is disabled while VMs are running in the cluster.

The following example shows that the value of this annotation is set to false by default:

  // VM runtime yaml file
  apiVersion: vm.cluster.gke.io/v1
  kind: VMRuntime
  metadata:
    annotations:
      baremetal.cluster.gke.io/vmrumtime-force-disable: "false"
    name: vmruntime
  [...]

When this annotation is set to false, VM Runtime on Google Distributed Cloud tries to protect running VMs. Delete all running VMs before the VM Runtime on Google Distributed Cloud is disabled, or specify the --force=true parameter with the bmctl disable vmruntime command as shown in the previous section.

The following table explains what happens to running VMs when this annotation is set to true or false and if you specify the --force=true parameter or not:

Cluster state --force parameter vmrumtime-force-disable annotation Behavior
No VMs N/A N/A Disable VM Runtime on Google Distributed Cloud.
Existing VMs True True Delete all running VMs and the related resources. Disable the VM Runtime on Google Distributed Cloud.
True False Delete all running VMs and the related resources. Disable the VM Runtime on Google Distributed Cloud.
False True Prompt to delete running VMs and related resources. When all running VMs have been deleted, disable VM Runtime on Google Distributed Cloud.
False False Don't delete any existing VMs that are running. Don't disable the VM Runtime on Google Distributed Cloud. The bmctl command returns an error.

What's next