Skip to content

Instantly share code, notes, and snippets.

@vorandrew
Created October 26, 2023 09:14
Show Gist options
  • Save vorandrew/d9e750bb5906e111e812301da9a1cef4 to your computer and use it in GitHub Desktop.
Save vorandrew/d9e750bb5906e111e812301da9a1cef4 to your computer and use it in GitHub Desktop.
Terraform gke
data "google_client_config" "default" {}
provider "kubernetes" {
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"
grant_registry_access = true
horizontal_pod_autoscaling = true
http_load_balancing = true
ip_range_pods = "${local.name}-pods"
ip_range_services = "${local.name}-services"
name = local.name
network = module.vpc.network_name
project_id = local.project_id
region = local.region
remove_default_node_pool = true
subnetwork = "${local.name}-private-1"
node_pools = [
{
disk_size_gb = 50
machine_type = "e2-standard-2"
name = "main"
node_count = 3
},
{
name = "gpu"
machine_type = "n1-highmem-2"
node_count = 1
disk_size_gb = 150
disk_type = "pd-standard"
accelerator_count = 1
accelerator_type = "nvidia-tesla-t4"
auto_repair = false
spot = true
},
]
node_pools_oauth_scopes = {
all = [
"https://www.googleapis.com/auth/cloud-platform",
]
}
node_pools_labels = {
all = {}
default-node-pool = {
default-node-pool = true
}
}
node_pools_metadata = {
all = {}
default-node-pool = {
node-pool-metadata-custom-value = "my-node-pool"
}
}
node_pools_taints = {
all = []
default-node-pool = [
{
key = "default-node-pool"
value = true
effect = "PREFER_NO_SCHEDULE"
},
]
}
node_pools_tags = {
all = []
default-node-pool = [
"default-node-pool",
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment