Lesson 8 · This repo's IaC: Terragrunt & the env×org matrix
GKE & the cluster
The Terraform that builds the Kubernetes cluster the entire track has been running on.
Your win: read the GKE module and connect its config to things you learned courses ago — the spot node pools (C2), Workload Identity (C3–6), and binary authorization (C5) all originate here.
The cluster is a module, wrapping a community module
The Kubernetes cluster from Course 2 — where every Pod, Service, and Istio sidecar runs — is
provisioned by modules/platforms/gke.tf, which wraps the
well-tested community module terraform-google-modules/kubernetes-engine//modules/beta-public-cluster
(:4-5). You configure it; the upstream module handles the hundreds
of API calls to build a production GKE cluster.
Three settings you'll recognize from earlier courses
node_pools is generated from var.gke.node_pools
(gke.tf:50-59), with spot = np.spot — a boolean per
pool. The actual pool list lives in the cell's locals
(live/stag-manabie/env.hcl:694-1109): on-demand
n2d-highmem-4 (spot = false), spot n2d-highmem-4-spot,
*-runners-spot, GPU *-gpu-spot. So the cost/reliability trade-off
you saw scheduling Pods onto is set in Terraform.
- Workload Identity — enabled by the upstream module; the module outputs
gke_identity_namespace=PROJECT.svc.id.goog, which theappsmodule uses to build the SA bindings (Lesson 9). Without it enabled on the cluster, theiam.gke.ioannotations (C3) would do nothing. - Binary Authorization —
enable_binary_authorization = var.gke.enable_binary_authorizationat gke.tf:111 (Course 5). This is the cluster-side switch that would enforce the attestation policy — the policy the binauthz module defines (currently DRYRUN, C5).
network_policy, database_encryption via
KMS, and remove_default_node_pool. It takes its network from the VPC module via a
Terragrunt dependency (Lesson 5) — private_network =
dependency.vpc.outputs.network_self_link. So "the cluster" is really: this module + the
VPC it depends on + the node pools from env.hcl + WI/binauthz flags.
GKE + the terraform-google-modules kubernetes-engine module
GKE concepts, and the community module this repo wraps (node pools, Workload Identity).
→ cloud.google.com — GKE overview
→ registry — kubernetes-engine module
Check yourself (from memory)
Q1. The GKE module (platforms/gke.tf)…
terraform-google-modules/kubernetes-engine//…/beta-public-cluster
— you configure, upstream builds.
Q2. Whether a node pool is pre-emptible is set by…
spot = np.spot per pool (env.hcl) — the Course-2
spot-node cost trade-off, set in Terraform.
Q3. enable_binary_authorization at gke.tf:111 is…
modules/platforms/gke.tf,
WRAPPING the community terraform-google-modules/kubernetes-engine//…/beta-public-cluster
(:4-5). THREE recognizable settings: (1) SPOT node pools — node_pools from
var.gke.node_pools (:50-59), spot = np.spot; pool list in
env.hcl:694-1109 (on-demand n2d-highmem-4 spot=false, spot pools, GPU spot) = the
C2 L10 cost trade-off, in Terraform. (2) WORKLOAD IDENTITY — enabled by the module; output
gke_identity_namespace = PROJECT.svc.id.goog feeds the apps SA bindings (L9);
without it the C3 annotations do nothing. (3) BINARY AUTHORIZATION —
enable_binary_authorization (:111), the cluster switch for the C5 policy (DRYRUN).
Plus release channel, autoscaling, VPA, network_policy, KMS db encryption; network via the VPC
dependency.1. In-repo: deployments/terraform/modules/platforms/gke.tf:4,50,111; registry — kubernetes-engine.