Create a customized boot disk

Before you begin

To use gdcloud command-line interface (CLI) commands, ensure that you have downloaded, installed, and configured the gdcloud CLI. All commands for Distributed Cloud Hosted use the gdcloud or kubectl CLI, and require an operating system (OS) environment.

Get the kubeconfig file paths

  1. Run gdcloud auth login to the admin cluster.

    1. Record the path to the generated file, as in this example:
      /tmp/admin-kubeconfig-with-user-identity.yaml.

    2. Use the path to replace ORG_ADMIN_KUBECONFIG in these instructions.

Create a boot disk

When you create a virtual machine (VM) instance, you must also create a boot disk for the VM. You can use either a public image or a custom image.

GDCH automatically creates a boot persistent disk when you create a VM instance. If you require additional data storage disks for your instances, add a persistent disk to your VM.

Use the procedures described on this page to create boot disks that you can use later to create VMs.

Permissions required for this task

To perform this task, you must have access to VM disks. Follow the steps to either verify or assign the Project VirtualMachine Admin role.

Create a boot disk from an image

You can create a standalone boot persistent disk outside of instance creation and attach it to an instance afterwards. This section shows how to create a boot disk from either a GDCH-provided OS image or a custom OS image.

Create a boot disk from a GDCH-provided image

Before you create a boot disk by using a GDCH-provided image, review the list of available images. Then create a boot disk with the provided image.

gdcloud

  1. List all available images and their minimum disk size:

    gdcloud compute images list
    

    This command includes both Distributed Cloud Hosted-provided and custom images. Choose either one in the vm-system namespace.

  2. Select a Distributed Cloud Hosted-provided image to create the VM disk:

    gdcloud compute disks create BOOT_DISK_NAME \
        --project=PROJECT \
        --size=DISK_SIZE \
        --image=IMAGE_NAME \
        --image-project=vm-system
    

    Replace the variables using the following definitions:

    VariableDefinition
    BOOT_DISK_NAME The name of the boot disk.
    PROJECT The GDCH project in which to create the boot disk.
    DISK_SIZE The size of the boot disk, needs to be at least the minimumDiskSize of the image.
    IMAGE_NAME The name of the image.

kubectl

  1. List all available GDCH-provided images:

    kubectl --kubeconfig ORG_ADMIN_KUBECONFIG \
        get virtualmachineimages.virtualmachine.gdc.goog --namespace vm-system
    
  2. Get the minimumDiskSize of a specific GDCH-provided image. The size of the created customized boot disk must be at least the minimumDiskSize:

    kubectl --kubeconfig ORG_ADMIN_KUBECONFIG \
      get virtualmachineimages.virtualmachine.gdc.goog --namespace vm-system \
      IMAGE_NAME -ojsonpath='{.spec.minimumDiskSize}'
    
  3. Create a VirtualMachineDisk object:

    kubectl --kubeconfig ORG_ADMIN_KUBECONFIG apply -n PROJECT -f - <<EOF
    apiVersion: virtualmachine.gdc.goog/v1
    kind: VirtualMachineDisk
    metadata:
      name: BOOT_DISK_NAME
    spec:
      source:
        image:
          name: IMAGE_NAME
          namespace: vm-system
      size: DISK_SIZE
    EOF
    

    Replace the variables using the following definitions,

    VariableDefinition
    ADMIN_KUBECONFIG The admin cluster kubeconfig file path.
    IMAGE_NAME The name of the image.
    PROJECT The GDCH project in which to create the boot disk.
    BOOT_DISK_NAME The name of the boot disk.
    DISK_SIZE The size of the boot disk, needs to be at least the minimumDiskSize of the image.

Create a boot disk from a custom image

A custom image belongs exclusively to your project. To create a VM with a custom image, you must first create a custom image in the same project if you don't already have one.

Set up the necessary IAM roles to access custom images in your project if you haven't done so yet. Then proceed with these instructions.

gdcloud

  1. List all custom images and their minimum disk size:

    gdcloud compute images list \
        --project=PROJECT \
    
  2. Select a custom image to create the VM disk:

    gdcloud compute disks create BOOT_DISK_NAME \
        --project=PROJECT \
        --size=DISK_SIZE \
        --image=IMAGE_NAME \
        --image-project=PROJECT
    

    Replace the variables using the following definitions:

    VariableDefinition
    BOOT_DISK_NAME The name of the boot disk.
    PROJECT The GDCH project in which to create the boot disk.
    DISK_SIZE The size of the boot disk, needs to be at least the minimumDiskSize of the image.
    IMAGE_NAME The name of the image.

kubectl

  1. List all custom images:

    kubectl --kubeconfig ORG_ADMIN_KUBECONFIG \
        get virtualmachineimages.virtualmachine.gdc.goog --namespace PROJECT
    
  2. Get the minimumDiskSize of a specific customized image. The size of the created customized boot disk must be at least the minimumDiskSize:

    kubectl --kubeconfig ORG_ADMIN_KUBECONFIG \
      get virtualmachineimages.virtualmachine.gdc.goog --namespace vm-system \
      IMAGE_NAME -ojsonpath='{.spec.minimumDiskSize}'
    
  3. Create a VirtualMachineDisk object:

    kubectl --kubeconfig ORG_ADMIN_KUBECONFIG \
        apply --namespace PROJECT -f - <<EOF
    apiVersion: virtualmachine.gdc.goog/v1
    kind: VirtualMachineDisk
    metadata:
      name: BOOT_DISK_NAME
    spec:
      source:
        image:
          name: IMAGE_NAME
          namespace: PROJECT
      size: DISK_SIZE
    EOF
    

    Replace the variables, using the following definitions:

    VariableDefinition
    ADMIN_KUBECONFIG The admin cluster kubeconfig file path.
    IMAGE_NAME The name of the image chosen from the list all custom images command.
    PROJECT The GDCH project in which to create the boot disk.
    BOOT_DISK_NAME The name of the boot disk.
    DISK_SIZE The size of the boot disk, needs to be at least the minimumDiskSize of the image.

To replace a boot disk, see the Replace a boot disk page.