Getting Started with GCP

A brief intorduction to Google Cloud Platform from my learning perspective

What is GCP

Google Cloud Platform (GCP) is basically Googles public cloud offering, at the time of writing it's the third largest public cloud behing AWS and Azure, but that's only with a 8% market share. Like most cloud vendors you can sign up to an initial "experimentation" offer, that's currently $200 worth of credits for 90 Days.

Why use GCP

So the current standing is that AWS domainates with a 31% market share, followed by Azure with 22% and then GCP with their measly 8%. So why would I want to use Googles offer, essentially price. I actually wanted to store some container images, I did some Googling and checked and compare Azure's ACR pricing with GCP and it seemed like a no brainer, Azure were planning to charge me £3.75 a month (based on the basic tier day rate on a 30 day basis) for the privildge, GCP would offer me so much data in and out free, beyond that they'd charge me per data consumption above the free tier. So it's basically free image storage. Easy choice.

Terraforming a GAR instance

I actually elected to use GAR (Google Artifact Registry) as opposed to the GCR (Google Container Registry) becasue it was the newer offering and seemd like fun!

resource "google_artifact_registry_repository" "blog-repo" {
  provider = google-beta

  location = var.google_location
  repository_id = "blog"
  description = "Contains the Tech Blog Docker images"
  format = "DOCKER"
}

And that's all the terraform I needed!

I did have to set up a few thing in GCP which initially confused me, but soon made sense.

How GCP Works

So in my Azure experience so far, everything is built in a hierarchal way, I have my subscription, then the resource groups, then the resources in each of those and that's sort of how I think of my projects or services as belonging to resource groups.

GCP is very different, you have the top level of just the account, then in there can be several projects, each with it's own specific resources. Resources in GCP are initially disabled and you have to "enable the API" so that in essence you can start building a given resource.

For example I wanted to build / use GAR, I therefore had to "enable" the API that is responsible for that resource:

GAR API

Access is then explicitly given, typically through a service account associated to the API / Resource that you intend to use:

GCP IAM Service Account

You can then create keys for the service account and configure in them in whatever consumer you need, be it GitHub for actions that push images (in this case) or in Terraform Cloud at the level of the project.

Other differences

So the main thing I noticed is that GCP has everything by default in the Left Hand Panel, and that in the nav bar at the top you can switch projects, so if you're in the IAM section of one project, you can switch projects and be in the IAM section of another.

It was confusing at first, as I was used to this hierarchal view of sub -> resource group -> stuff but I quickly came round to the idea and got used to it.

What else have I started

Well once I got in with the GAR stuff, I was curious to see what else GCP had to offer, one thing that stood out was the Cloud Run which is a serverless on deamnd compute space that harnesses the power of a container image to provision resources or apps.

I got curious, tried to figure out the cost and then thought why not move some of beerbuddies over to this platform. I had been running it as a static site in Azure, but had recently ran into some difficulties with routing to the apex domain in the Azure CDN and that sort of bugged me. So Cloud Run seemed to offer a solution, as well as easily managed HTTPS redirect and SSL cert provisioning (all in terraform!) which made this a sort of easy no brainer (the implementation of which I'll save for another post). So long story short, I'm currently running the web app in GCP and the content through Azure!

What comes next

Well hopefully this sort of whets your appetite and you'll want to find out a little bit more.

I plan on writing a little more on the experience so I intend to cover:

  • GAR and running Kubernets on a Raspberry Pi (Ubuntu Server)
  • Building a Cloud Run Web App

Final Thoughts

Well I'll be honest I am pretty impressed with the ease of use that GCP has brought, getting my head around service accounts and keys along with the terraform stuff was initially a little awkward, but like most things when it starts to work and you make some progress it all sort of comes together.

I'm curious to see what else GCP has to offer, but it might have to wait for the right project or budget to get me to commit to it.