Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: align keepers with ForceNew: true fields #1698

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,12 @@ locals {
"disk_type",
"accelerator_count",
"accelerator_type",
"gpu_partition_size",
"enable_secure_boot",
"enable_integrity_monitoring",
"local_ssd_count",
"machine_type",
"placement_policy",
"max_pods_per_node",
"min_cpu_platform",
"pod_range",
Expand All @@ -585,13 +587,14 @@ locals {
"enable_gcfs",
"enable_gvnic",
"enable_secure_boot",
"boot_disk_kms_key",
]
}

# This keepers list is based on the terraform google provider schemaNodeConfig
# resources where "ForceNew" is "true". schemaNodeConfig can be found in resource_container_node_pool.go at
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_container_node_pool.go and node_config.go at
# https://github.com/terraform-providers/terraform-provider-google/blob/main/google/node_config.go
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/resource_container_node_pool.go and node_config.go at
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/node_config.go
resource "random_id" "name" {
for_each = merge(local.node_pools, local.windows_node_pools)
byte_length = 2
Expand All @@ -601,18 +604,6 @@ resource "random_id" "name" {
local.force_node_pool_recreation_resources,
[for keeper in local.force_node_pool_recreation_resources : lookup(each.value, keeper, "")]
),
{
labels = join(",",
sort(
concat(
keys(local.node_pools_labels["all"]),
values(local.node_pools_labels["all"]),
keys(local.node_pools_labels[each.value["name"]]),
values(local.node_pools_labels[each.value["name"]])
)
)
)
},
{
taints = join(",",
sort(
Expand Down Expand Up @@ -646,16 +637,6 @@ resource "random_id" "name" {
)
)
)
},
{
tags = join(",",
sort(
concat(
local.node_pools_tags["all"],
local.node_pools_tags[each.value["name"]]
)
)
)
}
)
}
Expand Down
46 changes: 46 additions & 0 deletions docs/upgrading_to_v29.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,52 @@
The v29.0 release of *kubernetes-engine* is a backwards incompatible
release.

### Update variant random ID keepers updated

The v29.0 release updates the keepers for the update variant modules. This will force a recreation of the nodepools.

To avoid this, it is possible to edit the remote state of the `random_id` resource to add the new attributes.

1. Perform a `terraform plan` as normal, identifying the `random_id` resource(s) changing and the new/removed attributes
```tf
~ keepers = { # forces replacement
+ "boot_disk_kms_key" = ""
+ "gpu_partition_size" = ""
- "labels" = "" -> null
+ "placement_policy" = ""
- "tags" = "" -> null
# (19 unchanged elements hidden)
}
# (2 unchanged attributes hidden)
}
```
2. Pull the remote state locally: `terraform state pull > default.tfstate`
3. Back up the original remote state: `cp default.tfstate original.tfstate`
4. Edit the `random_id` resource(s) to add/remove the attributes from the `terraform plan` step
```diff
"attributes": {
"b64_std": "pool-02-vb4=",
"b64_url": "pool-02-vb4",
"byte_length": 2,
"dec": "pool-02-48574",
"hex": "pool-02-bdbe",
"id": "vb4",
"keepers": {
...
"taints": "",
- "labels": "",
- "tags": "",
+ "boot_disk_kms_key": "",
+ "gpu_partition_size": "",
+ "placement_policy": "",
},
"prefix": "pool-02-"
}
```
1. Bump the serial number at the top
2. Push the modified state to the remote `terraform state push default.tfstate`
3. Confirm the `random_id` resource(s) no longer changes (or the corresponding `nodepool`) in a `terraform plan`

### Default cluster service account permissions modified

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.
Expand Down
29 changes: 5 additions & 24 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,12 @@ locals {
"disk_type",
"accelerator_count",
"accelerator_type",
"gpu_partition_size",
"enable_secure_boot",
"enable_integrity_monitoring",
"local_ssd_count",
"machine_type",
"placement_policy",
"max_pods_per_node",
"min_cpu_platform",
"pod_range",
Expand All @@ -498,13 +500,14 @@ locals {
"enable_gcfs",
"enable_gvnic",
"enable_secure_boot",
"boot_disk_kms_key",
]
}

# This keepers list is based on the terraform google provider schemaNodeConfig
# resources where "ForceNew" is "true". schemaNodeConfig can be found in resource_container_node_pool.go at
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_container_node_pool.go and node_config.go at
# https://github.com/terraform-providers/terraform-provider-google/blob/main/google/node_config.go
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/resource_container_node_pool.go and node_config.go at
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/node_config.go
resource "random_id" "name" {
for_each = merge(local.node_pools, local.windows_node_pools)
byte_length = 2
Expand All @@ -514,18 +517,6 @@ resource "random_id" "name" {
local.force_node_pool_recreation_resources,
[for keeper in local.force_node_pool_recreation_resources : lookup(each.value, keeper, "")]
),
{
labels = join(",",
sort(
concat(
keys(local.node_pools_labels["all"]),
values(local.node_pools_labels["all"]),
keys(local.node_pools_labels[each.value["name"]]),
values(local.node_pools_labels[each.value["name"]])
)
)
)
},
{
taints = join(",",
sort(
Expand Down Expand Up @@ -559,16 +550,6 @@ resource "random_id" "name" {
)
)
)
},
{
tags = join(",",
sort(
concat(
local.node_pools_tags["all"],
local.node_pools_tags[each.value["name"]]
)
)
)
}
)
}
Expand Down
29 changes: 5 additions & 24 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,12 @@ locals {
"disk_type",
"accelerator_count",
"accelerator_type",
"gpu_partition_size",
"enable_secure_boot",
"enable_integrity_monitoring",
"local_ssd_count",
"machine_type",
"placement_policy",
"max_pods_per_node",
"min_cpu_platform",
"pod_range",
Expand All @@ -479,13 +481,14 @@ locals {
"enable_gcfs",
"enable_gvnic",
"enable_secure_boot",
"boot_disk_kms_key",
]
}

# This keepers list is based on the terraform google provider schemaNodeConfig
# resources where "ForceNew" is "true". schemaNodeConfig can be found in resource_container_node_pool.go at
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_container_node_pool.go and node_config.go at
# https://github.com/terraform-providers/terraform-provider-google/blob/main/google/node_config.go
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/resource_container_node_pool.go and node_config.go at
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/node_config.go
resource "random_id" "name" {
for_each = merge(local.node_pools, local.windows_node_pools)
byte_length = 2
Expand All @@ -495,18 +498,6 @@ resource "random_id" "name" {
local.force_node_pool_recreation_resources,
[for keeper in local.force_node_pool_recreation_resources : lookup(each.value, keeper, "")]
),
{
labels = join(",",
sort(
concat(
keys(local.node_pools_labels["all"]),
values(local.node_pools_labels["all"]),
keys(local.node_pools_labels[each.value["name"]]),
values(local.node_pools_labels[each.value["name"]])
)
)
)
},
{
taints = join(",",
sort(
Expand Down Expand Up @@ -540,16 +531,6 @@ resource "random_id" "name" {
)
)
)
},
{
tags = join(",",
sort(
concat(
local.node_pools_tags["all"],
local.node_pools_tags[each.value["name"]]
)
)
)
}
)
}
Expand Down
29 changes: 5 additions & 24 deletions modules/private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,12 @@ locals {
"disk_type",
"accelerator_count",
"accelerator_type",
"gpu_partition_size",
"enable_secure_boot",
"enable_integrity_monitoring",
"local_ssd_count",
"machine_type",
"placement_policy",
"max_pods_per_node",
"min_cpu_platform",
"pod_range",
Expand All @@ -424,13 +426,14 @@ locals {
"enable_gcfs",
"enable_gvnic",
"enable_secure_boot",
"boot_disk_kms_key",
]
}

# This keepers list is based on the terraform google provider schemaNodeConfig
# resources where "ForceNew" is "true". schemaNodeConfig can be found in resource_container_node_pool.go at
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_container_node_pool.go and node_config.go at
# https://github.com/terraform-providers/terraform-provider-google/blob/main/google/node_config.go
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/resource_container_node_pool.go and node_config.go at
# https://github.com/hashicorp/terraform-provider-google/blob/main/google/services/container/node_config.go
resource "random_id" "name" {
for_each = merge(local.node_pools, local.windows_node_pools)
byte_length = 2
Expand All @@ -440,18 +443,6 @@ resource "random_id" "name" {
local.force_node_pool_recreation_resources,
[for keeper in local.force_node_pool_recreation_resources : lookup(each.value, keeper, "")]
),
{
labels = join(",",
sort(
concat(
keys(local.node_pools_labels["all"]),
values(local.node_pools_labels["all"]),
keys(local.node_pools_labels[each.value["name"]]),
values(local.node_pools_labels[each.value["name"]])
)
)
)
},
{
taints = join(",",
sort(
Expand Down Expand Up @@ -485,16 +476,6 @@ resource "random_id" "name" {
)
)
)
},
{
tags = join(",",
sort(
concat(
local.node_pools_tags["all"],
local.node_pools_tags[each.value["name"]]
)
)
)
}
)
}
Expand Down