在 GCP 中克隆一个实例

Clone an instance in GCP

我需要一个 Compute Engine 实例 来导入确切的配置(IP、服务、文件 等...)原始机器,如果涉及 Web 服务器,则不会影响前端。在 运行 这台机器上,我可以关闭原始机器以增加其 RAM 或 vCPU,然后再次启动它并删除克隆的实例。

问题是我想自动执行此过程,这就是我需要 gcloud 命令的原因。那么有没有办法使用 gcloud 命令或其他工具 clone 整个 gcp 实例?

gcloud 无法做到这一点。这可以通过云控制台实现,但正如您在此 documentation:

中看到的

Restrictions

You can only use this feature in the Cloud Console; this feature is not supported in the gcloud tool or the API.

你可以做的是从 custom image 创建相似的(不完全相同的)实例,使用它你所要做的就是使用以下命令:

gcloud compute instances create --image=IMAGE

可以找到有关该命令的更多详细信息here