【发布时间】:2018-05-04 08:15:58
【问题描述】:
我有一个如下所示的用于计算实例类型的 python 模板以及其他所需的 config.yaml 文件。
...
CONTROLLER_MACHINE_TYPE='n1-standard-8'
controller_template = {
'name': 'controller-it',
'type': 'it_template.py',
'properties': {
'machineType': CONTROLLER_MACHINE_TYPE,
'dockerImage': CONTROLLER_IMAGE,
'dockerEnv': {
'ADC_LISTEN_QUEUE': 'controller-subscriber'
},
'zone': ZONE,
'network': NETWORK_NAME,
'saEmail': SA_EMAIL
}
}
it_template.py 内容
def GenerateConfig(context):
resources = [{
'name': context.env['name'],
'type': 'compute.v1.instanceTemplate',
'properties': {
'zone': context.properties['zone'],
'properties': {
"machineType": context.properties['machineType'],
"metadata": {
"items": [{
"key": 'gce-container-declaration',
"value": GenerateManifest(context)
}]
}, ...
我已经将它部署到名为 qa 的环境中。现在一段时间后,我意识到我需要更改此实例的机器类型。例如,我希望我的 qa 环境更新此资源的机器类型,而不是 n1-standard-8。
但是我没有看到任何提到更新任何资源属性的示例。
我们可以使用 gcp 部署管理器更新环境中资源的属性吗? 或者我需要添加具有其他名称和所需机器类型属性的新资源?
更新
按照@jordi Miralles 的建议,我修改了我的模板,将 machineType 设为 n1-standard-16 并尝试更新部署。
但我得到以下错误
cloud deployment-manager deployments update qa --config dm_config.yaml
The fingerprint of the deployment is KkD38j9KYiBTiaIW8SltbA==
Waiting for update [operation-1525444590548-56b623ef1b421-b4733efd-53174d1b]...failed.
ERROR: (gcloud.deployment-manager.deployments.update) Error in Operation [operation-1525444590548-56b623ef1b421-b4733efd-53174d1b]: errors:
- code: NO_METHOD_TO_UPDATE_FIELD
message: No method found to update field 'properties' on resource 'controller-it'
of type 'compute.v1.instanceTemplate'. The resource may need to be recreated with
the new field.
请帮忙。
【问题讨论】:
标签: google-cloud-platform google-deployment-manager