How to deploy a compute instance with no public IP

时间:2018-12-27 12:55:43

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

How can I deploy a computer instance with no public IP using GCP Deployment Manager?

Looking at the yaml configuration file, I get an error if I don't include anything in accessConfigs. networkInterfaces is also mandatory. At the moment my configuration file for the resource looks like this:

- type: compute.v1.instance                                                                      
  name: cassandra-node-1                                                                           
  properties:                                                                                        
    zone: europe-west2-c                                                                             
    machineType: https://www.googleapis.com/compute/v1/projects/affable-seat-213016/zones/europe-west2-c/machineTypes/n1-standard-1                                                                   
    disks:                                                                                           
    - deviceName: boot                                                                                 
      boot: true                                                                                       
      autoDelete: true                                                                                 
      initializeParams:                                                                                  
        sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20181204                                                                        
      networkInterfaces:                                                                               
      - accessConfigs: 

I have tried several combinations of accessConfigs and networkInterfaces, but so far only the ones that work are the ones with the snippet below, but that assigns a public IP to the instance.

networkInterfaces:                                                                               
- accessConfigs:                                                                                  
   - name: External NAT                                                                               
     type: ONE_TO_ONE_NAT

EDIT
Deploying with no accessConfig gives error:

ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1545956660669-57e0a1598ea49-702a8e20-89ae5f53]: errors: - code: CONDITION_NOT_MET
location: /deployments/test/resources/cassandra-node-1->$.properties
message: '"/networkInterfaces": domain: validation; keyword: type; message: instance
does not match any allowed primitive type; allowed: ["array"]; found: "null"'

1 个答案:

答案 0 :(得分:2)

如果您完全删除了accessConfigs成员(而不是提供一个空的accessConfigs),则该实例将创建而没有外部IP地址。