Skip to content

Commit 803f643

Browse files
committed
Add deploy_using_private_endpoint variable
1 parent 2ec2037 commit 803f643

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

autogen/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,23 @@ locals {
6363
zonal = "${concat(google_container_cluster.zonal_primary.*.zone, local.cluster_type_output_zonal_zones)}"
6464
}
6565

66+
{% if private_cluster %}
67+
cluster_type_output_endpoint = {
68+
regional = "${element(concat((
69+
var.deploy_using_private_endpoint ? google_container_cluster.primary.*.private_endpoint :
70+
google_container_cluster.primary.*.endpoint
71+
), list("")), 0)}"
72+
zonal = "${element(concat((
73+
var.deploy_using_private_endpoint ? google_container_cluster.zonal_primary.*.private_endpoint :
74+
google_container_cluster.zonal_primary.*.endpoint
75+
), list("")), 0)}"
76+
}
77+
{% else %}
6678
cluster_type_output_endpoint = {
6779
regional = "${element(concat(google_container_cluster.primary.*.endpoint, list("")), 0)}"
6880
zonal = "${element(concat(google_container_cluster.zonal_primary.*.endpoint, list("")), 0)}"
6981
}
82+
{% endif %}
7083

7184
cluster_type_output_master_auth = {
7285
regional = "${concat(google_container_cluster.primary.*.master_auth, list())}"

autogen/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ variable "service_account" {
228228
}
229229
{% if private_cluster %}
230230

231+
variable "deploy_using_private_endpoint" {
232+
description = "(Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment."
233+
default = "false"
234+
}
235+
231236
variable "enable_private_endpoint" {
232237
description = "(Beta) Whether the master's internal IP address is used as the cluster endpoint"
233238
default = false

modules/private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
121121
|------|-------------|:----:|:-----:|:-----:|
122122
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
123123
| 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 |
124+
| deploy\_using\_private\_endpoint | (Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | string | `"false"` | no |
124125
| description | The description of the cluster | string | `""` | no |
125126
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | string | `"true"` | no |
126127
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | string | `"false"` | no |

modules/private-cluster/main.tf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,15 @@ locals {
6464
}
6565

6666
cluster_type_output_endpoint = {
67-
regional = "${element(concat(google_container_cluster.primary.*.endpoint, list("")), 0)}"
68-
zonal = "${element(concat(google_container_cluster.zonal_primary.*.endpoint, list("")), 0)}"
67+
regional = "${element(concat((
68+
var.deploy_using_private_endpoint ? google_container_cluster.primary.*.private_endpoint :
69+
google_container_cluster.primary.*.endpoint
70+
), list("")), 0)}"
71+
72+
zonal = "${element(concat((
73+
var.deploy_using_private_endpoint ? google_container_cluster.zonal_primary.*.private_endpoint :
74+
google_container_cluster.zonal_primary.*.endpoint
75+
), list("")), 0)}"
6976
}
7077

7178
cluster_type_output_master_auth = {

modules/private-cluster/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ variable "service_account" {
227227
default = "create"
228228
}
229229

230+
variable "deploy_using_private_endpoint" {
231+
description = "(Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment."
232+
default = "false"
233+
}
234+
230235
variable "enable_private_endpoint" {
231236
description = "(Beta) Whether the master's internal IP address is used as the cluster endpoint"
232237
default = false

0 commit comments

Comments
 (0)