我想使用Google Cloud Scheduler在Google Cloud Platform中启动/停止一组Compute引擎实例。我该怎么办?
baobeicuijina 回答:使用Google Cloud Scheduler自动关闭和启动GCP
您可以查看Google文章以实现目标https://cloud.google.com/scheduler/docs/start-and-stop-compute-engine-instances-on-a-schedule。
此外,如果这些VM实例是无状态的,那么我建议看一下Google Cloud Run服务,该服务可以帮助您节省成本和操作开销,以配置自动关闭/自动启动。
希望这会有所帮助。
,我仍然想知道为什么gcp首先仍然没有此功能。 无论如何,这些简单的步骤为我做了工作
- 创建一个新的JobScheduler。
- 填写所需的详细信息
- 选择适合您要求的frequency。
- 选择目标发布/订阅。
- 选择主题名称(如果未创建,请创建新的topic)。
- 在有效负载部分中使用此停止脚本
gcloud compute instances stop instance-name
。
要验证更改,您可以手动运行作业并检查
,为了使用Cloud Scheduler启动和停止Compute Engine,您可以遵循Google this tutorial
我不会在此处复制粘贴所需的代码,因为该教程非常完整,但是我将在此处继续执行以下步骤。
如果您需要本教程的任何帮助,请告诉我!
,Instance Schedules 的新 Google Compute Engine 功能现在可用于通过 Cloud Console UI、使用 gcloud 或通过 API 启动和停止实例:
https://cloud.google.com/compute/docs/instances/schedule-instance-start-stop
,我直接使用vm instance API。无需云功能。
以下是api描述的链接: https://cloud.google.com/compute/docs/reference/rest/v1/instances/stop
您可以通过类似的方式启动引擎。
示例如何配置调度程序: