使用Deployment Manager部署VM实例

时间:2019-07-06 14:12:53

标签: google-cloud-platform google-deployment-manager

尝试使用Deployment Manager将VM部署到名为“ MyNet”的自定义VPC网络,只是不知道如何将我的自定义VPC网络放入yaml文件,还希望使用SSD而不是标准PERSISTENT磁盘。

   resources:
   - name: vm
    type: compute.v1.instance
    properties:
    zone: northamerica-northeast1-a
     machineType: zones/northamerica-northeast1-a/machineTypes/f1-micro
     disks:
   - deviceName: boot
      type: PERSISTENT
     boot: true
     autoDelete: true
     initializeParams:
       sourceImage: projects/centos-cloud/global/images/family/centos-7
   networkInterfaces:
     - network: global/networks/default
    accessConfigs:
      - name: External NAT
       type: ONE_TO_ONE_NAT

1 个答案:

答案 0 :(得分:0)

您可以查看this example explaining how to create two VMs and a custom network with Google Deployment Manager。在此存储库中,您还可以找到其他可能有用的示例。

无论如何,对于您的特定问题:要创建自定义VPC网络,请使用:

- name: my-custom-network
  type: compute.v1.network
  properties:
    routingConfig:
      routingMode: REGIONAL
    autoCreateSubnetworks: true

选中the REST reference of network resource以查找所有可能的参数。

要引用您的自定义网络,并且还要为您的VM使用 SSD 而不是 Standard disk

  1. networkInterfaces部分(network: $(ref.my-custom-network.selfLink))中引用自定义网络
  2. 在您的VM配置中添加disks.initializeParams.diskType属性

最后,对于您的VM,您应该编写:

- name: vm
  type: compute.v1.instance
  properties:
    zone: northamerica-northeast1-a
    machineType: zones/northamerica-northeast1-a/machineTypes/f1-micro
    disks:
    - deviceName: boot
      type: PERSISTENT
      boot: true
      autoDelete: true
      initializeParams:
        sourceImage: projects/centos-cloud/global/images/family/centos-7
        diskType: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/zones/northamerica-northeast1-a/diskTypes/pd-ssd
    networkInterfaces:
      - network: $(ref.my-custom-network.selfLink)
        accessConfigs:
        - name: External NAT
          type: ONE_TO_ONE_NAT

对于磁盘,请注意pd-ssd属性末尾的disks[0].initializeParams.diskType,而不是pd-standard(默认)。检查REST reference of instance resource的其他参数。