Skip to content

Commit 1f85f66

Browse files
authored
feat(TPG>=6.11)!: add endpoint_dns (#2180)
1 parent 276cbdb commit 1f85f66

File tree

46 files changed

+271
-41
lines changed

Some content is hidden

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

46 files changed

+271
-41
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ Then perform the following commands on the root folder:
264264
| cluster\_id | Cluster ID |
265265
| dns\_cache\_enabled | Whether DNS Cache enabled |
266266
| endpoint | Cluster endpoint |
267+
| endpoint\_dns | Cluster endpoint DNS |
267268
| fleet\_membership | Fleet membership (if registered) |
268269
| gateway\_api\_channel | The gateway api channel of this cluster. |
269270
| 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
@@ -630,6 +630,15 @@ resource "google_container_cluster" "primary" {
630630
}
631631
}
632632
}
633+
634+
dynamic "control_plane_endpoints_config" {
635+
for_each = var.enable_private_endpoint && var.deploy_using_private_endpoint ? [1] : [0]
636+
content {
637+
dns_endpoint_config {
638+
allow_external_traffic = var.deploy_using_private_endpoint
639+
}
640+
}
641+
}
633642
{% endif %}
634643

635644
{% if autopilot_cluster != true %}

autogen/main/outputs.tf.tmpl

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

79+
output "endpoint_dns" {
80+
description = "Cluster endpoint DNS"
81+
value = google_container_cluster.primary.control_plane_endpoints_config[0].dns_endpoint_config[0].endpoint
82+
depends_on = [
83+
/* Nominally, the endpoint is populated as soon as it is known to Terraform.
84+
* However, the cluster may not be in a usable state yet. Therefore any
85+
* resources dependent on the cluster being up will fail to deploy. With
86+
* this explicit dependency, dependent resources can wait for the cluster
87+
* to be up.
88+
*/
89+
google_container_cluster.primary,
90+
{% if autopilot_cluster != true %}
91+
google_container_node_pool.pools,
92+
{% endif %}
93+
]
94+
}
95+
7996
output "min_master_version" {
8097
description = "Minimum master kubernetes version"
8198
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, < 7"
27+
version = ">= 6.11.0, < 7"
2828
}
2929
google-beta = {
3030
source = "hashicorp/google-beta"
31-
version = ">= 6.7.0, < 7"
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.8.0, < 7"
37+
version = ">= 6.11.0, < 7"
3838
}
3939
google-beta = {
4040
source = "hashicorp/google-beta"
41-
version = ">= 6.8.0, < 7"
41+
version = ">= 6.11.0, < 7"
4242
}
4343
{% elif autopilot_cluster %}
4444
required_providers {
4545
google = {
4646
source = "hashicorp/google"
47-
version = ">= 6.8.0, < 7"
47+
version = ">= 6.11.0, < 7"
4848
}
4949
{% else %}
5050
required_providers {
5151
google = {
5252
source = "hashicorp/google"
53-
version = ">= 6.7.0, < 7"
53+
version = ">= 6.11.0, < 7"
5454
}
5555
{% endif %}
5656
kubernetes = {

autogen/safer-cluster/outputs.tf.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ output "endpoint" {
5252
value = module.gke.endpoint
5353
}
5454

55+
output "endpoint_dns" {
56+
description = "Cluster endpoint DNS"
57+
value = module.gke.endpoint_dns
58+
}
59+
5560
output "min_master_version" {
5661
description = "Minimum master kubernetes version"
5762
value = module.gke.min_master_version

examples/safer_cluster_iap_bastion/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ To deploy this example:
6060
| ca\_certificate | Cluster ca certificate (base64 encoded) |
6161
| cluster\_name | Cluster name |
6262
| endpoint | Cluster endpoint |
63+
| endpoint\_dns | Cluster endpoint DNS |
6364
| get\_credentials\_command | gcloud get-credentials command to generate kubeconfig for the private cluster |
6465
| keyring | The name of the keyring. |
6566
| keyring\_resource | The location of the keyring. |

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/safer_cluster_iap_bastion/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ output "endpoint" {
3535
value = module.gke.endpoint
3636
}
3737

38+
output "endpoint_dns" {
39+
sensitive = true
40+
description = "Cluster endpoint DNS"
41+
value = module.gke.endpoint_dns
42+
}
43+
3844
output "master_authorized_networks_config" {
3945
description = "Networks from which access to master is permitted"
4046
value = module.gke.master_authorized_networks_config

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
}

0 commit comments

Comments
 (0)