Running on Google Compute Engine

The GCE client utilities are part of CernVM, so you can use an interactive CernVM to manage your GCE batch CernVMs.

CernVM 4

On CernVM 4, cloud-init and amiconfig are supported on GCE. The following steps upload the image and start an instance on GCE:

  • Login to GCE and switch to a project with
    gcloud auth login
    gcloud config set project <PROJECT NAME>
  • If you haven't already done so, upload the GCE .tar.gz image to Google cloud storage with
    gsutil cp <GCE IMAGE> gs://<BUCKET>/<GCE IMAGE>
    gcloud compute images create <IMAGE NAME> --source-uri gs:///<BUCKET>/<GCE IMAGE>
  • If you haven't already done so, create an ssh key pair to login to the VMs in your project
    ssh-keygen -f <KEYPAIR>
    gcloud compute project-info add-metadata --metadata "sshKeys=root:$(cat <KEYPAIR>.pub)"
  • Start an instance with
    gcloud compute instances create <INSTANCE NAME> \
      --image <IMAGE NAME> --metadata-from-file user-data=<FILE NAME>

CernVM 3

For CernVM 3, only amiconfig contextualization is supported. By convention, amiconfig looks for Base64 encoded user data under the key cvm-user-data on the GCE meta data server.

The following steps upload the image and start an instance on GCE:

  • Upload the GCE .tar.gz image to Google cloud storage with gsutil cp <GCE IMAGE> gs://<BUCKET>/<GCE IMAGE>
  • Add the image to you project with gcutil addimage <IMAGE NAME> gs://<BUCKET>/<GCE IMAGE>
  • Create an ssh keypair with ssh-keygen -f <KEYPAIR>

Start the instance with the user data in the file user-data:

gcutil addinstance --image=<IMAGE NAME> --kernel="" <INSTANCE NAME> \
  --metadata=cvm-user-data:$(base64 -w0 user-data) \
  --authorized_ssh_keys=root:<KEYPAIR>.pub

You are here