gcloud compute instance creation with shared network resources

2,618 views
Skip to first unread message

John Hoffman

unread,
Nov 2, 2017, 3:28:47 PM11/2/17
to gce-discussion
I'm having a problem creating compute instances using shared network resources.  I was able to get it to work using the --network-interface subnet=<URL>.  However what I want to do is find a way to do this using the --network and --subnet options.  

My goal is to be able to use chef knife to create and provision instances.  The plugin for google-knife doesn't include the --network-interface option.  So I need a way to create the instance with --network and --subnetwork flags.

Is there any way to make this work?  Within my google project there are no networks so my only option is to select networks shared.

When I go into the web console and go through the create instance setup and then click command line and run it in gcloud it also fails indicating the selected subnet resource cannot be found.  The invalid field shows the subnet being listed in my project not the shared project.

So is there a way to set this up?  Can a network created in a separate project and then shared to my project be setup so that it appears in my project?

thanks,
John

Kamran (Google Cloud Support)

unread,
Nov 2, 2017, 9:20:18 PM11/2/17
to gce-discussion

Hello John,

You can share Virtual Private Cloud (VPC) networks across projects in your Cloud Organization. This article is an overview of Shared VPC and this article describes how to provision shared VPC networks for your projects. In the Creating resources section of the article by clicking on GCLOUD tab, you will find some examples of creating GCE VM instances by using --subnet and --network flags.

I hope this helps.

John Hoffman

unread,
Apr 11, 2019, 8:13:49 AM4/11/19
to gce-discussion
The migration to google cloud was postponed but it is back.  So I still have this issue.  The problem isn't with creating vpc's.  The network team in my company have created a network project and created various subnets and shared them.  So we do have vpcs that are shared and we have managed to create an instance with the gcloud command using --subnet flag with a long directory like name that ends in the shared subnet.

My problem is that I'm trying to use chef & knife to create servers.  So the command I'm using is 

'knife google server create ${server} --gce-image-project ${SharedImages} --gce-image ${imageName} --gce-machine-type ${machineType} --gce-subnet ${same path used for gcloud} ...various ssh options'  

The error I get is 'ERROR: RuntimeError: Invalid network: default'

the command, 
gcloud compute networks list 

doesn't give any networks.  

going into the web interface to create a vm, selecting the more advanced options from the link 'Management, security, disks, networking, sole tenancy', then selecting networking.  This shows under network interfaces "click-here-and-select-shared-subnet-region-specific', clicking on this with the button Networks in this Project shows no networks.

Selecting 'Networks shared with me (from host project: "network team"), gives me some subnets I can use.  These are the subnets I'm able to use with the gcloud command.

So coming back to my original issue, using the knife google command I have two options --gce-network and --gce-subnet.  Is there some way to specify a shared resource for network?  It seems like anything I've tried putting in the gce-network option returns an error similar to the default error I described above.

This is a link to the knife-google plugin docs https://github.com/chef/knife-google

On Thursday, November 2, 2017 at 3:28:47 PM UTC-4, John Hoffman wrote:

Germán (Google Cloud Support)

unread,
Apr 23, 2019, 3:57:25 PM4/23/19
to gce-discussion
Hello,

Please keep in mind that we dont support third party tools like Knife-google plugins. If using the Gcloud command works correctly, it only confirms there's an issue with the third party tool you are trying to use.

As per the ‘No networks’ showing on your project, can you confirm you actually have networks created in your project? I can see that you are sharing them from another google project it seems, if so, have you correctly configured the shared VPC [1] or are you using another method?
Reply all
Reply to author
Forward
0 new messages