Skip to content

Commit d494b0f

Browse files
bharathkkbcloud-foundation-botjackwhelptonmorgante
authored
feat!: update TPG version constraints to 4.0 (terraform-google-modules#1129)
* feat: update TPG version constraints to allow 4.0 * Removes basic auth, renames namespace_identity * Regenerates modules and documentation * Updates tests to use latest Google provider * addresses warning about multiple provider blocks * Updates network module for Google provider 4.0 compatibility * Temporarily uses "main" for gcloud module (until next release is cut) * Comments out version constraint (temporary change) * fetches main branch by default? * Uses master branch for gcloud module (until release is cut) * Uses kubectl-wrapper where appropriate * Uses released version of gcloud module * Returns instance group URLs per node pool * Extends use of cluster_output_node_pools_ variables * Fixes documentation * Updates more modules * Updates READMEs to match variables * Uses master branch of bastion * temporary change until new version is released * Updates node pools versions description * Adds locals for node pool instance group URLs * Uses master branch of terraform-google-project-factory * temporary change until new version of that dependency is released * Updates project version ready for release * Updates pinned version of Google provider for example * Updates pinned version of Google provider in example * Addresses code review comments * Temporarily applies an empty source_tags setting. * this should be removed once hashicorp/terraform-provider-google#10494 is addressed * Fixes indentation * Uses newly-released version of project factory * Uses released version of bastion host * Removes use of SECURE mode (deprecated) * test empty source tag workaround * fix wi test * refactor IAM test for loose match * map old node meta value, add validations * update docs * Update autogen/main/variables.tf.tmpl Co-authored-by: Morgante Pell <morgantep@google.com> * remove local Co-authored-by: cloud-foundation-bot <cloud-foundation-bot@google.com> Co-authored-by: Jack Whelpton <jack.whelpton@rakuten.com> Co-authored-by: Morgante Pell <morgantep@google.com>
1 parent 3b5ddb9 commit d494b0f

File tree

161 files changed

+1077
-578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+1077
-578
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ Then perform the following commands on the root folder:
128128
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
129129
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
130130
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format gke-security-groups@yourdomain.com | `string` | `null` | no |
131-
| basic\_auth\_password | The password to be used with Basic Authentication. | `string` | `""` | no |
132-
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | `string` | `""` | no |
133131
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> })</pre> | <pre>{<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
134132
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | `any` | `null` | no |
135133
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no |
@@ -151,7 +149,7 @@ Then perform the following commands on the root folder:
151149
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer and artifactregistry.reader roles. | `bool` | `false` | no |
152150
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
153151
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
154-
| identity\_namespace | Workload Identity namespace. (Default value of `enabled` automatically sets project based namespace `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
152+
| identity\_namespace | The workload pool to attach all Kubernetes service accounts to. (Default value of `enabled` automatically sets project-based pool `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
155153
| impersonate\_service\_account | An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials. | `string` | `""` | no |
156154
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | `number` | `0` | no |
157155
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | `bool` | `false` | no |
@@ -170,7 +168,7 @@ Then perform the following commands on the root folder:
170168
| network\_policy | Enable network policy addon | `bool` | `false` | no |
171169
| network\_policy\_provider | The network policy provider. | `string` | `"CALICO"` | no |
172170
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
173-
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA_SERVER"` | no |
171+
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
174172
| node\_pools | List of maps containing node pools | `list(map(string))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
175173
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
176174
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
@@ -202,7 +200,7 @@ Then perform the following commands on the root folder:
202200
| endpoint | Cluster endpoint |
203201
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |
204202
| http\_load\_balancing\_enabled | Whether http load balancing enabled |
205-
| identity\_namespace | Workload Identity namespace |
203+
| identity\_namespace | Workload Identity pool |
206204
| instance\_group\_urls | List of GKE generated instance groups |
207205
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
208206
| logging\_service | Logging service used |
@@ -213,7 +211,7 @@ Then perform the following commands on the root folder:
213211
| name | Cluster name |
214212
| network\_policy\_enabled | Whether network policy enabled |
215213
| node\_pools\_names | List of node pools names |
216-
| node\_pools\_versions | List of node pools versions |
214+
| node\_pools\_versions | Node pool versions by node pool name |
217215
| region | Cluster region |
218216
| release\_channel | The release channel of this cluster |
219217
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |

autogen/main/cluster.tf.tmpl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ resource "google_container_cluster" "primary" {
161161
}
162162

163163
master_auth {
164-
username = var.basic_auth_username
165-
password = var.basic_auth_password
166-
167164
client_certificate_config {
168165
issue_client_certificate = var.issue_client_certificate
169166
}
@@ -298,7 +295,7 @@ resource "google_container_cluster" "primary" {
298295
for_each = local.cluster_node_metadata_config
299296

300297
content {
301-
node_metadata = workload_metadata_config.value.node_metadata
298+
mode = workload_metadata_config.value.mode
302299
}
303300
}
304301

@@ -377,7 +374,7 @@ resource "google_container_cluster" "primary" {
377374
for_each = local.cluster_workload_identity_config
378375

379376
content {
380-
identity_namespace = workload_identity_config.value.identity_namespace
377+
workload_pool = workload_identity_config.value.workload_pool
381378
}
382379
}
383380

@@ -634,9 +631,10 @@ resource "google_container_node_pool" "pools" {
634631
for_each = local.cluster_node_metadata_config
635632

636633
content {
637-
node_metadata = lookup(each.value, "node_metadata", workload_metadata_config.value.node_metadata)
634+
mode = lookup(each.value, "node_metadata", workload_metadata_config.value.mode)
638635
}
639636
}
637+
640638
{% if beta_cluster %}
641639
dynamic "sandbox_config" {
642640
for_each = tobool((lookup(each.value, "sandbox_enabled", var.sandbox_enabled))) ? ["gvisor"] : []

autogen/main/dns.tf.tmpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
Delete default kube-dns configmap
2121
*****************************************/
2222
module "gcloud_delete_default_kube_dns_configmap" {
23-
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
24-
version = "~> 2.1.0"
23+
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
24+
version = "~> 3.1"
25+
2526
enabled = (local.custom_kube_dns_config || local.upstream_nameservers_config) && !var.skip_provisioners
2627
cluster_name = google_container_cluster.primary.name
2728
cluster_location = google_container_cluster.primary.location

autogen/main/firewall.tf.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ resource "google_compute_firewall" "master_webhooks" {
112112
direction = "INGRESS"
113113

114114
source_ranges = [local.cluster_endpoint_for_nodes]
115+
source_tags = []
115116
target_tags = [local.cluster_network_tag]
116117

117118
allow {

autogen/main/main.tf.tmpl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,11 @@ locals {
111111
security_group = var.authenticator_security_group
112112
}]
113113

114+
// legacy mappings https://github.com/hashicorp/terraform-provider-google/pull/10238
115+
old_node_metadata_config_mapping = { GKE_METADATA_SERVER = "GKE_METADATA", GCE_METADATA = "EXPOSE" }
116+
114117
cluster_node_metadata_config = var.node_metadata == "UNSPECIFIED" ? [] : [{
115-
node_metadata = var.node_metadata
118+
mode = lookup(local.old_node_metadata_config_mapping, var.node_metadata, var.node_metadata)
116119
}]
117120

118121
cluster_output_name = google_container_cluster.primary.name
@@ -153,7 +156,7 @@ locals {
153156
}]
154157

155158
cluster_output_node_pools_names = concat([for np in google_container_node_pool.pools : np.name], [""])
156-
cluster_output_node_pools_versions = concat([for np in google_container_node_pool.pools : np.version], [""])
159+
cluster_output_node_pools_versions = { for np in google_container_node_pool.pools : np.name => np.version }
157160

158161
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
159162
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
@@ -177,7 +180,7 @@ locals {
177180
cluster_horizontal_pod_autoscaling_enabled = !local.cluster_output_horizontal_pod_autoscaling_enabled
178181
workload_identity_enabled = !(var.identity_namespace == null || var.identity_namespace == "null")
179182
cluster_workload_identity_config = ! local.workload_identity_enabled ? [] : var.identity_namespace == "enabled" ? [{
180-
identity_namespace = "${var.project_id}.svc.id.goog" }] : [{ identity_namespace = var.identity_namespace
183+
workload_pool = "${var.project_id}.svc.id.goog" }] : [{ workload_pool = var.identity_namespace
181184
}]
182185
{% if beta_cluster %}
183186
# BETA features

autogen/main/outputs.tf.tmpl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ output "node_pools_names" {
114114
}
115115

116116
output "node_pools_versions" {
117-
description = "List of node pools versions"
117+
description = "Node pool versions by node pool name"
118118
value = local.cluster_node_pools_versions
119119
}
120120

@@ -123,23 +123,23 @@ output "service_account" {
123123
value = local.service_account
124124
}
125125

126+
output "instance_group_urls" {
127+
description = "List of GKE generated instance groups"
128+
value = distinct(flatten([for np in google_container_node_pool.pools : np.managed_instance_group_urls]))
129+
}
130+
126131
output "release_channel" {
127132
description = "The release channel of this cluster"
128133
value = var.release_channel
129134
}
130135

131136
output "identity_namespace" {
132-
description = "Workload Identity namespace"
133-
value = length(local.cluster_workload_identity_config) > 0 ? local.cluster_workload_identity_config[0].identity_namespace : null
137+
description = "Workload Identity pool"
138+
value = length(local.cluster_workload_identity_config) > 0 ? local.cluster_workload_identity_config[0].workload_pool : null
134139
depends_on = [
135140
google_container_cluster.primary
136141
]
137142
}
138-
139-
output "instance_group_urls" {
140-
description = "List of GKE generated instance groups"
141-
value = google_container_cluster.primary.instance_group_urls
142-
}
143143
{% if private_cluster %}
144144

145145
output "master_ipv4_cidr_block" {

autogen/main/variables.tf.tmpl

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -394,18 +394,6 @@ variable "service_account" {
394394
default = ""
395395
}
396396

397-
variable "basic_auth_username" {
398-
type = string
399-
description = "The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration."
400-
default = ""
401-
}
402-
403-
variable "basic_auth_password" {
404-
type = string
405-
description = "The password to be used with Basic Authentication."
406-
default = ""
407-
}
408-
409397
variable "issue_client_certificate" {
410398
type = bool
411399
description = "Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive!"
@@ -549,8 +537,13 @@ variable "authenticator_security_group" {
549537

550538
variable "node_metadata" {
551539
description = "Specifies how node metadata is exposed to the workload running on the node"
552-
default = "GKE_METADATA_SERVER"
540+
default = "GKE_METADATA"
553541
type = string
542+
543+
validation {
544+
condition = contains(["GKE_METADATA", "GCE_METADATA", "UNSPECIFIED", "GKE_METADATA_SERVER", "EXPOSE"], var.node_metadata)
545+
error_message = "The node_metadata value must be one of GKE_METADATA, GCE_METADATA or UNSPECIFIED."
546+
}
554547
}
555548

556549
variable "database_encryption" {
@@ -564,7 +557,7 @@ variable "database_encryption" {
564557
}
565558

566559
variable "identity_namespace" {
567-
description = "Workload Identity namespace. (Default value of `enabled` automatically sets project based namespace `[project_id].svc.id.goog`)"
560+
description = "The workload pool to attach all Kubernetes service accounts to. (Default value of `enabled` automatically sets project-based pool `[project_id].svc.id.goog`)"
568561
type = string
569562
default = "enabled"
570563
}

autogen/main/versions.tf.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ terraform {
2424
required_providers {
2525
google-beta = {
2626
source = "hashicorp/google-beta"
27-
version = ">= 3.87.0, <4.0.0"
27+
version = ">= 4.0.0, < 5.0"
2828
}
2929
kubernetes = {
3030
source = "hashicorp/kubernetes"
@@ -38,7 +38,7 @@ terraform {
3838
required_providers {
3939
google = {
4040
source = "hashicorp/google"
41-
version = ">= 3.55.0, <4.0.0"
41+
version = ">= 4.0.0, < 5.0"
4242
}
4343
kubernetes = {
4444
source = "hashicorp/kubernetes"

autogen/safer-cluster/main.tf.tmpl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ module "gke" {
111111
registry_project_ids = var.registry_project_ids
112112
grant_registry_access = var.grant_registry_access
113113

114-
// Basic Auth disabled
115-
basic_auth_username = ""
116-
basic_auth_password = ""
117-
118114
issue_client_certificate = false
119115

120116
cluster_resource_labels = var.cluster_resource_labels
@@ -164,7 +160,7 @@ module "gke" {
164160

165161
enable_vertical_pod_autoscaling = var.enable_vertical_pod_autoscaling
166162

167-
// We enable identity namespace by default.
163+
// We enable Workload Identity by default.
168164
identity_namespace = "${var.project_id}.svc.id.goog"
169165

170166
authenticator_security_group = var.authenticator_security_group

autogen/safer-cluster/outputs.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ output "node_pools_names" {
104104
}
105105

106106
output "node_pools_versions" {
107-
description = "List of node pools versions"
107+
description = "Node pool versions by node pool name"
108108
value = module.gke.node_pools_versions
109109
}
110110

0 commit comments

Comments
 (0)