skip to Main Content

Try to deploy the VM to custom VPC network called “MyNet” using deployment manager, just don’t know how to put my custom VPC network in the yaml file, also want to use SSD instead of standard PERSISTENT disk as well.

   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

2

Answers


  1. You can take a look at this example explaining how to create two VMs and a custom network with Google Deployment Manager. In this repository, you can also find other examples that might be useful.

    Anyway, for your specific problem : to create a custom VPC network, use :

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

    Check the REST reference of network resource to find all possible parameters.

    To reference your custom network and also to use SSD instead of Standard disk for your VM :

    1. reference the custom network in networkInterfaces section (network: $(ref.my-custom-network.selfLink))
    2. add the disks.initializeParams.diskType property in your VM configuration

    To conclude, for your VM, you should write :

    - 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
    

    For the disk, notice the pd-ssd at the end of the disks[0].initializeParams.diskType property, instead of pd-standard (default). Check the REST reference of instance resource for other parameters.

    Login or Signup to reply.
  2. You just need to specify a subnetwork of custom VPC, That sit

    resources:
    - name: "vm-1"
      type: compute.v1.instance
      properties:
        zone: {{zone}}
        machineType: zones/{{ zone }}/machineTypes/n1-standard-1
        disks:
        - deviceName: boot
          type: PERSISTENT
          boot: true
          autoDelete: true
          initializeParams:
            sourceImage: projects/centos-cloud/global/images/family/centos-7
        networkInterfaces:
        - subnetwork: projects/<project>/regions/<region>/subnetworks/<subnetwork_name>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search