Creating Workspot Templates for GCP

Prev Next

This article is a quick guide for adding a Microsoft Windows template to use with your GCP Workspot deployment. It is part of the Getting Started with Workspot article series. Please ensure you follow the appropriate steps for the Gen1 or Gen2 machines you plan to create.

To create a Workspot Template, you will need to upload the VM from a virtualized environment to the GCP Storage and, with the help of Workspot Control,  transformed into a Template. 

Prepare a VHD, VHDX, or VMDK file for uploading. We suggest uploading a basic template to serve as a foundational template, which customers can later adjust according to their needs.

Creating a Storage Bucket 

To create a Storage Bucket, go to the menu in GCP, then look for Cloud Storage > Buckets:  

  • Create bucket [customername] templates.  

  • Go in the bucket, and then go to the permissions tab.  

Add a new permission for all users

Note: This step is based on GCP documentation and is offered as one way to proceed if you are not familiar with GCP templates. If you are familiar with a different workflow, use that.

This step is temporary. It will be reversed after the image has been uploaded and converted to a GCP image.

  • Assign to New Principals: Grant the required roles to the project’s Compute Engine or Cloud Build service account (for example: roles/storage.objectViewer and roles/compute.storageAdmin) instead of granting access to allUsers.

  • Assign Roles:

    • Cloud Storage > Storage Object Creator

    • Cloud Storage > Storage Object Viewer

Upload the Image

  • Upload the VHD image from the local machine.   

  • Navigate to Cloud Storage and click on the Bucket. 

  • In the next screen, click on Upload Files. A File Explorer window will appear. Choose the VHD file you want to upload.

  • The upload process will start, and the status can be monitored in a tiny window on the bottom-right corner of the page 

  • The status will show as complete once the upload is done, and you can find the file uploaded in the bucket. 

  • Click on the File Details to copy the gsutil uri for future use. 

Convert a Customer Image to a GCP-supported Image 

When the image has been uploaded, to create a template, you need to convert the VHD, VHDX, or VMDK into a GCP Image. Make sure to follow the Workspot guidelines for uploading an image: 

 https://community.workspot.com/templates-images-creating-90/customer-provided-windows-10-template-requirements-for-azure-and-gcp-386   

  • Create an image from the VHD file above by running the following command, replacing your details in < > parameters:  

gcloud compute images import <Name of the Image> --os=< windows-10-x64-byol>  --source-file="<URI or location of the vhd file gs:uri>" --project "<ProjectID>" --network=<VPC Name> --subnet=<Subnet name> 

Example: 

gcloud compute images import cs-w10t-201009 --os=windows-10-x64-byol --source-file="gs://templatefolder/win10image.vhd" --project "demo" --network=default --subnet=subnet-daas 

  • If the disk you are uploading is UEFI boot-enabled, please tag the image with the “UEFI_COMPATIBLE" feature. 

gcloud compute images import cs-w10t-201009 --os=windows-10-x64-byol --source-file="gs://templatefolder/win10image.vhd" --project "demo" --network=default --subnet=subnet-daas --guest-os-features="UEFI_COMPATIBLE" 

Example: 

gcloud compute images import cs-w10t-201009 --os=windows-11-x64-byol --source-file="gs://templatefolder/win11image.vhd" --project "demo" --network=default --subnet=subnet-daas --guest-os-features="UEFI_COMPATIBLE" 

Please follow this document for the steps to create a UEFI/Gen2 disk and image: Creating a Windows 10 Generation 2 Disk Image on Hyper-V and Importing it on GCP. 

  • Run the modified Script in Cloud Shell. When the script finishes running, you will see the image under Compute Engine > Images  

  • If you set the “allUsers” permissions in a prior step, remove them now, as they are no longer required.

Create a Template from the Image 

The next step is to create a template from the image that we just created, using the build template method. 

  • Log in to the control portal: https://control.workspot.com  

  • Navigate to “Setup > Cloud > Public Cloud.” Choose the GCP Cloud Configuration you have created.  

  • On the new page, in the Custom Images Section, you will find the button “Add Images”. Click on the button.  

  • A new Window will pop up – Add Custom Image. In the Image name field, choose  the “Windows Desktop” radio button, type the name of the image you created in the previous steps. Click on the save button. This will add the image under the Custom Image tab.  

  • If you are creating a Cloud App image, make sure you select and choose the “Windows server” radio button. 

  • Now, click on the “Build Template” button.  

  • Provide the region and zone as your primary region and default zone.   

  • OS Type as “Windows Desktop” for Windows 10 and 11, “Windows Server” for cloud app.  

  • Choose the Image  

  • Provide the name for the template and choose the Template VM type. 

  • For deploying machines that are AD joined, check the box “Setup Domain Join” and click on the “Create Template” button.  

  • In the next window, you will be asked to join the domain via the “Domain Join” pop-up. Both the template and any desktops built from it will use these parameters to join the domain. Domain administrator credentials are stored in the VM’s secure wallet. Enter the appropriate domain name, OU string, and the credentials of a domain administrator’s account.  

  • This will now initiate the provisioning of the template machine. When provisioning is complete, its status will change to Draft.  

Log in and Configure the Template VM

  • Sign in to the Utility Server.

  • From there, connect to the newly provisioned Template machine, using its private IP. Or you can access the template VM directly through IdP. 

  • Make the necessary configurations, like installing any specific software, etc.  

Verify the Google Guest Environment is Present

  • If the image was imported without the --no-guest-environment flag, the Google Guest Environment should already be installed.

    • To confirm if you have the above:  

      • Connect to the machine using local admin credentials.  

      • Launch PowerShell in Admin mode  

      • Type the following command – googet installed  

  • If this succeeds, skip down to Configure the Google Guest Environment.

  • If you see an error that PowerShell is unable to identify the Googet command, then probably the guest environment is not installed. In this case, you should first install the Guest Environment, as shown below.

Install the Google Guest Environment

This step is unnecessary if you verified the presence of the environment. Skip to Configure the Google Guest Environment.

  • Paste the commands below into an elevated PowerShell console:  

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12  

Invoke-WebRequest https://github.com/google/googet/releases/download/v2.13.0/googet.exe -OutFile $env:temp\googet.exe & "$env:temp\googet.exe" -root C:\ProgramData\GooGet -noconfirm install -sources https://packages.cloud.google.com/yuck/repos/google-compute-engine-stable googet  

Remove-Item "$env:temp\googet.exe" 
  • On installation, GooGet adds content to the system environment, so launch a new admin-level PowerShell console after installation.

Configure the Google Guest Environment

  • Launch a new admin-level PowerShell console if you just installed GooGet

  • Add the google-compute-engine-stable repo:

    • googet addrepo google-compute-engine-stable

  • Install the core packages google-compute-engine-windows, google-compute-engine-metadata-scripts, google-compute-engine-sysprep, and google-compute-engine-vss:

    • googet -noconfirm install google-compute-engine-windows google-compute-engine-sysprep google-compute-engine-metadata-scripts google-compute-engine-Powershell google-compute-engine-vss

  • Install the network drivers for the NIC, the  NetKVM drivers, and optionally the GGA display drivers if you enabled “Use Display Adapter” on the VM Edit page on GCloud Console: 

    • googet -noconfirm install google-compute-engine-driver-netkvm google-compute-engine-driver-vioscsi google-compute-engine-driver-pvpanic google-osconfig-agent google-compute-engine-driver-balloon google-compute-engine-driver-gga  

  • Finally, configure GooGet to auto-update:

    • googet -noconfirm install google-compute-engine-auto-updater

“Googet list” should now have output like:

List of installed applications with details like publisher, installation date, and version.

GCloud Article: https://cloud.google.com/compute/docs/images/install-guest-environment 

Publish the Template in Control

  • When the template is ready to be published, change the state of the template on Control to “Published”. This action will shut down the template machine. 

  • Add DNS Server IPs on Project Metadata: 

    • Goto > Compute Engine > Settings > Metadata  

    • Add the Key “domain-controller-addresses”, edit the Value, and provide the DNS server internal IPs separated by a comma (,). 

    • The IPs will be added as a DNS server on the OS level whenever the Cloud Desktop boots. 

  • After clicking the Save button, the changes should reflect as below:   

Related Documents