【发布时间】:2021-10-09 10:20:29
【问题描述】:
我想通过 Google Cloud Deployment Manager 部署 PHP 应用程序。创建实例后,应在 VM 上安装 PHP(和其他一些 Linux 软件包)。这可能在模板文件中吗?还是我必须创建自定义 VM 映像?
我只设法创建了虚拟机,但没有找到有关如何自动安装软件包的任何信息。
{% set COMPUTE_URL_BASE = 'https://www.googleapis.com/compute/v1/' %}
{% set BASE_NAME = env['deployment'] + '-' + env['name'] %}
{% macro GlobalComputeUrl(project, collection, name) -%}
{{ COMPUTE_URL_BASE }}projects/{{ project }}/global/{{ collection }}/{{ name }}
{%- endmacro %}
{% macro ZonalComputeUrl(project, zone, collection, name) -%}
{{ COMPUTE_URL_BASE }}projects/{{ project }}/zones/{{ zone }}/{{ collection }}/{{ name }}
{%- endmacro %}
resources:
- name: {{ BASE_NAME }}
type: compute.v1.instance
properties:
zone: {{ properties['zone'] }}
machineType: {{ ZonalComputeUrl(env['project'], properties['zone'], 'machineTypes', 'e2-micro') }}
metadata:
items:
- key: gce-container-declaration
value: |
{{ imports[properties['containerManifest']]|indent(12) }}
disks:
- deviceName: boot
type: PERSISTENT
autoDelete: true
boot: true
initializeParams:
diskName: {{ BASE_NAME }}-disk
sourceImage: {{ GlobalComputeUrl('cos-cloud', 'images', properties['containerImage']) }}
networkInterfaces:
- accessConfigs:
- name: external-nat
type: ONE_TO_ONE_NAT
network: {{ GlobalComputeUrl(env['project'], 'networks', 'default') }}
serviceAccounts:
- email: default
scopes:
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring.write
【问题讨论】:
标签: google-cloud-platform config google-deployment-manager