Watch the replays from our Launchpad 2020 conference


Quick tip: Enable nested virtualization on a GCE instance

There are times when you need to run a virtual machine — but you’re already ON a virtual machine.  Fortunately, it’s possible, but you need to enable nested virtualization.  For me, this comes up often when I’m running OpenStack or Kubernetes on a Google Compute Engine instance.  To solve the problem, follow these steps:

  1. Install the latest version of the gcloud command-line tool.
  2. Create a new instance so you have a base disk to work with.  Because you’ll eventually want to use the image in a zone that includes nested virtualization, create it in zone us-central1-b.  You can do this from the UI, or using the command line. By default, the disk will have the same name as the instance:
    gcloud compute instances create temp-image-base --image-family=projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts --zone=us-central1-b
  3. Stop the instance:
    gcloud compute instances stop temp-image-base --zone=us-central1-b
  4. Now create a new disk, based on that disk, with nested virtualization enabled:
    gcloud compute images create nested-vm-image \
      --source-disk=temp-image-base --source-disk-zone=us-central1-b \
  5. Next create the new instance using the new image:
    gcloud compute instances create nested-vm --zone us-central1-b --image=nested-vm-image --machine-type=n1-standard-32 --boot-disk-size=250GB
  6. Connect to the instance:
    gcloud compute ssh nested-vm --zone=us-central1-b
  7. Confirm that nested virtualization is enabled by looking for a non-zero response to:
    > grep -cw vmx /proc/cpuinfo
    > 1
  8. Finally, install a hypervisor such as KVM:
    sudo apt-get update && sudo apt-get install qemu-kvm -y

From there, you’re ready to run VMs on your VM.

What's New in Kubernetes 1.18