Skip to content

Commit 7c5a6f0

Browse files
committed
fix: add node_pool_taints to all the modules
1 parent f31b1f4 commit 7c5a6f0

File tree

17 files changed

+122
-10
lines changed

17 files changed

+122
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Then perform the following commands on the root folder:
140140
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) | `<map>` | no |
141141
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) | `<map>` | no |
142142
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map(list(string)) | `<map>` | no |
143+
| node\_pools\_taints | Map of lists containing node taints by node-pool name | object | `<map>` | no |
143144
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) | `<list>` | no |
144145
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
145146
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string | `"null"` | no |

autogen/main/cluster.tf.tmpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ resource "google_container_node_pool" "pools" {
458458
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
459459
},
460460
)
461-
{% if beta_cluster %}
462461
dynamic "taint" {
463462
for_each = concat(
464463
local.node_pools_taints["all"],
@@ -470,7 +469,6 @@ resource "google_container_node_pool" "pools" {
470469
value = taint.value.value
471470
}
472471
}
473-
{% endif %}
474472
tags = concat(
475473
lookup(local.node_pools_tags, "default_values", [true, true])[0] ? [local.cluster_network_tag] : [],
476474
lookup(local.node_pools_tags, "default_values", [true, true])[1] ? ["${local.cluster_network_tag}-${each.value["name"]}"] : [],

autogen/main/variables.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ variable "cluster_autoscaling" {
227227
}
228228
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
229229
}
230+
{% endif %}
230231

231232
variable "node_pools_taints" {
232233
type = map(list(object({ key = string, value = string, effect = string })))
@@ -239,7 +240,6 @@ variable "node_pools_taints" {
239240
}
240241
}
241242

242-
{% endif %}
243243
variable "node_pools_tags" {
244244
type = map(list(string))
245245
description = "Map of lists containing node network tags by node-pool name"

autogen/main/variables_defaults.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ locals {
4040
var.node_pools_metadata
4141
)
4242

43-
{% if beta_cluster %}
4443
node_pools_taints = merge(
4544
{ all = [] },
4645
{ default-node-pool = [] },
@@ -51,7 +50,6 @@ locals {
5150
var.node_pools_taints
5251
)
5352

54-
{% endif %}
5553
node_pools_tags = merge(
5654
{ all = [] },
5755
{ default-node-pool = [] },

cluster.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ resource "google_container_node_pool" "pools" {
198198
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
199199
},
200200
)
201+
dynamic "taint" {
202+
for_each = concat(
203+
local.node_pools_taints["all"],
204+
local.node_pools_taints[each.value["name"]],
205+
)
206+
content {
207+
effect = taint.value.effect
208+
key = taint.value.key
209+
value = taint.value.value
210+
}
211+
}
201212
tags = concat(
202213
lookup(local.node_pools_tags, "default_values", [true, true])[0] ? [local.cluster_network_tag] : [],
203214
lookup(local.node_pools_tags, "default_values", [true, true])[1] ? ["${local.cluster_network_tag}-${each.value["name"]}"] : [],

modules/private-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ Then perform the following commands on the root folder:
172172
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) | `<map>` | no |
173173
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) | `<map>` | no |
174174
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map(list(string)) | `<map>` | no |
175+
| node\_pools\_taints | Map of lists containing node taints by node-pool name | object | `<map>` | no |
175176
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) | `<list>` | no |
176177
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
177178
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string | `"null"` | no |

modules/private-cluster-update-variant/cluster.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,17 @@ resource "google_container_node_pool" "pools" {
283283
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
284284
},
285285
)
286+
dynamic "taint" {
287+
for_each = concat(
288+
local.node_pools_taints["all"],
289+
local.node_pools_taints[each.value["name"]],
290+
)
291+
content {
292+
effect = taint.value.effect
293+
key = taint.value.key
294+
value = taint.value.value
295+
}
296+
}
286297
tags = concat(
287298
lookup(local.node_pools_tags, "default_values", [true, true])[0] ? [local.cluster_network_tag] : [],
288299
lookup(local.node_pools_tags, "default_values", [true, true])[1] ? ["${local.cluster_network_tag}-${each.value["name"]}"] : [],

modules/private-cluster-update-variant/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ variable "enable_resource_consumption_export" {
187187
description = "Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export."
188188
default = true
189189
}
190+
191+
variable "node_pools_taints" {
192+
type = map(list(object({ key = string, value = string, effect = string })))
193+
description = "Map of lists containing node taints by node-pool name"
194+
195+
# Default is being set in variables_defaults.tf
196+
default = {
197+
all = []
198+
default-node-pool = []
199+
}
200+
}
201+
190202
variable "node_pools_tags" {
191203
type = map(list(string))
192204
description = "Map of lists containing node network tags by node-pool name"

modules/private-cluster-update-variant/variables_defaults.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ locals {
4040
var.node_pools_metadata
4141
)
4242

43+
node_pools_taints = merge(
44+
{ all = [] },
45+
{ default-node-pool = [] },
46+
zipmap(
47+
[for node_pool in var.node_pools : node_pool["name"]],
48+
[for node_pool in var.node_pools : []]
49+
),
50+
var.node_pools_taints
51+
)
52+
4353
node_pools_tags = merge(
4454
{ all = [] },
4555
{ default-node-pool = [] },

modules/private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ Then perform the following commands on the root folder:
150150
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) | `<map>` | no |
151151
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) | `<map>` | no |
152152
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map(list(string)) | `<map>` | no |
153+
| node\_pools\_taints | Map of lists containing node taints by node-pool name | object | `<map>` | no |
153154
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) | `<list>` | no |
154155
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
155156
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string | `"null"` | no |

modules/private-cluster/cluster.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,17 @@ resource "google_container_node_pool" "pools" {
211211
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
212212
},
213213
)
214+
dynamic "taint" {
215+
for_each = concat(
216+
local.node_pools_taints["all"],
217+
local.node_pools_taints[each.value["name"]],
218+
)
219+
content {
220+
effect = taint.value.effect
221+
key = taint.value.key
222+
value = taint.value.value
223+
}
224+
}
214225
tags = concat(
215226
lookup(local.node_pools_tags, "default_values", [true, true])[0] ? [local.cluster_network_tag] : [],
216227
lookup(local.node_pools_tags, "default_values", [true, true])[1] ? ["${local.cluster_network_tag}-${each.value["name"]}"] : [],

modules/private-cluster/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ variable "enable_resource_consumption_export" {
187187
description = "Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export."
188188
default = true
189189
}
190+
191+
variable "node_pools_taints" {
192+
type = map(list(object({ key = string, value = string, effect = string })))
193+
description = "Map of lists containing node taints by node-pool name"
194+
195+
# Default is being set in variables_defaults.tf
196+
default = {
197+
all = []
198+
default-node-pool = []
199+
}
200+
}
201+
190202
variable "node_pools_tags" {
191203
type = map(list(string))
192204
description = "Map of lists containing node network tags by node-pool name"

modules/private-cluster/variables_defaults.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ locals {
4040
var.node_pools_metadata
4141
)
4242

43+
node_pools_taints = merge(
44+
{ all = [] },
45+
{ default-node-pool = [] },
46+
zipmap(
47+
[for node_pool in var.node_pools : node_pool["name"]],
48+
[for node_pool in var.node_pools : []]
49+
),
50+
var.node_pools_taints
51+
)
52+
4353
node_pools_tags = merge(
4454
{ all = [] },
4555
{ default-node-pool = [] },

test/setup/main.tf

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resource "random_id" "random_project_id_suffix" {
2020

2121
module "gke-project-1" {
2222
source = "terraform-google-modules/project-factory/google"
23-
version = "~> 8.0"
23+
version = "~> 9.1.0"
2424

2525
name = "ci-gke-${random_id.random_project_id_suffix.hex}"
2626
random_project_id = true
@@ -35,15 +35,22 @@ module "gke-project-1" {
3535
"cloudkms.googleapis.com",
3636
"cloudresourcemanager.googleapis.com",
3737
"container.googleapis.com",
38+
"compute.googleapis.com",
3839
"pubsub.googleapis.com",
3940
"serviceusage.googleapis.com",
4041
"storage-api.googleapis.com",
4142
]
43+
activate_api_identities = [
44+
{
45+
api = "container.googleapis.com"
46+
roles = ["roles/cloudkms.cryptoKeyEncrypterDecrypter"]
47+
},
48+
]
4249
}
4350

4451
module "gke-project-2" {
4552
source = "terraform-google-modules/project-factory/google"
46-
version = "~> 8.0"
53+
version = "~> 9.1.0"
4754

4855
name = "ci-gke-${random_id.random_project_id_suffix.hex}"
4956
random_project_id = true
@@ -56,16 +63,23 @@ module "gke-project-2" {
5663
"cloudkms.googleapis.com",
5764
"cloudresourcemanager.googleapis.com",
5865
"container.googleapis.com",
66+
"compute.googleapis.com",
5967
"pubsub.googleapis.com",
6068
"serviceusage.googleapis.com",
6169
"storage-api.googleapis.com",
6270
]
71+
activate_api_identities = [
72+
{
73+
api = "container.googleapis.com"
74+
roles = ["roles/cloudkms.cryptoKeyEncrypterDecrypter"]
75+
},
76+
]
6377
}
6478

6579
# apis as documented https://cloud.google.com/service-mesh/docs/gke-install-new-cluster#setting_up_your_project
6680
module "gke-project-asm" {
6781
source = "terraform-google-modules/project-factory/google"
68-
version = "~> 8.0"
82+
version = "~> 9.1.0"
6983

7084
name = "ci-gke-asm-${random_id.random_project_id_suffix.hex}"
7185
random_project_id = true

test/setup/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ terraform {
1919
}
2020

2121
provider "google" {
22-
version = "3.25.0"
22+
version = "3.42.0"
2323
}
2424

2525
provider "google-beta" {
26-
version = "3.32.0"
26+
version = "3.42.0"
2727
}

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ variable "enable_resource_consumption_export" {
187187
description = "Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export."
188188
default = true
189189
}
190+
191+
variable "node_pools_taints" {
192+
type = map(list(object({ key = string, value = string, effect = string })))
193+
description = "Map of lists containing node taints by node-pool name"
194+
195+
# Default is being set in variables_defaults.tf
196+
default = {
197+
all = []
198+
default-node-pool = []
199+
}
200+
}
201+
190202
variable "node_pools_tags" {
191203
type = map(list(string))
192204
description = "Map of lists containing node network tags by node-pool name"

variables_defaults.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ locals {
4040
var.node_pools_metadata
4141
)
4242

43+
node_pools_taints = merge(
44+
{ all = [] },
45+
{ default-node-pool = [] },
46+
zipmap(
47+
[for node_pool in var.node_pools : node_pool["name"]],
48+
[for node_pool in var.node_pools : []]
49+
),
50+
var.node_pools_taints
51+
)
52+
4353
node_pools_tags = merge(
4454
{ all = [] },
4555
{ default-node-pool = [] },

0 commit comments

Comments
 (0)