- Sign up for GCP Free Trial (requires credit card for billing).
- Create a Project in the GCP Console.
- Go to Billing → Link a Billing Account to your project.
- Kubernetes Engine API:
- Visit Kubernetes Engine API → Click Enable.
- Compute Engine API:
- Visit Compute Engine API → Click Enable.
- Install Terraform.
- Install Google Cloud SDK and authenticate:
gcloud init # Log in to GCP gcloud auth application-default login
# main.tf
provider "google" {
project = "YOUR_PROJECT_ID" # Replace with your GCP Project ID
region = "us-central1"
}
module "gke" {
source = "terraform-google-modules/kubernetes-engine/google"
project_id = "YOUR_PROJECT_ID"
name = "my-cluster"
region = "us-central1"
network = "default"
subnetwork = "default"
ip_range_pods = ""
ip_range_services = ""
node_pools = [{
name = "default-node-pool"
machine_type = "e2-small"
node_count = 1
}]
}
gcloud services list --enabled | grep -E 'container.googleapis.com|compute.googleapis.com'
- Ensure both APIs appear in the output.
terraform init && terraform plan
terraform apply
terraform destroy # Delete the cluster and all associated resources
- No, but GCP offers:
- Free Tier: $300 credits for new users (valid for 90 days).
- Always Free: Limited resources (e.g., 1 non-preemptible f1-micro VM instance/month), but GKE nodes are not included in "Always Free."
- Cost Note: A small GKE cluster (e.g., 1 node) costs ~$25–$50/month if left running. Always clean up resources after testing!
- Use Preemptible Nodes: Add
preemptible = true
to the node pool (nodes last max 24h, cost 80% less). - Small Machine Types: Use
e2-small
ore2-micro
. - Minimize Node Count: Start with
node_count = 1
. - Delete Clusters: Always run
terraform destroy
after testing.
- Find your Project ID: GCP Console.
- Enable Kubernetes Engine API: Enable API.