Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gke node zones #94

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion modules/gcp/gke/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ resource "google_compute_subnetwork" "cluster_subnet" {
]
}

locals {
ng_formated_zones_list = [for ng in var.node_pools :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also set defaults for these params. Just saw that there weren't any

{
name = ng.name
machine_type = ng.machine_type
disk_size_gb = ng.disk_size_gb
disk_type = ng.disk_type
image_type = ng.image_type
autoscaling = ng.autoscaling
min_count = ng.min_count
max_count = ng.max_count
auto_repair = ng.auto_repair
auto_upgrade = ng.auto_upgrade
preemptible = ng.preemptible
enable_gcfs = ng.enable_gcfs
accelerator_type = ng.accelerator_type
accelerator_count = ng.accelerator_count
node_locations = ng.zones != null ? join(",", ng.zones) : ""
}
]
}


module "gke" {
depends_on = [google_compute_subnetwork.cluster_subnet]
source = "github.com/argonautdev/terraform-google-kubernetes-engine//modules/private-cluster?ref=v21.1.5"
Expand All @@ -56,7 +79,7 @@ module "gke" {
enable_vertical_pod_autoscaling = var.enable_vertical_pod_autoscaling
kubernetes_version = var.kubernetes_version
initial_node_count = var.initial_node_count ##How many instances should be launched in each zone
node_pools = var.node_pools
node_pools = local.ng_formated_zones_list
remove_default_node_pool = var.remove_default_node_pool
cluster_resource_labels = merge(var.default_labels, var.labels)
//kubernetes_version = var.kubernetes_version
Expand Down
1 change: 1 addition & 0 deletions modules/gcp/gke/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ variable "node_pools" {
enable_gcfs = bool,##Set to true only if image streaming is required.
accelerator_type = optional(string),
accelerator_count = optional(number),
zones = optional(list(string)),
}))
description = "List of maps containing node pools"
default = [
Expand Down