So I recently came across this article: https://redmaple.tech/blogs/affordable-kubernetes-for-personal-projects/
and as I'm currently trying to learn how to use Terraform I thought I might give it a shot to put this tutorial into a terraform module.
So I recently came across this article: https://redmaple.tech/blogs/affordable-kubernetes-for-personal-projects/
and as I'm currently trying to learn how to use Terraform I thought I might give it a shot to put this tutorial into a terraform module.
| provider "google" { | |
| project = "<project>" | |
| region = "us-central1" | |
| } | |
| data "google_client_config" "default" {} | |
| provider "kubernetes" { | |
| load_config_file = false | |
| host = "https://${module.gke.endpoint}" | |
| token = data.google_client_config.default.access_token | |
| cluster_ca_certificate = base64decode(module.gke.ca_certificate) | |
| } | |
| module "gke" { | |
| source = "terraform-google-modules/kubernetes-engine/google" | |
| project_id = "<project>" | |
| name = "<project>" | |
| region = "us-central1" | |
| zones = ["us-central1-a", "us-central1-b", "us-central1-f"] | |
| network = "default" | |
| subnetwork = "default" | |
| ip_range_pods = "/17" | |
| ip_range_services = "/22" | |
| http_load_balancing = false | |
| horizontal_pod_autoscaling = true | |
| network_policy = false | |
| node_pools = [ | |
| { | |
| name = "ingress-pool" | |
| machine_type = "e2-micro" | |
| node_locations = "us-central1-b,us-central1-c" | |
| min_count = 1 | |
| max_count = 100 | |
| local_ssd_count = 0 | |
| disk_size_gb = 10 | |
| disk_type = "pd-standard" | |
| image_type = "COS" | |
| auto_repair = true | |
| auto_upgrade = true | |
| service_account = "project-service-account@<PROJECT ID>.iam.gserviceaccount.com" | |
| preemptible = false | |
| initial_node_count = 80 | |
| }, | |
| { | |
| name = "web-pool" | |
| machine_type = "e2-medium" | |
| node_locations = "us-central1-b,us-central1-c" | |
| min_count = 1 | |
| max_count = 100 | |
| local_ssd_count = 0 | |
| disk_size_gb = 20 | |
| disk_type = "pd-standard" | |
| image_type = "COS" | |
| auto_repair = true | |
| auto_upgrade = true | |
| service_account = "project-service-account@<PROJECT ID>.iam.gserviceaccount.com" | |
| preemptible = false | |
| initial_node_count = 80 | |
| }, | |
| ] | |
| node_pools_oauth_scopes = { | |
| all = [] | |
| ingress-pool = [ | |
| "https://www.googleapis.com/auth/cloud-platform", | |
| ] | |
| } | |
| node_pools_labels = { | |
| all = {} | |
| ingress-pool = { | |
| default-node-pool = true | |
| } | |
| } | |
| node_pools_metadata = { | |
| all = {} | |
| ingress-pool = { | |
| node-pool-metadata-custom-value = "ingress-pool" | |
| } | |
| } | |
| node_pools_taints = { | |
| all = [] | |
| ingress-pool = [ | |
| { | |
| key = "dedicated" | |
| value = "ingress" | |
| effect = "NO_SCHEDULE" | |
| }, | |
| ] | |
| } | |
| node_pools_tags = { | |
| all = [] | |
| ingress-pool = [ | |
| "ingress-pool", | |
| ] | |
| } | |
| } |