ansible,

GCP Nested Virtualization

Gini Gini Follow · 1 min read
Share this

Note: This is purely based on GCP Documentation and for my own quick reference with additonal notes.

## Create a boot disk from a public image 
$ gcloud compute disks create disk1 --image-project debian-cloud --image-family debian-9 --zone us-central1-b


## Create image
$ gcloud compute images create nested-vm-image \
  --source-disk disk1 --source-disk-zone us-central1-b \
  --licenses "https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"

## remove the disk since it not needed anymore

## Create VM with new Image
$ gcloud compute instances create example-nested-vm --zone us-central1-b \
              --min-cpu-platform "Intel Haswell" \
              --image nested-vm-image

## SSH Access to the VM
$ gcloud compute ssh example-nested-vm
## and check the nested virtualization inside VM
$ grep -cw vmx /proc/cpuinfo

Starting a nested VM

## Update the VM instance and install some necessary packages
$ sudo apt update && sudo apt install qemu-kvm -y

## Download OS Image
$ wget https://people.debian.org/~aurel32/qemu/amd64/debian_squeeze_amd64_standard.qcow2

## Run inside screen and press enter
$ screen

## SStart the nested VM. When prompted, login in with user: root, password: root
sudo qemu-system-x86_64 -enable-kvm -hda debian_squeeze_amd64_standard.qcow2 -m 512 -curses

Starting a private bridge between the host and nested VMs

## insall necessary pacakges
$ sudo apt update && sudo apt install uml-utilities qemu-kvm bridge-utils virtinst libvirt-daemon-system libvirt-clients -y

## Start the default network that comes with the libvirt package:
$ sudo virsh net-start default

Appendix

Install GNOME on Debian

$ sudo tasksel install desktop gnome-desktop
$ sudo tasksel install laptop

## To tell Debian 10 to start the graphical desktop environment by default on boot, run the following command:
$ sudo systemctl set-default graphical.target
$ sudo reboot
Gini
Written by Gini Follow
Backpacker, Foodie, Techie

Latest Stories

How To Get Hands-On Experience in AWS

Every Time you have the same situation, you know the technology and maybe you are already a certified professional in that technology, but you are not getting enough hands-on on that ...

In AWS, Jan 04, 2021
Getting Started with Ansible Collections

Ansible Collection is a great way of getting content contributions from various Ansible Developers. Earlier there was a tagline for Ansible – “Batteries included”, but now the battery...

In redhat, ansible, Dec 22, 2020
Configure Your Windows Host to be Managed by Ansible

I was talking to my friend about Ansible automation and how we are implementing automated solutions for cloud and on-premise infrastructure. Then he told me that, his team is looking ...

In redhat, ansible, Dec 01, 2020
Remove nodes from Kubespray Managed Kubernetes Cluster

Kubespray is a combination of Ansible and Kubernetes and you can use Kubespray for deploying production ready Kubernetes clusters. You can manage full-lifecycle of Kubernetes clusters...

In containers, kubernetes, Nov 30, 2020
Adding new nodes to Kubespray Managed Kubernetes Cluster

Kubespray is a combination of Ansible and Kubernetes and you can use Kubespray for deploying production ready Kubernetes clusters. Learn how to add new nodes in a Kubernetes cluster u...

In containers, kubernetes, Nov 27, 2020

Featured