使用部署管理器创建虚拟机和其他资源时出现以下错误代码。
错误代码 :
Waiting for create [operation-1599546356618-5aec7686355d6-35c95719-d85f1e9d]...failed. ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1599546356618-5aec7686355d6-35c95719-d85f1e9d]: errors:
- code: RESOURCE_ERROR location: /deployments/quickstart-deployment/resources/quickstart-deployment message: '{"ResourceType":"compute.v1.instance","ResourceErrorCode":"412","ResourceErrorMessage":{"code":412,"message":"Precondition
check failed.","status":"FAILED_PRECONDITION","statusMessage":"Precondition Failed","requestPath":"https://compute.googleapis.com/compute/v1/projects/xxxxxxxxxx/zones/us-central1-a/instances","httpMethod":"POST"}}'
我的 Yaml 文件是:
resources:
- type: compute.v1.instance name: quickstart-deployment properties:
zone: asia-east1-b
machineType: https://www.googleapis.com/compute/v1/projects/xxxx/zones/asia-east1-b/machineTypes/f1-micro
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/xxx/global/networks/default
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
有人可以检查并帮助我解决这个错误吗?
答案1
我已.yaml
根据文档进行了相应更改创建基本模板:
$ cat vm.yaml
resources:
- name: quickstart-deployment
type: compute.v1.instance
properties:
zone: asia-east1-b
machineType: zones/asia-east1-b/machineTypes/f1-micro
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: projects/debian-cloud/global/images/family/debian-9
networkInterfaces:
- network: global/networks/default
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
并且它对我有用:
$ gcloud deployment-manager deployments create vm --config=vm.yaml
The fingerprint of the deployment is b'J_pRfbjbVQy-MLN2gL9NGQ=='
Waiting for create [operation-1599649846919-5aedf80e40181-c0582c09-ed1da9db]...done.
Create operation operation-1599649846919-5aedf80e40181-c0582c09-ed1da9db completed successfully.
NAME TYPE STATE ERRORS INTENT
quickstart-deployment compute.v1.instance COMPLETED []
$ gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
quickstart-deployment asia-east1-b f1-micro 10.140.0.2 XXX.199.YYY.111 RUNNING
解决您的问题请按照以下步骤操作:
- 尝试手动创建 VM 实例。
.yaml
根据文档进行相应更改创建基本模板或者尝试我的.yaml
。
请记住,您的.yaml
格式应该正确。
答案2
我能够使用 Google 提供的基本模板创建部署,但我注意到我的虚拟机本身没有获取任何公共 IP。(公共 IP 列为空白)。当我手动部署虚拟机时,我也注意到了同样的情况。
谷歌最近做了什么改变吗?