我有一个 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.
请帮忙。