diff --git a/blueprints/networking/shared-vpc-gke/main.tf b/blueprints/networking/shared-vpc-gke/main.tf index 2e770377f..97bf45d24 100644 --- a/blueprints/networking/shared-vpc-gke/main.tf +++ b/blueprints/networking/shared-vpc-gke/main.tf @@ -227,6 +227,7 @@ module "cluster-1-nodepool-1" { project_id = module.project-svc-gke.project_id location = module.cluster-1.0.location cluster_name = module.cluster-1.0.name + cluster_id = module.cluster-1.0.id service_account = { create = true } diff --git a/modules/gke-cluster/main.tf b/modules/gke-cluster/main.tf index 3ef14391a..5b5cd95f3 100644 --- a/modules/gke-cluster/main.tf +++ b/modules/gke-cluster/main.tf @@ -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 diff --git a/modules/gke-nodepool/README.md b/modules/gke-nodepool/README.md index e1201b1d2..50e9d08cb 100644 --- a/modules/gke-nodepool/README.md +++ b/modules/gke-nodepool/README.md @@ -83,23 +83,24 @@ module "cluster-1-nodepool-1" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [cluster_name](variables.tf#L17) | Cluster name. | string | ✓ | | -| [location](variables.tf#L35) | Cluster location. | string | ✓ | | -| [project_id](variables.tf#L143) | Cluster project id. | string | ✓ | | -| [gke_version](variables.tf#L22) | Kubernetes nodes version. Ignored if auto_upgrade is set in management_config. | string | | null | -| [labels](variables.tf#L28) | Kubernetes labels applied to each node. | map(string) | | {} | -| [max_pods_per_node](variables.tf#L40) | Maximum number of pods per node. | number | | null | -| [name](variables.tf#L46) | Optional nodepool name. | string | | null | -| [node_config](variables.tf#L52) | Node-level configuration. | object({…}) | | {…} | -| [node_count](variables.tf#L91) | Number of nodes per instance group. Initial value can only be changed by recreation, current is ignored when autoscaling is used. | object({…}) | | {…} | -| [node_locations](variables.tf#L103) | Node locations. | list(string) | | null | -| [nodepool_config](variables.tf#L109) | Nodepool-level configuration. | object({…}) | | null | -| [pod_range](variables.tf#L131) | Pod secondary range configuration. | object({…}) | | null | -| [reservation_affinity](variables.tf#L148) | Configuration of the desired reservation which instances could take capacity from. | object({…}) | | null | -| [service_account](variables.tf#L158) | Nodepool service account. If this variable is set to null, the default GCE service account will be used. If set and email is null, a service account will be created. If scopes are null a default will be used. | object({…}) | | {} | -| [sole_tenant_nodegroup](variables.tf#L169) | Sole tenant node group. | string | | null | -| [tags](variables.tf#L175) | Network tags applied to nodes. | list(string) | | null | -| [taints](variables.tf#L181) | Kubernetes taints applied to all nodes. | list(object({…})) | | null | +| [cluster_name](variables.tf#L23) | Cluster name. | string | ✓ | | +| [location](variables.tf#L41) | Cluster location. | string | ✓ | | +| [project_id](variables.tf#L149) | Cluster project id. | string | ✓ | | +| [cluster_id](variables.tf#L17) | Cluster id. Optional, but providing cluster_id is recommended to prevent cluster misconfiguration in some of the edge cases. | string | | null | +| [gke_version](variables.tf#L28) | Kubernetes nodes version. Ignored if auto_upgrade is set in management_config. | string | | null | +| [labels](variables.tf#L34) | Kubernetes labels applied to each node. | map(string) | | {} | +| [max_pods_per_node](variables.tf#L46) | Maximum number of pods per node. | number | | null | +| [name](variables.tf#L52) | Optional nodepool name. | string | | null | +| [node_config](variables.tf#L58) | Node-level configuration. | object({…}) | | {…} | +| [node_count](variables.tf#L97) | Number of nodes per instance group. Initial value can only be changed by recreation, current is ignored when autoscaling is used. | object({…}) | | {…} | +| [node_locations](variables.tf#L109) | Node locations. | list(string) | | null | +| [nodepool_config](variables.tf#L115) | Nodepool-level configuration. | object({…}) | | null | +| [pod_range](variables.tf#L137) | Pod secondary range configuration. | object({…}) | | null | +| [reservation_affinity](variables.tf#L154) | Configuration of the desired reservation which instances could take capacity from. | object({…}) | | null | +| [service_account](variables.tf#L164) | Nodepool service account. If this variable is set to null, the default GCE service account will be used. If set and email is null, a service account will be created. If scopes are null a default will be used. | object({…}) | | {} | +| [sole_tenant_nodegroup](variables.tf#L175) | Sole tenant node group. | string | | null | +| [tags](variables.tf#L181) | Network tags applied to nodes. | list(string) | | null | +| [taints](variables.tf#L187) | Kubernetes taints applied to all nodes. | list(object({…})) | | null | ## Outputs diff --git a/modules/gke-nodepool/main.tf b/modules/gke-nodepool/main.tf index 0c35c8d0f..ad0c053f3 100644 --- a/modules/gke-nodepool/main.tf +++ b/modules/gke-nodepool/main.tf @@ -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 diff --git a/modules/gke-nodepool/variables.tf b/modules/gke-nodepool/variables.tf index 15c8a1515..e0d3e967a 100644 --- a/modules/gke-nodepool/variables.tf +++ b/modules/gke-nodepool/variables.tf @@ -14,6 +14,12 @@ * limitations under the License. */ +variable "cluster_id" { + description = "Cluster id. Optional, but providing cluster_id is recommended to prevent cluster misconfiguration in some of the edge cases." + type = string + default = null +} + variable "cluster_name" { description = "Cluster name." type = string