Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify master_authorized_networks_config to master_authorized_networks #354

Merged
merged 4 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| kubernetes\_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string | `"latest"` | no |
| logging\_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string | `"logging.googleapis.com"` | no |
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. The object format is {cidr_blocks = list(object({cidr_block = string, display_name = string}))}. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string | `"monitoring.googleapis.com"` | no |
| name | The name of the cluster (required) | string | n/a | yes |
| network | The VPC network to host the cluster in (required) | string | n/a | yes |
Expand Down
2 changes: 1 addition & 1 deletion autogen/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ resource "google_container_cluster" "primary" {
}
{% endif %}
dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
for_each = local.master_authorized_networks_config
content {
dynamic "cidr_blocks" {
for_each = master_authorized_networks_config.value.cidr_blocks
Expand Down
4 changes: 4 additions & 0 deletions autogen/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ locals {
# /BETA features
{% endif %}

master_authorized_networks_config = length(var.master_authorized_networks) == 0 ? [] : [{
cidr_blocks : var.master_authorized_networks
}]

cluster_output_node_pools_names = concat(google_container_node_pool.pools.*.name, [""])
cluster_output_node_pools_versions = concat(google_container_node_pool.pools.*.version, [""])

Expand Down
2 changes: 1 addition & 1 deletion autogen/outputs.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ output "monitoring_service" {

output "master_authorized_networks_config" {
description = "Networks from which access to master is permitted"
value = var.master_authorized_networks_config
value = google_container_cluster.primary.master_authorized_networks_config
}

output "master_version" {
Expand Down
6 changes: 3 additions & 3 deletions autogen/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ variable "node_version" {
default = ""
}

variable "master_authorized_networks_config" {
type = list(object({ cidr_blocks = list(object({ cidr_block = string, display_name = string })) }))
description = "The desired configuration options for master authorized networks. The object format is {cidr_blocks = list(object({cidr_block = string, display_name = string}))}. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists)."
variable "master_authorized_networks" {
type = list(object({ cidr_block = string, display_name = string }))
description = "List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists)."
default = []
}

Expand Down
2 changes: 1 addition & 1 deletion cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ resource "google_container_cluster" "primary" {
monitoring_service = var.monitoring_service

dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
for_each = local.master_authorized_networks_config
content {
dynamic "cidr_blocks" {
for_each = master_authorized_networks_config.value.cidr_blocks
Expand Down
37 changes: 37 additions & 0 deletions docs/upgrading_to_v6.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Upgrading to v6.0

The v6.0 release of *kubernetes-engine* is a backwards incompatible
release.

## Dropped support
Due to changes in GKE, the module has dropped support for setting the `kubernetes_dashboard` variable.

Additionally, support for Google provider versions older than v2.18 has been removed.

## Migration Instructions

### Master Authorized Networks
Previously, setting up master authorized networks required setting a nested config within `master_authorized_networks_config`.
Now, to set up master authorized networks you can simply pass a list of authorized networks.

```diff
module "kubernetes_engine_private_cluster" {
source = "terraform-google-modules/kubernetes-engine/google"
- version = "~> 5.0"
+ version = "~> 6.0"

- master_authorized_networks_config = [
+ master_authorized_networks = [
{
- cidr_blocks = [
- {
- cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
- display_name = "VPC"
- },
- ]
+ cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
+ display_name = "VPC"
},
]
}
```
10 changes: 3 additions & 7 deletions examples/node_pool_update_variant/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,10 @@ module "gke" {
enable_private_nodes = true
master_ipv4_cidr_block = "172.16.0.0/28"

master_authorized_networks_config = [
master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]

Expand Down
10 changes: 3 additions & 7 deletions examples/node_pool_update_variant_beta/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@ module "gke" {
enable_private_nodes = true
master_ipv4_cidr_block = "172.16.0.0/28"

master_authorized_networks_config = [
master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]

Expand Down
10 changes: 3 additions & 7 deletions examples/private_zonal_with_networking/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,10 @@ module "gke" {
enable_private_nodes = true
master_ipv4_cidr_block = "172.16.0.0/28"

master_authorized_networks_config = [
master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
}
Expand Down
10 changes: 3 additions & 7 deletions examples/regional_private_node_pool_oauth_scopes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ module "gke" {
remove_default_node_pool = true
disable_legacy_metadata_endpoints = true

master_authorized_networks_config = [
master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = module.gke-network.subnets_ips[0]
display_name = "VPC"
},
]
cidr_block = module.gke-network.subnets_ips[0]
display_name = "VPC"
},
]

Expand Down
12 changes: 5 additions & 7 deletions examples/safer_cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,14 @@ module "gke" {
ip_range_services = local.svc_range_name
compute_engine_service_account = var.compute_engine_service_account
master_ipv4_cidr_block = "172.16.0.0/28"
master_authorized_networks_config = [

master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = "10.60.0.0/17"
display_name = "VPC"
},
]
cidr_block = "10.60.0.0/17"
display_name = "VPC"
},
]

istio = true
cloudrun = true
}
Expand Down
10 changes: 3 additions & 7 deletions examples/simple_regional_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,10 @@ module "gke" {
enable_private_nodes = true
master_ipv4_cidr_block = "172.16.0.0/28"

master_authorized_networks_config = [
master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
}
Expand Down
10 changes: 3 additions & 7 deletions examples/simple_regional_private_beta/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ module "gke" {
enable_private_nodes = true
master_ipv4_cidr_block = "172.16.0.0/28"

master_authorized_networks_config = [
master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]

Expand Down
10 changes: 3 additions & 7 deletions examples/simple_zonal_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,10 @@ module "gke" {
enable_private_nodes = true
master_ipv4_cidr_block = "172.16.0.0/28"

master_authorized_networks_config = [
master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
}
Expand Down
10 changes: 3 additions & 7 deletions examples/stub_domains_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ module "gke" {
enable_private_endpoint = false
enable_private_nodes = true

master_authorized_networks_config = [
master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]

Expand Down
10 changes: 3 additions & 7 deletions examples/workload_metadata_config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,10 @@ module "gke" {
master_ipv4_cidr_block = "172.16.0.0/28"
node_metadata = "SECURE"

master_authorized_networks_config = [
master_authorized_networks = [
{
cidr_blocks = [
{
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
display_name = "VPC"
},
]
}
Expand Down
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ locals {
cluster_output_horizontal_pod_autoscaling_enabled = google_container_cluster.primary.addons_config.0.horizontal_pod_autoscaling.0.disabled


master_authorized_networks_config = length(var.master_authorized_networks) == 0 ? [] : [{
cidr_blocks : var.master_authorized_networks
}]

cluster_output_node_pools_names = concat(google_container_node_pool.pools.*.name, [""])
cluster_output_node_pools_versions = concat(google_container_node_pool.pools.*.version, [""])

Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| kubernetes\_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string | `"latest"` | no |
| logging\_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string | `"logging.googleapis.com"` | no |
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. The object format is {cidr_blocks = list(object({cidr_block = string, display_name = string}))}. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
| master\_ipv4\_cidr\_block | (Beta) The IP range in CIDR notation to use for the hosted master network | string | `"10.0.0.0/28"` | no |
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string | `"monitoring.googleapis.com"` | no |
| name | The name of the cluster (required) | string | n/a | yes |
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ resource "google_container_cluster" "primary" {
}
}
dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
for_each = local.master_authorized_networks_config
content {
dynamic "cidr_blocks" {
for_each = master_authorized_networks_config.value.cidr_blocks
Expand Down
4 changes: 4 additions & 0 deletions modules/beta-private-cluster-update-variant/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ locals {

# /BETA features

master_authorized_networks_config = length(var.master_authorized_networks) == 0 ? [] : [{
cidr_blocks : var.master_authorized_networks
}]

cluster_output_node_pools_names = concat(google_container_node_pool.pools.*.name, [""])
cluster_output_node_pools_versions = concat(google_container_node_pool.pools.*.version, [""])

Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ output "monitoring_service" {

output "master_authorized_networks_config" {
description = "Networks from which access to master is permitted"
value = var.master_authorized_networks_config
value = google_container_cluster.primary.master_authorized_networks_config
}

output "master_version" {
Expand Down
6 changes: 3 additions & 3 deletions modules/beta-private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ variable "node_version" {
default = ""
}

variable "master_authorized_networks_config" {
type = list(object({ cidr_blocks = list(object({ cidr_block = string, display_name = string })) }))
description = "The desired configuration options for master authorized networks. The object format is {cidr_blocks = list(object({cidr_block = string, display_name = string}))}. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists)."
variable "master_authorized_networks" {
type = list(object({ cidr_block = string, display_name = string }))
description = "List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists)."
default = []
}

Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| kubernetes\_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string | `"latest"` | no |
| logging\_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string | `"logging.googleapis.com"` | no |
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. The object format is {cidr_blocks = list(object({cidr_block = string, display_name = string}))}. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
| master\_ipv4\_cidr\_block | (Beta) The IP range in CIDR notation to use for the hosted master network | string | `"10.0.0.0/28"` | no |
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string | `"monitoring.googleapis.com"` | no |
| name | The name of the cluster (required) | string | n/a | yes |
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ resource "google_container_cluster" "primary" {
}
}
dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
for_each = local.master_authorized_networks_config
content {
dynamic "cidr_blocks" {
for_each = master_authorized_networks_config.value.cidr_blocks
Expand Down
4 changes: 4 additions & 0 deletions modules/beta-private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ locals {

# /BETA features

master_authorized_networks_config = length(var.master_authorized_networks) == 0 ? [] : [{
cidr_blocks : var.master_authorized_networks
}]

cluster_output_node_pools_names = concat(google_container_node_pool.pools.*.name, [""])
cluster_output_node_pools_versions = concat(google_container_node_pool.pools.*.version, [""])

Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ output "monitoring_service" {

output "master_authorized_networks_config" {
description = "Networks from which access to master is permitted"
value = var.master_authorized_networks_config
value = google_container_cluster.primary.master_authorized_networks_config
}

output "master_version" {
Expand Down
6 changes: 3 additions & 3 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ variable "node_version" {
default = ""
}

variable "master_authorized_networks_config" {
type = list(object({ cidr_blocks = list(object({ cidr_block = string, display_name = string })) }))
description = "The desired configuration options for master authorized networks. The object format is {cidr_blocks = list(object({cidr_block = string, display_name = string}))}. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists)."
variable "master_authorized_networks" {
type = list(object({ cidr_block = string, display_name = string }))
description = "List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists)."
default = []
}

Expand Down
Loading