Skip to content

Running OSv on Google Compute Engine

WALDEMAR KOZACZUK edited this page Sep 8, 2024 · 5 revisions
Step 1: Use a default GCE project or Create a new one

https://cloud.google.com/console

Step 2: Download, Install and Init SDK

https://cloud.google.com/sdk/

wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-x86_64.tar.gz
tar xfx ./google-cloud-cli-linux-x86_64.tar.gz 
./google-cloud-sdk/install.sh

gcloud init
Step 3: Create an OSv image to deploy to GCE
$ cd osv
$ ./scripts/build image=golang-pie-httpserver,httpserver-monitoring-api
Step 4: Set the project id and zone id
$ gcloud config set project <YOUR_PROJECT_ID>
$ gcloud config set compute/zone <YOUR_ZONE> #for example us-east1-c
Step 5: Deploy the OSv image as a new GCE instance
./scripts/deploy_to_gce.sh create <OSV-IMAGES-FOLDER> <OSV-INSTANCE-NAME>

The script deploy_to_gce.sh does the following:

  • creates an image tarball of the last built OSv image
  • copies the image tarball to the Google storage folder specified by <OSV-IMAGES-FOLDER>
  • creates a GCE instance image of the tarball in GCS
  • creates and starts a new GCE instance of the image created above
  • creates firewall rules to allow networking traffic on ports 8000 and 9000

Also, the script takes a third optional parameter: the instance type. The default one is f1-micro.

Step 6: Describe the image
$ ./scripts/deploy_to_gce.sh describe <OSV-IMAGES-FOLDER> <OSV-INSTANCE-NAME>
Step 7: Test the image
$ curl http://<PUBLIC_IP>:8000/os/dmesg
$ curl http://<PUBLIC_IP>:9000/
Step 8: Optionally delete the GCE instance and all related artifacts
$ ./scripts/deploy_to_gce.sh delete <OSV-IMAGES-FOLDER> <OSV-INSTANCE-NAME>
Clone this wiki locally