Importing virtual appliances

A virtual appliance is a package that contains disk images and hardware configuration for a virtual machine (VM).

A widely used and popular format for virtual appliances is the OVF format. When you package virtual appliances in the OVF format, you generate an OVF package. An OVF package is a folder that contains an .ovf descriptor file, and a collection of other resources such as disks. When an OVF package is archived into a single file, it is referred to as an OVA file.

You can import VMs that are in OVF format to Compute Engine, whether they are in an OVF package or in an OVA single file. To check whether using a virtual appliance is the best choice for your use case, review Choosing an import method.

When you import a virtual appliance, the import process uses the information stored in the descriptor file to create and start a VM instance on Compute Engine.

Before you begin

Enable the Cloud Build API

The virtual appliance import tool uses Cloud Build. Enable the Cloud Build service in your project, and grant the Cloud Build service account permissions to create and manage compute resources.

Console

  1. Enable the Cloud Build API.

    Enable the Cloud Build API

    When you enable the Cloud Build API from the console, Compute Engine grants the Cloud Build service account the following roles so that the Cloud Build service can import instances into Compute Engine:

    • roles/iam.serviceAccountTokenCreator
    • roles/compute.admin
    • roles/iam.serviceAccountUser

    The import tool also uses the default Compute Engine service account. By default, the Compute Engine service account has the Cloud IAM project editor role. If this role is removed, the import process might fail. To add the role back to the service account, see Granting access. For more information about the Compute Engine default service account, see Compute Engine default service account.

gcloud

To set up the Cloud Build service using gcloud command-line tool, complete the following steps:

  1. Enable Cloud Build.

    gcloud services enable cloudbuild.googleapis.com
    

    The import tool also uses the default Compute Engine service account. By default, the Compute Engine service account has the Cloud IAM project editor role. If this role is removed, the import process might fail. To add the role back to the service account, see Granting access. For more information about the Compute Engine default service account, see Compute Engine default service account.

  2. Add the compute.admin role to the service account for the Cloud Build API.

    gcloud projects add-iam-policy-binding [PROJECT_ID] \
      --member serviceAccount:[PROJECT_NUM]@cloudbuild.gserviceaccount.com \
      --role roles/compute.admin
    
  3. Add the iam.serviceAccountUser role to the service account for the Cloud Build API.

    gcloud projects add-iam-policy-binding [PROJECT_ID] \
      --member serviceAccount:[PROJECT_NUM]@cloudbuild.gserviceaccount.com \
      --role roles/iam.serviceAccountUser
    
  4. Add the iam.serviceAccountTokenCreator role to the service account for the Cloud Build API.

    gcloud projects add-iam-policy-binding [PROJECT_ID] \
      --member serviceAccount:[PROJECT_NUM]@cloudbuild.gserviceaccount.com \
      --role roles/iam.serviceAccountTokenCreator
    

    where:

Requirements

Source VM requirements

The following requirements must be met by the VM that is used to create the OVF file:

  • Virtual disks must be in VMDK or VHD formats.
  • Virtual disks must be configured with MBR boot. UEFI is not supported.
  • Virtual disks must not be encrypted.

To verify that your VM meets the requirements, you can run the precheck tool.

OVF file requirements

The following requirements must be met by the OVF file:

  • The OVF files must provide Level 1 portability as described in the OVF specification document. Virtual appliances that meet Level 2 portability can be imported, but any custom extensions such as source hypervisor specific details are ignored during the import process.
  • The OVF file must contain only one VM. If more than one VM is present, only the first VM is imported.
  • The first disk in the OVF file must be bootable.

Configurations that are imported by the import tool

The OVF standard specifies the process for packaging virtual appliances in a manner that is not dependent on the virtualization provider. OVF virtual appliances packages contain one .ovf descriptor file and a collection of other resources such as virtual disks.

When you import an OVF virtual appliance to Compute Engine, the following configurations from the descriptor file are processed and imported:

  • Virtual Disks. Information retrieved from the DiskSection element of the OVF package.
  • CPU and Memory. Retrieved from the ResourceAllocationSection of the OVF package.

    If the CPU or memory configurations are outside the limits of the supported range in Compute Engine, the import process sets the values to the max that is supported on Compute Engine.

  • Boot Disk. Details retrieved from the BootDeviceSection element of the OVF package.

  • Guest OS. Details retrieved from the OperatingSystemSection element of the OVF package.

    The Guest OS information is used to install the correct drivers and guest environment packages on the imported instance. If the guest OS information found in OVF is incorrect, the import fails. You can use --os flag to override guest OS information.

Imported instances are always created with a single network adapter, with no external IP. This single network adapter is used regardless of the networking configurations specified in the OVF file.

Limitations

When importing a virtual appliance, the following sections of the descriptor file are ignored (not imported):

  • NetworkSection
  • AnnotationSection
  • ProductSection
  • EulaSection
  • StartupSection
  • DeploymentOptionSection
  • InstallSection
  • EnvironmentFilesSection
  • SharedDiskSection
  • ScaleOutSection
  • PlacementGroupSection
  • PlacementSection
  • EncryptionSection

Supported operating systems

Specify one of the following operating systems in the OperatingSystemSection of your descriptor file:

Linux distributions and versions

  • CentOS 6, CentOS 7
  • Debian 8, Debian 9
  • Red Hat Enterprise Linux 6, Red Hat Enterprise Linux 7
  • Ubuntu 14.04 LTS, Ubuntu 16.04 LTS

For all Linux distributions, the boot disk must have GRUB installed.

Windows versions

  • Windows Server 2008 R2
  • Windows Server 2012, Windows Server 2012 R2, Windows Server 2012 R2 Core
  • Windows Server 2016, Windows Server 2016 Core
  • Windows Server 2019, Windows Server 2019 Core
  • Windows 7 SP1 x64 (supported for BYOL only)
  • Windows 8 SP1 x64 (supported for BYOL only)
  • Windows 10 Enterprise x64 (supported for BYOL only)

For all Windows operating systems, PowerShell version 3 or later must be installed. PowerShell versions earlier than 3.0 can cause issues with the startup and shutdown scripts used during the import process.

Support for BYOL

By default, OVF files that use Windows and Red Hat Enterprise Linux (RHEL) operating systems are imported and configured to use premium OS on-demand billing, which incurs additional charges.

If you prefer to use your own software subscriptions for RHEL, you can import virtual appliances as bring-your-own-license (BYOL)—licensed appliances.

To import appliances as BYOL licensed appliances, specify one of following BYOL values for the [--os] flag when you run the import command.

  • rhel-6-byol
  • rhel-7-byol
  • windows-2008r2-byol
  • windows-2012-byol
  • windows-2012r2-byol
  • windows-2016-byol
  • windows-2019-byol
  • windows-7-byol
  • windows-8-1-x64-byol
  • windows-10-byol

Importing an OVA file

  1. Add the virtual appliance to Cloud Storage.
  2. To import an OVA file from Cloud Storage to Compute Engine, use the gcloud compute instances import command.

    gcloud compute instances import [INSTANCE_NAME] \
      --source-uri=gs:[PATH_TO_OVA_FILE]
    

    where:

    • [INSTANCE_NAME] is the name of the instance you want to create.
    • [PATH_TO_OVA_FILE] is the path to the OVA file on Cloud Storage.

    For example, to import an OVA file Ubuntu.ova and create an instance named my-instance, run the following command:

    gcloud compute instances import my-instance \
      --source-uri=gs://my-bucket/Ubuntu.ova
    

    In some cases, you might be prompted to provide a value for the OS. To specify the operating system, you need to add the --os flag. For example, to import an OVA file Ubuntu.ova and create an instance named my-instance that runs Ubuntu 16.04, run the following command:

    gcloud compute instances import my-instance \
     --os=ubuntu-1604
     --source-uri=gs://my-bucket/Ubuntu.ova
    

Importing an OVF file

  1. Add the virtual appliance to Cloud Storage.
  2. To import an OVF file from Cloud Storage to Compute Engine, use the gcloud compute instances import command.

    If your directory contains only one OVF file, you can either provide the path to the descriptor file or the path to the directory that contains the OVF file.

    • To import an OVF file using the path to the descriptor file, run the following command:

      gcloud compute instances import [INSTANCE_NAME] \
        --source-uri=gs:[PATH_TO_OVF_FILE]
      
    • To import an OVF file using the directory path, run the following command:

      gcloud compute instances import [INSTANCE_NAME] \
        --source-uri=gs:[PATH_TO_OVF_DIRECTORY]
      

    where:

    • [INSTANCE_NAME] is the name of the instance you want to create.
    • [PATH_TO_OVF_FILE] is the path to the OVF file on Cloud Storage.
    • [PATH_TO_OVF_DIRECTORY] is the path to the directory that contains the OVF file on Cloud Storage.

    For example, to import an OVF file Ubuntu.ovf in the my-bucket directory, that creates an instance named my-instance, run the following command:

    gcloud compute instances import my-instance \
      --source-uri=gs://my-bucket/
    

    In some cases, you might be prompted to provide a value for the OS. To specify the operating system, you need to add the --os flag. For example, to import an OVF file Ubuntu.ovf and create an instance named my-instance that runs Ubuntu 16.04, run the following command:

    gcloud compute instances import my-instance \
     --os=ubuntu-1604 \
     --source-uri=gs://my-bucket/
    

Importing with custom settings

Custom CPU and memory

If you want to override the CPU or memory configuration specified in the OVF file, specify the --custom-cpu and --custom-memory flags.

For example, to import an instance named my-instance that runs Ubuntu 1404 and has 2 CPUs and 2048 MB of memory, run the following command:

gcloud compute instances import my-instance \
  --os=ubuntu-1404 --source-uri=gs://my-bucket/Ubuntu.ova \
  --custom-cpu=2 --custom-memory=2048MB

Custom networks

If your project is set up to use custom networks, you'll need to specify a --network flag. If the network is configured with a custom subnet mode, you must also specify --subnet and --zone flags.

For example, to import an instance with the following properties:

  • Instance name: my-instance
  • Operating system: Ubuntu 1404
  • Network: custom-vpc network
  • Subnet company-vpc-us-east1-c
  • Zone: us-east1-c

Run the following command:

gcloud compute instances import my-instance --os ubuntu-1404 \
  --source-uri=gs://my-bucket/Ubuntu.ova \
  --network company-vpc \
  --subnet company-vpc-us-east1-c \
  --zone us-east1-c

What's next

Оцените, насколько информация на этой странице была вам полезна:

Оставить отзыв о...

Текущей странице
Compute Engine Documentation