Skip to content

Commit

Permalink
Fixes for GKE
Browse files Browse the repository at this point in the history
* Fix non-empty plan when spot instances are used
* Add cluster_id and recommend its use, as this prevents inconsitencies
  when only cluster is recreated (with no changes on node pool)
  • Loading branch information
wiktorn committed Dec 21, 2022
1 parent ba8d14a commit 411bcaf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
12 changes: 6 additions & 6 deletions blueprints/networking/shared-vpc-gke/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ module "cluster-1" {
}

module "cluster-1-nodepool-1" {
source = "../../../modules/gke-nodepool"
count = var.cluster_create ? 1 : 0
name = "nodepool-1"
project_id = module.project-svc-gke.project_id
location = module.cluster-1.0.location
cluster_name = module.cluster-1.0.name
source = "../../../modules/gke-nodepool"
count = var.cluster_create ? 1 : 0
name = "nodepool-1"
project_id = module.project-svc-gke.project_id
location = module.cluster-1.0.location
cluster_id = module.cluster-1.0.id
service_account = {
create = true
}
Expand Down
3 changes: 2 additions & 1 deletion modules/gke-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
resource "google_container_cluster" "cluster" {
lifecycle {
ignore_changes = [
node_config[0].boot_disk_kms_key
node_config[0].boot_disk_kms_key,
node_config[0].spot
]
}
provider = google-beta
Expand Down
2 changes: 1 addition & 1 deletion modules/gke-nodepool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resource "google_service_account" "service_account" {
resource "google_container_node_pool" "nodepool" {
provider = google-beta
project = var.project_id
cluster = var.cluster_name
cluster = coalesce(var.cluster_id, var.cluster_name)
location = var.location
name = var.name
version = var.gke_version
Expand Down
9 changes: 8 additions & 1 deletion modules/gke-nodepool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@
* limitations under the License.
*/

variable "cluster_id" {
description = "Cluster id. Either cluster_id or cluster_name must be provided. Providing cluster_id is recommended."
type = string
default = null
}

variable "cluster_name" {
description = "Cluster name."
description = "Cluster name. Either cluster_id or cluster_name must be provided. Providing cluster_id is recommended."
type = string
default = null
}

variable "gke_version" {
Expand Down

0 comments on commit 411bcaf

Please sign in to comment.