Google Compute Engine (GCE) is the Infrastructure as a Service (IaaS) component of Google Cloud Platform which is built on the global infrastructure that runs Google’s search engine, Gmail, YouTube, and other services. GCE enables users to launch virtual machines on demand. Juju can use GCE by communicating with it via API calls.
A Google account is required. See http://google.com .
A GCE account is required. See https://cloud.google.com/compute/ .
The Juju client (the host running the below commands) will need the ability to contact the GCE infrastructure on TCP ports 22 and 17070.
Proceed to install the software.
sudo apt-get update sudo apt-get install -y juju-core
A separate GCE project is needed.
According to Google: "A project is a container for all GCE resources. Each project is a compartmentalized world. They do not share resources, can have different owners/users, and are billed separately.".
Create a project now. If you have already used GCE your existing projects will be listed in the pull-down menu with one being selected as your currently active project (here 'Juju-GCE'). The dialog is found at the top-right corner:
Enter some details. If you have already created a project in the past you will not see the extra two questions shown below:
The project id (used later) will be generated automatically. Use the 'Edit' button to change it.
The Google Compute Engine API needs to be enabled for your new project in order for Juju to communicate with it. This is done automatically if a "billing method" has been set up. By following the below steps you will discover whether you need to set up billing or not.
At the top-left of the web UI there is an icon representing 'Product & services'. It is denoted by this icon:
Click through and select 'API Manager'. By default you will be on the 'Overview' screen, it will show:
Select 'Compute Engine API' to get:
The API is already enabled if the button displays 'Disable API'. If the button shows 'Enable API', clicking it may prompt you to set up a billing method (if not already done).
A collection of credentials-related material will be required for Juju to communicate with your GCE project. This is obtained by downloading a file from the UI.
Return to the 'API Manager' and choose the 'Credentials' screen. By default you will be within the 'Credentials' tab. Click the 'New credentials' button and choose 'Service account key' from the 3 options available:
In the ensuing dialog, select 'Compute Engine default service account' and 'JSON' key type:
Once the 'Create' button is pressed you will be prompted to download a file. This is the file we're after. Store it safely as this file cannot be regenerated (although a new one can easily be created).
Place this file where the Juju client can find it. This may or may not be on
the computer you downloaded the file to. We recommend the
For the current example, the file is called
on our project name of 'Juju-GCE'. Let it be put here:
Warning: Due to LP #1533790 make a copy of the original file and put it in another location. Edit the original file by removing the sections containing these keywords: 'project-id', 'auth-uri', 'token_uri', 'auth_provider_x509_cert_url', and 'client-x509-cert-url'.
If this is a new Juju install then you do not yet have a
~/.juju/environments.yaml file. Create one with
If it does exist (but it was created with an older version of Juju), first move it out of the way (back it up) and then generate a new one. Alternatively, you can output a generic file to screen (STDOUT) and paste the GCE parts into your existing file:
juju generate-config --show
The file will contain a section for the GCE provider.
Values will need to be found for the following parameters:
The value of
auth-file is the path to the credentials file downloaded
The value of
project-id is based on the name of the project you created earlier.
Take it from the downloaded file.
According to all the above, the GCE section of file
this example would look like this (comments removed for simplicity):
gce: type: gce auth-file: /home/ubuntu/.juju/Juju-GCE-f33a6cdbd8e3.json project-id: juju-gce-1204
Finally, switch to the GCE provider and bootstrap:
juju switch gce juju bootstrap --debug
A successful bootstrap will result in the controller being visible in the GCE console:
See General configuration options for additional and advanced customization of your environment.
The gcloud compute tool is a CLI utility for querying and configuring a CGE account/project. It is not required nor sufficient for setting up Juju for GCE. It does, however, have many uses. In particular, it can be used to change defaults such as compute zone and region. The Google Cloud SDK gets installed along with the tool.
curl https://sdk.cloud.google.com | bash exec -l $SHELL gcloud init
For further information on the gcloud tool: