Skip to content

Commit 3181f6c

Browse files
authored
feat!: align keepers with ForceNew: true fields (#1698)
1 parent 350faa7 commit 3181f6c

File tree

5 files changed

+66
-96
lines changed

5 files changed

+66
-96
lines changed

autogen/main/cluster.tf.tmpl

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,12 @@ locals {
572572
"disk_type",
573573
"accelerator_count",
574574
"accelerator_type",
575+
"gpu_partition_size",
575576
"enable_secure_boot",
576577
"enable_integrity_monitoring",
577578
"local_ssd_count",
578579
"machine_type",
580+
"placement_policy",
579581
"max_pods_per_node",
580582
"min_cpu_platform",
581583
"pod_range",
@@ -585,13 +587,14 @@ locals {
585587
"enable_gcfs",
586588
"enable_gvnic",
587589
"enable_secure_boot",
590+
"boot_disk_kms_key",
588591
]
589592
}
590593

591594
# This keepers list is based on the terraform google provider schemaNodeConfig
592595
# resources where "ForceNew" is "true". schemaNodeConfig can be found in resource_container_node_pool.go at
593-
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_container_node_pool.go and node_config.go at
594-
# https://github.com/terraform-providers/terraform-provider-google/blob/main/google/node_config.go
596+
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/resource_container_node_pool.go and node_config.go at
597+
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/node_config.go
595598
resource "random_id" "name" {
596599
for_each = merge(local.node_pools, local.windows_node_pools)
597600
byte_length = 2
@@ -601,18 +604,6 @@ resource "random_id" "name" {
601604
local.force_node_pool_recreation_resources,
602605
[for keeper in local.force_node_pool_recreation_resources : lookup(each.value, keeper, "")]
603606
),
604-
{
605-
labels = join(",",
606-
sort(
607-
concat(
608-
keys(local.node_pools_labels["all"]),
609-
values(local.node_pools_labels["all"]),
610-
keys(local.node_pools_labels[each.value["name"]]),
611-
values(local.node_pools_labels[each.value["name"]])
612-
)
613-
)
614-
)
615-
},
616607
{
617608
taints = join(",",
618609
sort(
@@ -646,16 +637,6 @@ resource "random_id" "name" {
646637
)
647638
)
648639
)
649-
},
650-
{
651-
tags = join(",",
652-
sort(
653-
concat(
654-
local.node_pools_tags["all"],
655-
local.node_pools_tags[each.value["name"]]
656-
)
657-
)
658-
)
659640
}
660641
)
661642
}

docs/upgrading_to_v29.0.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,52 @@
22
The v29.0 release of *kubernetes-engine* is a backwards incompatible
33
release.
44

5+
### Update variant random ID keepers updated
6+
7+
The v29.0 release updates the keepers for the update variant modules. This will force a recreation of the nodepools.
8+
9+
To avoid this, it is possible to edit the remote state of the `random_id` resource to add the new attributes.
10+
11+
1. Perform a `terraform plan` as normal, identifying the `random_id` resource(s) changing and the new/removed attributes
12+
```tf
13+
~ keepers = { # forces replacement
14+
+ "boot_disk_kms_key" = ""
15+
+ "gpu_partition_size" = ""
16+
- "labels" = "" -> null
17+
+ "placement_policy" = ""
18+
- "tags" = "" -> null
19+
# (19 unchanged elements hidden)
20+
}
21+
# (2 unchanged attributes hidden)
22+
}
23+
```
24+
2. Pull the remote state locally: `terraform state pull > default.tfstate`
25+
3. Back up the original remote state: `cp default.tfstate original.tfstate`
26+
4. Edit the `random_id` resource(s) to add/remove the attributes from the `terraform plan` step
27+
```diff
28+
"attributes": {
29+
"b64_std": "pool-02-vb4=",
30+
"b64_url": "pool-02-vb4",
31+
"byte_length": 2,
32+
"dec": "pool-02-48574",
33+
"hex": "pool-02-bdbe",
34+
"id": "vb4",
35+
"keepers": {
36+
...
37+
"taints": "",
38+
- "labels": "",
39+
- "tags": "",
40+
+ "boot_disk_kms_key": "",
41+
+ "gpu_partition_size": "",
42+
+ "placement_policy": "",
43+
},
44+
"prefix": "pool-02-"
45+
}
46+
```
47+
1. Bump the serial number at the top
48+
2. Push the modified state to the remote `terraform state push default.tfstate`
49+
3. Confirm the `random_id` resource(s) no longer changes (or the corresponding `nodepool`) in a `terraform plan`
50+
551
### Default cluster service account permissions modified
652

753
When `create_service_account` is `true`, the service account will now be created with `Kubernetes Engine Node Service Account` role instead of `Logs Writer`, `Monitoring Metric Writer`, `Monitoring Viewer` and `Stackdriver Resource Metadata Writer` roles.

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,12 @@ locals {
485485
"disk_type",
486486
"accelerator_count",
487487
"accelerator_type",
488+
"gpu_partition_size",
488489
"enable_secure_boot",
489490
"enable_integrity_monitoring",
490491
"local_ssd_count",
491492
"machine_type",
493+
"placement_policy",
492494
"max_pods_per_node",
493495
"min_cpu_platform",
494496
"pod_range",
@@ -498,13 +500,14 @@ locals {
498500
"enable_gcfs",
499501
"enable_gvnic",
500502
"enable_secure_boot",
503+
"boot_disk_kms_key",
501504
]
502505
}
503506

504507
# This keepers list is based on the terraform google provider schemaNodeConfig
505508
# resources where "ForceNew" is "true". schemaNodeConfig can be found in resource_container_node_pool.go at
506-
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_container_node_pool.go and node_config.go at
507-
# https://github.com/terraform-providers/terraform-provider-google/blob/main/google/node_config.go
509+
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/resource_container_node_pool.go and node_config.go at
510+
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/node_config.go
508511
resource "random_id" "name" {
509512
for_each = merge(local.node_pools, local.windows_node_pools)
510513
byte_length = 2
@@ -514,18 +517,6 @@ resource "random_id" "name" {
514517
local.force_node_pool_recreation_resources,
515518
[for keeper in local.force_node_pool_recreation_resources : lookup(each.value, keeper, "")]
516519
),
517-
{
518-
labels = join(",",
519-
sort(
520-
concat(
521-
keys(local.node_pools_labels["all"]),
522-
values(local.node_pools_labels["all"]),
523-
keys(local.node_pools_labels[each.value["name"]]),
524-
values(local.node_pools_labels[each.value["name"]])
525-
)
526-
)
527-
)
528-
},
529520
{
530521
taints = join(",",
531522
sort(
@@ -559,16 +550,6 @@ resource "random_id" "name" {
559550
)
560551
)
561552
)
562-
},
563-
{
564-
tags = join(",",
565-
sort(
566-
concat(
567-
local.node_pools_tags["all"],
568-
local.node_pools_tags[each.value["name"]]
569-
)
570-
)
571-
)
572553
}
573554
)
574555
}

modules/beta-public-cluster-update-variant/cluster.tf

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,12 @@ locals {
466466
"disk_type",
467467
"accelerator_count",
468468
"accelerator_type",
469+
"gpu_partition_size",
469470
"enable_secure_boot",
470471
"enable_integrity_monitoring",
471472
"local_ssd_count",
472473
"machine_type",
474+
"placement_policy",
473475
"max_pods_per_node",
474476
"min_cpu_platform",
475477
"pod_range",
@@ -479,13 +481,14 @@ locals {
479481
"enable_gcfs",
480482
"enable_gvnic",
481483
"enable_secure_boot",
484+
"boot_disk_kms_key",
482485
]
483486
}
484487

485488
# This keepers list is based on the terraform google provider schemaNodeConfig
486489
# resources where "ForceNew" is "true". schemaNodeConfig can be found in resource_container_node_pool.go at
487-
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_container_node_pool.go and node_config.go at
488-
# https://github.com/terraform-providers/terraform-provider-google/blob/main/google/node_config.go
490+
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/resource_container_node_pool.go and node_config.go at
491+
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/node_config.go
489492
resource "random_id" "name" {
490493
for_each = merge(local.node_pools, local.windows_node_pools)
491494
byte_length = 2
@@ -495,18 +498,6 @@ resource "random_id" "name" {
495498
local.force_node_pool_recreation_resources,
496499
[for keeper in local.force_node_pool_recreation_resources : lookup(each.value, keeper, "")]
497500
),
498-
{
499-
labels = join(",",
500-
sort(
501-
concat(
502-
keys(local.node_pools_labels["all"]),
503-
values(local.node_pools_labels["all"]),
504-
keys(local.node_pools_labels[each.value["name"]]),
505-
values(local.node_pools_labels[each.value["name"]])
506-
)
507-
)
508-
)
509-
},
510501
{
511502
taints = join(",",
512503
sort(
@@ -540,16 +531,6 @@ resource "random_id" "name" {
540531
)
541532
)
542533
)
543-
},
544-
{
545-
tags = join(",",
546-
sort(
547-
concat(
548-
local.node_pools_tags["all"],
549-
local.node_pools_tags[each.value["name"]]
550-
)
551-
)
552-
)
553534
}
554535
)
555536
}

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,12 @@ locals {
411411
"disk_type",
412412
"accelerator_count",
413413
"accelerator_type",
414+
"gpu_partition_size",
414415
"enable_secure_boot",
415416
"enable_integrity_monitoring",
416417
"local_ssd_count",
417418
"machine_type",
419+
"placement_policy",
418420
"max_pods_per_node",
419421
"min_cpu_platform",
420422
"pod_range",
@@ -424,13 +426,14 @@ locals {
424426
"enable_gcfs",
425427
"enable_gvnic",
426428
"enable_secure_boot",
429+
"boot_disk_kms_key",
427430
]
428431
}
429432

430433
# This keepers list is based on the terraform google provider schemaNodeConfig
431434
# resources where "ForceNew" is "true". schemaNodeConfig can be found in resource_container_node_pool.go at
432-
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_container_node_pool.go and node_config.go at
433-
# https://github.com/terraform-providers/terraform-provider-google/blob/main/google/node_config.go
435+
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/resource_container_node_pool.go and node_config.go at
436+
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/node_config.go
434437
resource "random_id" "name" {
435438
for_each = merge(local.node_pools, local.windows_node_pools)
436439
byte_length = 2
@@ -440,18 +443,6 @@ resource "random_id" "name" {
440443
local.force_node_pool_recreation_resources,
441444
[for keeper in local.force_node_pool_recreation_resources : lookup(each.value, keeper, "")]
442445
),
443-
{
444-
labels = join(",",
445-
sort(
446-
concat(
447-
keys(local.node_pools_labels["all"]),
448-
values(local.node_pools_labels["all"]),
449-
keys(local.node_pools_labels[each.value["name"]]),
450-
values(local.node_pools_labels[each.value["name"]])
451-
)
452-
)
453-
)
454-
},
455446
{
456447
taints = join(",",
457448
sort(
@@ -485,16 +476,6 @@ resource "random_id" "name" {
485476
)
486477
)
487478
)
488-
},
489-
{
490-
tags = join(",",
491-
sort(
492-
concat(
493-
local.node_pools_tags["all"],
494-
local.node_pools_tags[each.value["name"]]
495-
)
496-
)
497-
)
498479
}
499480
)
500481
}

0 commit comments

Comments
 (0)