Skip to content

Commit

Permalink
new gke node pools
Browse files Browse the repository at this point in the history
  • Loading branch information
pvenigal committed May 30, 2024
1 parent 6eadaae commit 4c70082
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
118 changes: 118 additions & 0 deletions modules/gke/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,121 @@ resource "google_container_node_pool" "default" {
create_before_destroy = true
}
}

resource "google_container_node_pool" "app_node_pool" {
count = var.enable_app_node_pool ? 1 : 0
name = "${var.deployment_name}app-node-pool"
cluster = google_container_cluster.default.id
node_count = var.initial_node_count

node_config {
image_type = "COS_CONTAINERD"
machine_type = var.app_np_machine_type
disk_size_gb = var.disk_size_gb
disk_type = var.disk_type
service_account = resource.google_service_account.gke_service_account.email

oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
shielded_instance_config {
enable_secure_boot = true
enable_integrity_monitoring = true
}
# Define the labels for the nodes
labels = {
default-node-pool = true
}
metadata = {
disable-legacy-endpoints = "true"
}
}

autoscaling {
min_node_count = 1
max_node_count = 2
location_policy = "ANY"
}

management {
auto_upgrade = true
auto_repair = true
}

upgrade_settings {
max_surge = 1
max_unavailable = 1
}

lifecycle {
ignore_changes = [
location,
]
create_before_destroy = true
}
}

resource "google_container_node_pool" "ch_node_pool" {
count = var.enable_ch_node_pool ? 1 : 0
name = "${var.deployment_name}ch-node-pool"
cluster = google_container_cluster.default.id
node_count = var.initial_node_count

node_config {
image_type = "COS_CONTAINERD"
machine_type = var.ch_machine_type
disk_size_gb = var.disk_size_gb
disk_type = var.disk_type
service_account = resource.google_service_account.gke_service_account.email

oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
shielded_instance_config {
enable_secure_boot = true
enable_integrity_monitoring = true
}
# Define the labels for the nodes
labels = {
default-node-pool = false
}
metadata = {
disable-legacy-endpoints = "true"
}
taint {
key = "clickhouse"
value = "reserved"
effect = "NO_SCHEDULE"
}
}

autoscaling {
min_node_count = 1
max_node_count = 1
location_policy = "ANY"
}

management {
auto_upgrade = true
auto_repair = true
}

upgrade_settings {
max_surge = 1
max_unavailable = 1
}

lifecycle {
ignore_changes = [
location,
]
create_before_destroy = true
}
}

24 changes: 24 additions & 0 deletions modules/gke/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,27 @@ variable "disk_type" {
default = "pd-standard"
description = "The disk type for the GKE cluster nodes"
}

variable "enable_app_node_pool" {
description = "Whether to enable the app node pool"
type = bool
default = false
}

variable "enable_ch_node_pool" {
description = "Whether to enable the ch node pool"
type = bool
default = false
}

variable "app_np_machine_type" {
type = string
default = "e2-highmem-16"
description = "The machine type for the app GKE cluster nodes"
}

variable "ch_machine_type" {
type = string
default = "n2-standard-8"
description = "The machine type for the ch GKE cluster nodes"
}

0 comments on commit 4c70082

Please sign in to comment.