等待作业在Google计算引擎上完成的最简单方法是什么?使用bash shell,从windows运行,使用gcloud设置。
让我们说我启动一个实例
gcloud compute instances create gci --image-family gci-stable --image-project google-containers \
--scopes 773889352370-compute@developer.gserviceaccount.com="https://www.googleapis.com/auth/cloud-platform" \
--boot-disk-size "40" \
--metadata-from-file startup-script=SubmitJson.sh $MONTH
这样我就有了一个运行小作业的启动脚本(在Google CloudML上分析一些图像)。我想在继续之前等待工作完成。
我可以轮询其状态
gcloud compute instances describe gci
返回一长串规范
C:\Program Files (x86)\Google\Cloud SDK>gcloud compute instances describe gci
canIpForward: false
cpuPlatform: Intel Sandy Bridge
creationTimestamp: '2017-02-19T20:42:38.878-08:00'
disks:
- autoDelete: true
boot: true
deviceName: persistent-disk-0
index: 0
interface: SCSI
kind: compute#attachedDisk
licenses:
- https://www.googleapis.com/compute/v1/projects/google-containers/global/licenses/gci-public
mode: READ_WRITE
source: https://www.googleapis.com/compute/v1/projects/api-project-773889352370/zones/us-central1-a/disks/gci
type: PERSISTENT
id: '4161667477774257489'
kind: compute#instance
machineType: https://www.googleapis.com/compute/v1/projects/api-project-773889352370/zones/us-central1-a/machineTypes/n1-standard-1
metadata:
fingerprint: zaIRTnxUhBE=
kind: compute#metadata
name: gci
networkInterfaces:
- accessConfigs:
- kind: compute#accessConfig
name: external-nat
natIP: 104.197.244.99
type: ONE_TO_ONE_NAT
kind: compute#networkInterface
name: nic0
network: https://www.googleapis.com/compute/v1/projects/api-project-773889352370/global/networks/default
networkIP: 10.128.0.2
subnetwork: https://www.googleapis.com/compute/v1/projects/api-project-773889352370/regions/us-central1/subnetworks/default
scheduling:
automaticRestart: true
onHostMaintenance: MIGRATE
preemptible: false
selfLink: https://www.googleapis.com/compute/v1/projects/api-project-773889352370/zones/us-central1-a/instances/gci
serviceAccounts:
- email: 773889352370-compute@developer.gserviceaccount.com
scopes:
- https://www.googleapis.com/auth/cloud-platform
status: RUNNING
tags:
fingerprint: 42WmSpB8rSM=
zone: https://www.googleapis.com/compute/v1/projects/api-project-773889352370/zones/us-central1-a
我可以在循环中执行此操作,每隔X秒,等待状态变为TERMINATED,但这看起来效率非常低。 AWS有一个等待ec2的功能。我期望看到类似的功能,但无法找到它。同步运行。
相关问题,但请注意我对kubernetes群集资源不感兴趣:Wait for job/pod completion in Kubernetes or Google Container Engine