Skip to content

About

Workshop: build your own platform on GKE with Terraform, guided by AI coding tools.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Build a platform on Kubernetes in GCP

In this workshop you build your own small platform on Google Kubernetes Engine (GKE), starting from an empty Terraform file. You are expected to lean heavily on AI tools (Claude Code, Copilot, Cursor, ChatGPT, …) to write the code. The goal is not to type every line yourself, but to understand what you build, make good decisions, and get it running.

This repo only gives you the starting point: terraform.tf with the provider setup for the shared workshop project. Everything else you build in main.tf (and any other files you like).

Prerequisites

Install these before the workshop:

Tool Notes
gcloud CLI brew install --cask google-cloud-sdk
Terraform >= 1.17 We recommend tenv (brew install tenv). It reads .terraform-version and installs the right version for you.
kubectl brew install kubectl
gke-gcloud-auth-plugin gcloud components install gke-gcloud-auth-plugin. See troubleshooting if kubectl can't find it.
An AI coding tool Whichever you prefer. An agent that can run commands in your terminal (e.g. Claude Code) works especially well.

Getting started

  1. Log in to Google Cloud. You need both logins: the first is for gcloud, the second is what Terraform uses.

    gcloud auth login
    gcloud auth application-default login
    gcloud config set project cloud-labs-workshop-42clws

    Terraform gets the project from terraform.tf, but gcloud (and any AI agent running gcloud commands for you) needs it set as the default.

  2. Create main.tf with a unique id. Use something short and lowercase, like your name. It is used to prefix all your resources so they don't collide with other participants'.

    locals {
      id = "yourname"
    }
  3. Initialize and check that everything works.

    terraform init
    terraform apply

    The apply should create nothing, and print current_user_email with your email. If it does, you're ready.

What's in terraform.tf

  • Terraform and provider versions: Terraform >= 1.17 and the Google provider.
  • Provider config: the workshop project, region europe-west1 and zone europe-west1-b. Resources you create use these defaults unless you say otherwise.
  • current_user_email output: shows which Google account Terraform is running as.
  • id_is_set check: warns you if local.id is empty.

Don't change this file unless you know why.

Rules for the shared project

Everyone works in the same GCP project, so:

  • Prefix every resource name with ${local.id}, e.g. "${local.id}-cluster".
  • Don't enable or disable project APIs (google_project_service) from your Terraform. Destroying it would turn the API off for everyone. Ask a facilitator if an API is missing.
  • Keep it small. Use a zonal cluster and small machine types (e.g. e2-standard-2). We have limited quota.
  • Clean up afterwards with terraform destroy. Set deletion_protection = false on your cluster, or destroy will fail.
  • Never run destroy or delete commands on resources you don't own. Be careful when your AI tool suggests gcloud commands, and check what they target.

The workshop

The workshop is 3 hours, and is the first in a series: later workshops build further on the platform you start today. So don't worry about getting everything done, but do aim to finish steps 1–3.

Each step lists what to aim for. How you get there, and which AI prompts you use, is up to you. Everything happens locally on your machine. Committing to your local clone after each step is a good habit: it gives you a checkpoint to go back to if your AI tool takes a wrong turn.

1. A Kubernetes cluster

Create a VPC network, a subnet and a GKE cluster with a node pool, all in Terraform. Creating the cluster takes around 10 minutes, so use the time to read up on what you're creating.

Done when: kubectl get nodes shows at least one Ready node.

Things to think about: Why remove the default node pool? What are secondary IP ranges used for? Zonal or regional?

Tip: gcloud container clusters get-credentials <cluster> --zone europe-west1-b sets up kubectl for your cluster. Make it a Terraform output.

2. Understand what you got