Skip to content

Instantly share code, notes, and snippets.

@dannyverp
Created March 18, 2021 20:36
Show Gist options
  • Save dannyverp/03440c6c1e20338dadebb132832c357d to your computer and use it in GitHub Desktop.
Save dannyverp/03440c6c1e20338dadebb132832c357d to your computer and use it in GitHub Desktop.
Cheap k8s cluster Terraform
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",
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment