【发布时间】:2021-09-24 09:50:07
【问题描述】:
我想创建一个WURFL Microservice Basic from the GCP Marketplace 的实例,但我想以编程方式进行,以便在需要时重现它。
并将其解压缩到我的机器上,所以这里有创建 WURFL 解决方案的代码:
test_config.yaml 文件包含有关我的部署的相关信息,我将 serviceAccount、zone、network、subnetwork 和 externalIP 属性更改为我需要它们具有的值:
imports:
- path: wurfl-microservice-basic.jinja
resources:
- name: wurfl-microservice-basic
type: wurfl-microservice-basic.jinja
properties:
zone: europe-west2-a
network:
- sharedresources
subnetwork:
- eu-west2
externalIP:
- NONE
serviceAccount: wurflrunner@XXXXX.iam.gserviceaccount.com
我通过发布来部署:
gcloud deployment-manager deployments create \
wurfl \
--project xxxxxxx \
--config test_config.yaml
为了允许指定 serviceAccount,我必须对部署包进行一些更改。
我在 wurfl-microservice-basic.jinja.schema
的属性中添加了一个 serviceAccount 属性properties:
serviceAccount:
type: string
default: stop@gocreateaservieaccount.com
zone:
type: string
x-googleProperty:
type: GCE_ZONE
machineType:
type: string
default: e2-small
x-googleProperty:
type: GCE_MACHINE_TYPE
zoneProperty: zone
gceMachineType:
minCpu: 2
minRamGb: 1.9990234375
network:
type: array
default: [default]
minItems: 1
maxItems: 1
x-googleProperty:
type: GCE_NETWORK
gceNetwork:
allowSharedVpcs: True
machineTypeProperty: machineType
subnetwork:
type: array
minItems: 1
maxItems: 1
x-googleProperty:
type: GCE_SUBNETWORK
zoneProperty: zone
gceSubnetwork:
networkProperty: network
externalIP:
type: array
default: [EPHEMERAL]
minItems: 1
maxItems: 1
x-googleProperty:
type: GCE_EXTERNAL_IP
gceExternalIp:
networkProperty: network
notConfigurable: False
allowStaticIps: True
bootDiskType:
type: string
default: pd-ssd
x-googleProperty:
type: GCE_DISK_TYPE
zoneProperty: zone
bootDiskSizeGb:
type: integer
default: 20
minimum: 20
maximum: 10000
x-googleProperty:
type: GCE_DISK_SIZE
gceDiskSize:
diskTypeProperty: bootDiskType
在 wurfl-microservice-basic.jinja 我添加了:
{% set serviceAccount = properties["serviceAccount"] %}
并改变:
serviceAccounts:
- email: default
scopes:
- 'https://www.googleapis.com/auth/cloud.useraccounts.readonly'
- 'https://www.googleapis.com/auth/devstorage.read_only'
- 'https://www.googleapis.com/auth/logging.write'
- 'https://www.googleapis.com/auth/monitoring.write'
到
serviceAccounts:
- email: {{ serviceAccount }}
scopes:
- 'https://www.googleapis.com/auth/cloud.useraccounts.readonly'
- 'https://www.googleapis.com/auth/devstorage.read_only'
- 'https://www.googleapis.com/auth/logging.write'
- 'https://www.googleapis.com/auth/monitoring.write'
这导致包成功创建。创建的 VM 允许项目范围的 SSH 密钥:
我被告知这违反了公司政策,需要启用“阻止项目范围的 SSH 密钥”(即选中)。
当我进行更改以允许指定 serviceAccount 时,这相对容易做到,因为 serviceAccount 已经存在于 wurfl-microservice-basic.jinja 但是“块”并非如此项目范围的 SSH 密钥”设置。
请有人告诉我,我需要对下载的部署包进行哪些更改才能启用“阻止项目范围的 SSH 密钥”?
【问题讨论】: