我有一个部署,其中包括一个托管实例组和两个实例模板(A和B)。最初使用实例组引用实例模板A创建了部署。
我尝试使用Deployment Manager更新实例模板B中的sourceImage( gcloud beta Deployment-manager部署更新了my-deployment --template ... ),但是出现了以下错误:
ERROR: (gcloud.beta.deployment-manager.deployments.update) Error in
Operation [operation-1538798895713-57787898f4ae9-8b478716-0bb72a09]:
errors:
- code: NO_METHOD_TO_UPDATE_FIELD
message: No method found to update field 'properties' on
resource 'fwp-app-preprod-instance-template-a' of type
'compute.v1.instanceTemplate'. The resource may need to be
recreated with the new field.
我应该明确指出,我对原始部署所做的唯一更改是实例模板的sourceImage。
是否可以通过Deployment Manager执行实例模板的更新,以便它引用更新的sourceImage?
该错误清楚地表明可能需要重新创建资源(实例模板),我很高兴Deployment Manager能够做到这一点。但是我不知道如何指示/强制部署管理器执行该操作。
我毫不怀疑它可以在Deployment Manager之外完成,但我想避免配置漂移。
我的app.jinja.schema:
imports:
- path: instance-group.jinja
- path: instance-template.jinja
我的app.jinja:
resources:
- name: instance-template-a
type: instance-template.jinja
properties:
name: {{ env["deployment"] }}-instance-template-a
machineType: g1-small
sourceImage: "projects/my-project/global/images/my-image"
diskSizeGb: '30'
- name: instance-template-b
type: instance-template.jinja
properties:
name: {{ env["deployment"] }}-instance-template-b
machineType: g1-small
sourceImage: "projects/my-project/global/images/my-image"
diskSizeGb: '30'
- name: fwp-instance-group
type: instance-group.jinja
我的instance-group.jinja:
resources:
- name: 'instance-group-{{ env["deployment"] }}'
type: compute.v1.regionInstanceGroupManager
properties:
baseInstanceName: ig-instance-{{ env["deployment"] }}
instanceTemplate: '$(ref.{{ env["deployment"] }}-instance-template-a.selfLink)'
targetSize: 1
region: australia-southeast1
- name: 'autoscaler-{{ env["deployment"] }}'
type: compute.v1.regionAutoscalers
properties:
autoscalingPolicy:
coolDownPeriodSec: 60
loadBalancingUtilization:
utilizationTarget: 0.9
maxNumReplicas: 10
minNumReplicas: 2
target: $(ref.instance-group-{{ env["deployment"] }}.selfLink)
region: australia-southeast1
还有我的instance-template.jinja
resources:
- name: {{ properties["name"] }}
type: compute.v1.instanceTemplate
properties:
name: {{ properties["name"] }}
description: ''
properties:
machineType: {{ properties["machineType"] }}
tags:
items:
- no-ip
- web-server
- http-server
- https-server
disks:
- type: 'PERSISTENT'
boot: true
mode: 'READ_WRITE'
autoDelete: true
deviceName: instance-device
initializeParams:
sourceImage: {{ properties["sourceImage"] }}
diskType: 'pd-standard'
diskSizeGb: {{ properties["diskSizeGb"] }}
canIpForward: false
networkInterfaces:
- network: projects/my-project/global/networks/vpc-fwp-nonprod
subnetwork: projects/my-project/regions/australia-southeast1/subnetworks/subnet-private-fwp-nonprod
aliasIpRanges: []
labels: { environment: {{ env["deployment"] }}, tenancy: "fwp-nonprod" }
scheduling:
preemptible: false
onHostMaintenance: MIGRATE
automaticRestart: true
nodeAffinities: []
serviceAccounts:
- email: some-service-account@developer.gserviceaccount.com
scopes:
- https://www.googleapis.com/auth/cloud-platform
答案 0 :(得分:0)
要重述评论:
DM配置包括托管实例组的实例模板。更改源图像正在尝试更改模板中使用的图像。
很遗憾,instance templates are immutable once created
“因此,无法在创建现有实例模板后对其进行更新或更改。”
这说明了返回的错误消息。更改要用于托管实例组的映像的正确方法是创建一个新模板,并在该组上执行rolling update,并使用新实例模板。