Manage virtual machines on Distributed Cloud connected racks

This page describes how to manage virtual machines on Google Distributed Cloud connected racks running VM Runtime on Google Distributed Cloud. You must be familiar with VM Runtime on GDC before completing the steps on this page. For a list of supported guest operating systems, see Verified guest operating systems for VM Runtime on GDC.

Virtual machine workloads are supported on legacy ("Config 1" and "Config 2") rack hardware, but not on any superseding rack hardware configurations.

To learn how virtual machines serve as an essential component of the Distributed Cloud connected platform, see Extending GKE Enterprise to manage on-premises edge VMs.

Distributed Cloud connected clusters support virtual machine webhooks. This allows Distributed Cloud connected to validate user requests made to the local Kubernetes API server. Rejected requests generate detailed information on the reason for rejection.

Upgrade existing virtual machines to Distributed Cloud connected version 1.7.0

You must add the following to the spec section of the VMRuntime resource on your cluster and then apply the modified resource to the cluster before upgrading the cluster to Distributed Cloud connected software to version 1.7.0:

spec:
  haPolicy:
    defaultRecoveryStrategy: Reschedule
    nodeHeartbeatInterval: 15s
    nodeMonitorGracePeriod: 55s

Enable VM Runtime on GDC support on Distributed Cloud connected

By default, VM Runtime on GDC virtual machine support is disabled on Distributed Cloud connected. To enable it, complete the steps in this section. The instructions in this section assume that you have a fully functioning Distributed Cloud connected cluster.

  1. Modify the VMRuntime custom resource with the following contents and apply it to your cluster:

    apiVersion: vm.cluster.gke.io/v1
    kind: VMRuntime
    metadata:
      name: vmruntime
    spec:
      # Enable Anthos VM Runtime support
      enabled: true
      # vmImageFormat defaults to "raw" if not set
      vmImageFormat: "raw"
      # Set node grace period to 55 seconds; required for upgrading to 1.7.0
      haPolicy:
        defaultRecoveryStrategy: Reschedule
        nodeHeartbeatInterval: 15s
        nodeMonitorGracePeriod: 55s

    Do not change the value of the vmImageFormat parameter. Distributed Cloud connected does not support any other virtual disk formats.

    This process typically takes several minutes to complete.

    Do not change the value of the vmImageFormat parameter. Distributed Cloud connected does not support any other virtual disk formats.

    This process typically takes several minutes to complete.

  2. Use the following command to verify that the VMRuntime custom resource has been applied to your cluster:

    kubectl get vmruntime -o yaml

    The command returns output similar to the following example:

     - apiVersion: vm.cluster.gke.io/v1
       kind: VMRuntime
       metadata:
         name: vmruntime
         ...
       spec:
         enabled: true
         vmImageFormat: raw
       status:
         ...
       ready: true
         ...
    
  3. Use the following command to verify that VM Runtime on GDC virtual machine support has been enabled on your cluster:

    kubectl get pods -n vm-system

    The command returns output showing the VM Runtime on GDC subsystem Pods running on your cluster, similar to the following example:

    NAME                                                READY   STATUS         RESTARTS        AGE
    cdi-apiserver-6c76c6cf7b-n68wn                      1/1     Running        0               132m
    cdi-deployment-f78fd599-vj7tv                       1/1     Running        0               132m
    cdi-operator-65c4df9647-fcb9d                       1/1     Running        0               134m
    cdi-uploadproxy-7765ffb694-6j7bf                    1/1     Running        0               132m
    macvtap-fjfjr                                       1/1     Running        0               134m
    virt-api-77dd99dbbb-bs2fb                           1/1     Running        0               132m
    virt-api-77dd99dbbb-pqc27                           1/1     Running        0               132m
    virt-controller-5b44dbbbd7-hc222                    1/1     Running        0               132m
    virt-controller-5b44dbbbd7-p8xkk                    1/1     Running        0               132m
    virt-handler-n76fs                                  1/1     Running        0               132m
    virt-operator-86565697d9-fpxqh                      2/2     Running        0               134m
    virt-operator-86565697d9-jnbt7                      2/2     Running        0               134m
    vm-controller-controller-manager-7844d5fb7b-72d8m   2/2     Running        0               134m
    vmruntime-controller-manager-845649c847-m78r9       2/2     Running        0               175m
    

Install the virtctl management tool

You need the virtctl client tool to manage virtual machines on your Distributed Cloud connected cluster. To install the tool, complete the following steps:

  1. Install the virtctl client tool as a kubectl plugin:

    export VERSION=v0.59.0-anthos1.28-gke.8
    gcloud storage cp gs://anthos-baremetal-release/virtctl/${VERSION}/linux-amd64/virtctl/usr/local/bin/virtctl
    cd /usr/local/bin
    sudo ln -s virtctl kubectl-virt
    sudo chmod a+x virtctl
    cd -
  2. Verify that the virt plugin is installed:

    kubectl plugin list

    If the plugin has been successfully installed, the command's output lists kubectl-virt as one of the plugins.

Provision a virtual machine on Distributed Cloud connected

This section provides configuration examples that illustrate how to provision a Linux virtual machine and a Windows virtual machine on a Distributed Cloud connected cluster with the Symcloud Storage abstraction layer.

Note that you cannot create a virtual machine on a Distributed Cloud connected cluster directly by using the kubectl virt command because Distributed Cloud connected does not provide file system storage to virtual machines.

Before completing the steps in this section, you must first complete the steps in Configure Distributed Cloud connected for Symcloud Storage. If you later disable Symcloud Storage on the cluster, virtual machines configured to use Symcloud Storage will fail.

Provision a Linux virtual machine on Distributed Cloud connected

The following example illustrates how to provision a Linux virtual machine with Symcloud Storage running Ubuntu Server 22.04. The installation source is the Ubuntu Server 22.04 ISO disc image.

  1. Create a VirtualMachineDisk resource with the following contents for the Ubuntu Server installation disc image, and then apply it to your cluster:

    apiVersion: vm.cluster.gke.io/v1
    kind: VirtualMachineDisk
    metadata:
      name: ubuntu-iso-disk
    spec:
      size: 20Gi
      storageClassName: robin
      diskType: cdrom
      source:
        http:
          url: https://releases.ubuntu.com/jammy/ubuntu-22.04.3-live-server-amd64.iso
  2. Create a VirtualMachineDisk resource with the following contents for the virtual machine's virtual hard disk, and then apply it to your cluster: