Skip to content

Commit e0ac559

Browse files
committed
Enable specifying master_authorized_networks_config
1 parent 2cf62a0 commit e0ac559

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

cluster_zonal.tf

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ resource "google_container_cluster" "zonal_primary" {
3030
subnetwork = "projects/${local.network_project_id}/regions/${var.region}/subnetworks/${var.subnetwork}"
3131
min_master_version = "${local.kubernetes_version}"
3232

33+
master_authorized_networks_config = "${var.master_authorized_networks_config}"
34+
3335
addons_config {
3436
http_load_balancing {
3537
disabled = "${var.http_load_balancing ? 0 : 1}"

main.tf

+19-13
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,14 @@ locals {
6868
zonal = "${element(concat(google_container_cluster.zonal_primary.*.master_version, list("")), 0)}"
6969
}
7070

71-
cluster_type_output_min_master_version = {
72-
regional = "${element(concat(google_container_cluster.primary.*.min_master_version, list("")), 0)}"
73-
zonal = "${element(concat(google_container_cluster.zonal_primary.*.min_master_version, list("")), 0)}"
71+
cluster_type_output_master_authorized_networks_config = {
72+
regional = "${element(concat(google_container_cluster.primary.*.master_authorized_networks_config, list("")), 0)}"
73+
zonal = "${element(concat(google_container_cluster.zonal_primary.*.master_authorized_networks_config, list("")), 0)}"
74+
}
75+
76+
cluster_type_output_master_authorized_networks_config = {
77+
regional = "${element(concat(google_container_cluster.primary.*.master_version, list("")), 0)}"
78+
zonal = "${element(concat(google_container_cluster.zonal_primary.*.master_version, list("")), 0)}"
7479
}
7580

7681
cluster_type_output_network_policy_enabled = {
@@ -108,16 +113,17 @@ locals {
108113
cluster_master_auth_map = "${local.cluster_master_auth_list_layer2[0]}"
109114

110115
# cluster locals
111-
cluster_name = "${local.cluster_type_output_name[local.cluster_type]}"
112-
cluster_location = "${local.cluster_type_output_location[local.cluster_type]}"
113-
cluster_region = "${local.cluster_type_output_region[local.cluster_type]}"
114-
cluster_zones = "${sort(local.cluster_type_output_zones[local.cluster_type])}"
115-
cluster_endpoint = "${local.cluster_type_output_endpoint[local.cluster_type]}"
116-
cluster_ca_certificate = "${lookup(local.cluster_master_auth_map, "cluster_ca_certificate")}"
117-
cluster_master_version = "${local.cluster_type_output_master_version[local.cluster_type]}"
118-
cluster_min_master_version = "${local.cluster_type_output_min_master_version[local.cluster_type]}"
119-
cluster_node_pools_names = "${local.cluster_type_output_node_pools_names[local.cluster_type]}"
120-
cluster_node_pools_versions = "${local.cluster_type_output_node_pools_versions[local.cluster_type]}"
116+
cluster_name = "${local.cluster_type_output_name[local.cluster_type]}"
117+
cluster_location = "${local.cluster_type_output_location[local.cluster_type]}"
118+
cluster_region = "${local.cluster_type_output_region[local.cluster_type]}"
119+
cluster_zones = "${sort(local.cluster_type_output_zones[local.cluster_type])}"
120+
cluster_endpoint = "${local.cluster_type_output_endpoint[local.cluster_type]}"
121+
cluster_ca_certificate = "${lookup(local.cluster_master_auth_map, "cluster_ca_certificate")}"
122+
cluster_master_version = "${local.cluster_type_output_master_version[local.cluster_type]}"
123+
cluster_min_master_version = "${local.cluster_type_output_min_master_version[local.cluster_type]}"
124+
cluster_master_authorized_networks_config = "${local.cluster_type_output_cluster_master_authorized_networks_config[local.cluster_type]}"
125+
cluster_node_pools_names = "${local.cluster_type_output_node_pools_names[local.cluster_type]}"
126+
cluster_node_pools_versions = "${local.cluster_type_output_node_pools_versions[local.cluster_type]}"
121127

122128
cluster_network_policy_enabled = "${local.cluster_type_output_network_policy_enabled[local.cluster_type] ? false : true}"
123129
cluster_http_load_balancing_enabled = "${local.cluster_type_output_http_load_balancing_enabled[local.cluster_type] ? false : true}"

outputs.tf

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ output "min_master_version" {
5050
value = "${local.cluster_min_master_version}"
5151
}
5252

53+
output "master_authorized_networks_config" {
54+
description = "Networks from which access to master is permitted"
55+
value = "${local.master_authorized_networks_config}"
56+
}
57+
5358
output "master_version" {
5459
description = "Current master kubernetes version"
5560
value = "${local.cluster_master_version}"

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ variable "node_version" {
6565
default = ""
6666
}
6767

68+
variable "master_authorized_networks_config" {
69+
description = "The desired configuration options for master authorized networks. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists)."
70+
type = "list"
71+
default = []
72+
}
73+
6874
variable "horizontal_pod_autoscaling" {
6975
description = "Enable horizontal pod autoscaling addon"
7076
default = false

0 commit comments

Comments
 (0)