Skip to content

Commit 04687ba

Browse files
committed
feat: support TPG v6.11 and control_plane_endpoints_config
1 parent 752db66 commit 04687ba

File tree

49 files changed

+273
-47
lines changed

Some content is hidden

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

49 files changed

+273
-47
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ Then perform the following commands on the root folder:
263263
| cluster\_id | Cluster ID |
264264
| dns\_cache\_enabled | Whether DNS Cache enabled |
265265
| endpoint | Cluster endpoint |
266+
| endpoint\_dns | Cluster endpoint DNS |
266267
| fleet\_membership | Fleet membership (if registered) |
267268
| gateway\_api\_channel | The gateway api channel of this cluster. |
268269
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |

autogen/main/cluster.tf.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,15 @@ resource "google_container_cluster" "primary" {
632632
}
633633
}
634634
}
635+
636+
dynamic "control_plane_endpoints_config" {
637+
for_each = var.enable_private_endpoint && var.deploy_using_private_endpoint ? [1] : [0]
638+
content {
639+
dns_endpoint_config {
640+
allow_external_traffic = var.deploy_using_private_endpoint
641+
}
642+
}
643+
}
635644
{% endif %}
636645

637646
{% if autopilot_cluster != true %}

autogen/main/main.tf.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ locals {
143143
cluster_output_regional_zones = google_container_cluster.primary.node_locations
144144
cluster_output_zones = local.cluster_output_regional_zones
145145

146+
cluster_endpoint_dns = google_container_cluster.primary.control_plane_endpoints_config[0].dns_endpoint_config[0].endpoint
146147
{% if private_cluster %}
147-
cluster_endpoint = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (var.deploy_using_private_endpoint ? google_container_cluster.primary.private_cluster_config[0].private_endpoint : google_container_cluster.primary.private_cluster_config[0].public_endpoint) : google_container_cluster.primary.endpoint
148+
cluster_endpoint = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (var.enable_private_endpoint || var.deploy_using_private_endpoint ? google_container_cluster.primary.private_cluster_config[0].private_endpoint : google_container_cluster.primary.private_cluster_config[0].public_endpoint) : google_container_cluster.primary.endpoint
148149
cluster_peering_name = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? google_container_cluster.primary.private_cluster_config[0].peering_name : null
149150
cluster_endpoint_for_nodes = var.master_ipv4_cidr_block
150151
{% else %}

autogen/main/outputs.tf.tmpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ output "endpoint" {
7676
]
7777
}
7878

79+
output "endpoint_dns" {
80+
sensitive = true
81+
description = "Cluster endpoint DNS"
82+
value = local.cluster_endpoint_dns
83+
depends_on = [
84+
/* Nominally, the endpoint is populated as soon as it is known to Terraform.
85+
* However, the cluster may not be in a usable state yet. Therefore any
86+
* resources dependent on the cluster being up will fail to deploy. With
87+
* this explicit dependency, dependent resources can wait for the cluster
88+
* to be up.
89+
*/
90+
google_container_cluster.primary,
91+
{% if autopilot_cluster != true %}
92+
google_container_node_pool.pools,
93+
{% endif %}
94+
]
95+
}
96+
7997
output "min_master_version" {
8098
description = "Minimum master kubernetes version"
8199
value = local.cluster_min_master_version

autogen/main/versions.tf.tmpl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2022 Google LLC
2+
* Copyright 2022-2024 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,33 +24,33 @@ terraform {
2424
required_providers {
2525
google = {
2626
source = "hashicorp/google"
27-
version = ">= 6.7.0, < 6.11.0"
27+
version = ">= 6.11.0, < 7"
2828
}
2929
google-beta = {
3030
source = "hashicorp/google-beta"
31-
version = ">= 6.7.0, < 6.11.0"
31+
version = ">= 6.11.0, < 7"
3232
}
3333
{% elif beta_cluster and autopilot_cluster %}
3434
required_providers {
3535
google = {
3636
source = "hashicorp/google"
37-
version = ">= 6.5.0, < 6.11.0"
37+
version = ">= 6.11.0, < 7"
3838
}
3939
google-beta = {
4040
source = "hashicorp/google-beta"
41-
version = ">= 6.5.0, < 6.11.0"
41+
version = ">= 6.11.0, < 7"
4242
}
4343
{% elif autopilot_cluster %}
4444
required_providers {
4545
google = {
4646
source = "hashicorp/google"
47-
version = ">= 6.5.0, < 6.11.0"
47+
version = ">= 6.11.0, < 7"
4848
}
4949
{% else %}
5050
required_providers {
5151
google = {
5252
source = "hashicorp/google"
53-
version = ">= 6.7.0, < 6.11.0"
53+
version = ">= 6.11.0, < 7"
5454
}
5555
{% endif %}
5656
kubernetes = {

examples/safer_cluster_iap_bastion/bastion.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ module "bastion" {
3434
startup_script = templatefile("${path.module}/templates/startup-script.tftpl", {})
3535
members = var.bastion_members
3636
shielded_vm = "false"
37+
38+
service_account_roles = ["roles/container.viewer"]
3739
}

examples/simple_regional_beta/main.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ locals {
2020

2121
data "google_client_config" "default" {}
2222

23-
provider "kubernetes" {
24-
host = "https://${module.gke.endpoint}"
25-
token = data.google_client_config.default.access_token
26-
cluster_ca_certificate = base64decode(module.gke.ca_certificate)
27-
}
28-
2923
module "gke" {
3024
source = "terraform-google-modules/kubernetes-engine/google//modules/beta-public-cluster"
3125
version = "~> 34.0"

examples/simple_regional_beta/versions.tf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@ terraform {
2323
google-beta = {
2424
source = "hashicorp/google-beta"
2525
}
26-
kubernetes = {
27-
source = "hashicorp/kubernetes"
28-
}
2926
}
3027
}

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ locals {
109109
cluster_output_regional_zones = google_container_cluster.primary.node_locations
110110
cluster_output_zones = local.cluster_output_regional_zones
111111

112+
cluster_endpoint_dns = google_container_cluster.primary.control_plane_endpoints_config[0].dns_endpoint_config[0].endpoint
112113
cluster_endpoint = google_container_cluster.primary.endpoint
113114
cluster_endpoint_for_nodes = "${google_container_cluster.primary.endpoint}/32"
114115

modules/beta-autopilot-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ Then perform the following commands on the root folder:
170170
| cluster\_id | Cluster ID |
171171
| dns\_cache\_enabled | Whether DNS Cache enabled |
172172
| endpoint | Cluster endpoint |
173+
| endpoint\_dns | Cluster endpoint DNS |
173174
| fleet\_membership | Fleet membership (if registered) |
174175
| gateway\_api\_channel | The gateway api channel of this cluster. |
175176
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |

0 commit comments

Comments
 (0)