Pasupathi Rajamanickam
Pasupathi Rajamanickam

Reputation: 2052

Google cloud Create image from instance

I have a VM which is up and running and I have few applications in the VM. So I want to have an image of this VM so that I can create new instances with all the installed packages. I have option called clone, but instead cloning a VM I wanted to have it as an Image and create VM whenever I want.

Upvotes: 7

Views: 12217

Answers (2)

khushbu
khushbu

Reputation: 160

https://github.com/khushbuparakh/gcp/blob/master/instance.py

You can use this. It creates a bucket. Upload your private file to the bucket. Create an image using that file and spin up an instance. Make sure the file you are uploading to bucket is in tar.gz compressed format with a disk.raw file in it.

Upvotes: -2

Christiaan
Christiaan

Reputation: 2725

It's described here: https://cloud.google.com/compute/docs/creating-custom-image

Basically what it boils down to:

  1. Set the auto-delete state of the root persistent disk to false so that it is not automatically deleted when you delete the instance.
  2. Delete the instance.
  3. gcloud compute images create example-image --source-disk example-disk --source-disk-zone ZONE

Upvotes: 12

Related Questions