在Web控制檯,創建一個快照,然後單擊快照並在創建實例按鈕,你可以自定義設置,然後單擊它說:
等REST或命令行
並複製命令行,這將是您的模板。
這個,你可以創造出一個bash腳本(clone_instance.sh),我做了這樣的事情:現在
#!/bin/bash -e
snapshot="my-snapshot-name"
gcloud_account="[email protected]"
#clone 10 machines
for machine in 01 02 03 04 05 06 07 08 09 10
do
gcloud compute --project "myProject" disks create "instance-${machine}" --size "220" --zone "us-east1-d" --source-snapshot "${snapshot}" --type "pd-standard"
gcloud compute --project "bizqualify" instances create "webscrape-${machine}" --zone "us-east1-d" --machine-type "n1-highmem-4" --network "default" --maintenance-policy "MIGRATE" --service-account "[email protected]" --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring.write","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" --tags "http-server","https-server" --disk "name=webscrape-${machine},device-name=webscrape-${machine},mode=rw,boot=yes,auto-delete=yes"
done
,在你的終端,你可以執行你的腳本
sh clone_instance.sh
相關:http://stackoverflow.com/q/31312085/322020 – Nakilon 2016-12-26 14:38:12