Google cloud Create image from instance

半城伤御伤魂 提交于 2020-01-12 18:54:18

问题


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.


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/36701516/google-cloud-create-image-from-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!