gpt4 book ai didi

google-cloud-platform - 如何通过 GCP 部署管理器更新机器类型属性

转载 作者:行者123 更新时间:2023-12-02 21:06:09 24 4
gpt4 key购买 nike

我有一个如下所示的用于计算实例类型的 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 的环境中。现在过了一段时间我意识到我需要更改该实例的机器类型。例如,我希望我的质量保证环境更新此资源的机器类型,而不是 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.<br/>
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.

请帮忙。

最佳答案

您可以在部署管理器中更新资源,如果您想要更改资源,则无需创建具有不同名称的新资源。请参阅updating a deployment

您可以使用现有的部署 yaml 文件进行您想要应用的更改,然后更新现有的部署:

gcloud deployment-manager deployments update [EXISTING DEPLOYMENT] --config [UPDATED YAML]

请注意,您的实例必须停止。对 changing machine type 的所有其他影响申请。此外,任何永久磁盘上的数据都不会丢失。

更新完成后记得打开实例!

关于google-cloud-platform - 如何通过 GCP 部署管理器更新机器类型属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50170298/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com