Requirements
Ruby Version
Ruby 2.0 or greater.
Google Cloud Platform (GCP) Project
A Google Cloud Platform account is required. If you do not already have an appropriate "project" in which to run your test-kitchen instances, create one, noting the "project id".
Authentication and Authorization
The underlying API this plugin uses relies on the Google Auth Library to handle authentication to the Google Cloud API. The auth library expects that there is a JSON credentials file located at:
~/.config/gcloud/application_default_credentials.json
The easiest way to create this is to download and install the Google Cloud SDK and run the
gcloud auth login
command which will create the credentials file for you.
If you already have a file you'd like to use that is in a different location, set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable with the full path to that file.
SSH Keys
In order to bootstrap Linux nodes, you will first need to ensure your SSH
keys are set up correctly. Ensure your SSH public key is properly entered
into your project's Metadata tab in the GCP Console. GCE will add your key
to the appropriate user's ~/.ssh/authorized_keys
file when Chef first
connects to perform the bootstrap process.
- If you don't have one, create a key using
ssh-keygen
- Log in to the GCP console, select your project, go to Compute Engine, and go to the Metadata tab.
- Select the "SSH Keys" tab.
- Add a new item, and paste in your public key.
- Note: to change the username automatically detected for the key, prefix your key with the username
you plan to use to connect to a new instance. For example, if you plan to connect
as "chefuser", your key should look like:
chefuser:ssh-rsa AAAAB3N...
- Note: to change the username automatically detected for the key, prefix your key with the username
you plan to use to connect to a new instance. For example, if you plan to connect
as "chefuser", your key should look like:
- Click "Save".
Alternatively, the Google Cloud SDK (a.k.a. gcloud
) will create a SSH key
for you when you create and access your first instance:
- Create a small test instance:
gcloud compute instances create instance1 --zone us-central1-f --image debian-8 --machine-type g1-small
- Ensure your SSH keys allow access to the new instance
gcloud compute ssh instance1 --zone us-central1-f
- Log out and delete the instance
gcloud compute instances delete instance1 --zone us-central1-f
You will now have a local SSH keypair, ~/.ssh/google_compute_engine[.pub]
that
will be used for connecting to your GCE Linux instances for this local username
when you use the gcloud compute ssh
command. You can tell Test Kitchen to use
this key by adding it to the transport section of your .kitchen.yml:
transport:
ssh_key:
- ~/.ssh/google_compute_engine
You can find more information on configuring SSH keys in the Google Compute Engine documentation.