Provision a GKE Cluster in GCP

In the "Code Editor" tab, edit the following files:

  • variables.tf: Define input variables project_id (string, no default), region (string, default: us-central1), cluster_name (string, default: my-gke-cluster), node_count (number, default: 1), and machine_type (string, default: e2-medium), each with appropriate descriptions.
  • outputs.tf: Define outputs cluster_name (GKE cluster name) and cluster_endpoint (cluster endpoint).
  • gke.tf: Configure a GKE cluster using the defined variables, in us-central1, with a default node pool (to be removed) and a separate node pool with var.node_count nodes and var.machine_type.
  • terraform.tfvars: Set project_id = "my-gcp-project".

The provider.tf file is pre-configured and read-only.

GitOps Repository

  • 📁 /root/learn-terraform-gcp-gke
    • 📄 provider.tf
    • 📄 gke.tf
    • 📄 variables.tf
    • 📄 outputs.tf
    • 📄 terraform.tfvars

Code Editor

Terminal