从实例内部删除GCE实例及其根永久磁盘 [英] Delete GCE instance AND its root persistent disk from within the instance

查看:88
本文介绍了从实例内部删除GCE实例及其根永久磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过暂存盘在GCE中完成以前很简单的事情。基本上,我想启动一个实例(现在使用新创建的根永久磁盘),让该实例运行一些计算,然后让该实例杀死自身并删除根永久磁盘。

I'm trying to accomplish something that was simple to do before in GCE with scratch disks. Basically I want to start an instance (now using a newly created root persistent disk), have the instance run some computation, then have the instance kill itself AND delete the root persistent disk.

在V1 api之前这很容易,因为您可以使用暂存磁盘,该磁盘在实例被杀死后会消失,但是现在使用V1,可以删除具有永久根目录的实例磁盘需要两个调用-一个用于删除实例,另一个用于删除磁盘。

This was easy before the V1 api because you could use a scratch disk that disappeared when the instance was killed, however, now with V1, deleting an instance with a root persistent disk requires two calls - one to delete the instance and one to delete the disk.

问题是,如果您要从实例本身进行这2次调用-您要先删除哪一个?实例还是磁盘?您无法执行磁盘操作,因为实例正在使用该磁盘,并且如果您先杀死该实例,那么将如何使用该实例来杀死磁盘?

The issue is that if you want to do these 2 calls from the instance itself - which do you delete first? the instance or the disk? You cant do the disk because its in use by the instance, and if you kill the instance first then how will the instance be used to kill the disk?

推荐答案

我认为您无法实现您所描述的目标。实例在运行时需要磁盘。关闭后,您可以删除磁盘。

I don't think you can achieve exactly what you described. The instance needs the disk while it is running. After it shuts down you can delete the disk.

Google计算引擎公开REST API。您可以发出调用以删除磁盘并从其他计算机(即您的工作计算机)中删除实例。如果需要,您甚至可以使用AppEngine来帮助您。实例可以在任务关闭之前将其放入任务队列,而稍后运行的AppEngine任务可以正确清理GCE实例。您还可以使用AppEngine运行一个小型管理应用程序,以帮助您管理GCE实例。

Google compute engine exposes REST API. You can issue the calls to delete disk and remove instance from some other machine (i.e. your work machine). If you want to, you can even use AppEngine to help you with this. An instance could put a task onto the task queue before it shuts down, and the AppEngine task, which would run a bit later could properly clean up the GCE instance. You could also use AppEngine to run a small admin application which could help you with managing your GCE instances.

这篇关于从实例内部删除GCE实例及其根永久磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆