Skip to content

Commit 1cc42d0

Browse files
authored
Merge pull request #6 from terraform-google-modules/master
update
2 parents a19bd31 + 152ff2e commit 1cc42d0

File tree

55 files changed

+365
-151
lines changed

Some content is hidden

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

55 files changed

+365
-151
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ Extending the adopted spec, each change should have a link to its corresponding
2020
* `simple_regional_with_networking` example. [#195]
2121
* `release_channel` variable for beta submodules. [#271]
2222
* The `node_locations` attribute to the `node_pools` object for beta submodules. [#290]
23-
* `private_zonal_with_nteworking` example. [#308]
23+
* `private_zonal_with_networking` example. [#308]
2424
* `regional_private_node_pool_oauth_scopes` example. [#321]
25+
* The `cluster_autoscaling` variable for beta submodules. [#93]
2526

2627
### Changed
2728

@@ -314,6 +315,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
314315
[#108]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/108
315316
[#106]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/106
316317
[#94]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/94
318+
[#93]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/93
317319
[#89]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/89
318320
[#80]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/80
319321
[#77]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/77

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
149149
| 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 |
150150
| 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 |
151151
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
152-
| 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 |
152+
| 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 |
153153
| 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 |
154154
| name | The name of the cluster (required) | string | n/a | yes |
155155
| network | The VPC network to host the cluster in (required) | string | n/a | yes |

autogen/cluster.tf.tmpl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ resource "google_container_cluster" "primary" {
6262
monitoring_service = var.monitoring_service
6363

6464
{% if beta_cluster %}
65+
cluster_autoscaling {
66+
enabled = var.cluster_autoscaling.enabled
67+
dynamic "resource_limits" {
68+
for_each = local.autoscalling_resource_limits
69+
content {
70+
resource_type = lookup(resource_limits.value, "resource_type")
71+
minimum = lookup(resource_limits.value, "minimum")
72+
maximum = lookup(resource_limits.value, "maximum")
73+
}
74+
}
75+
}
76+
6577
enable_binary_authorization = var.enable_binary_authorization
6678
enable_intranode_visibility = var.enable_intranode_visibility
6779
default_max_pods_per_node = var.default_max_pods_per_node
@@ -89,7 +101,7 @@ resource "google_container_cluster" "primary" {
89101
}
90102
{% endif %}
91103
dynamic "master_authorized_networks_config" {
92-
for_each = var.master_authorized_networks_config
104+
for_each = local.master_authorized_networks_config
93105
content {
94106
dynamic "cidr_blocks" {
95107
for_each = master_authorized_networks_config.value.cidr_blocks

autogen/main.tf.tmpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ locals {
5050
node_version = var.regional ? local.node_version_regional : local.node_version_zonal
5151
{% if beta_cluster %}
5252
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
53+
54+
autoscalling_resource_limits = var.cluster_autoscaling.enabled ? [{
55+
resource_type = "cpu"
56+
minimum = var.cluster_autoscaling.min_cpu_cores
57+
maximum = var.cluster_autoscaling.max_cpu_cores
58+
}, {
59+
resource_type = "memory"
60+
minimum = var.cluster_autoscaling.min_memory_gb
61+
maximum = var.cluster_autoscaling.max_memory_gb
62+
}] : []
63+
5364
{% endif %}
5465

5566

@@ -116,6 +127,10 @@ locals {
116127
# /BETA features
117128
{% endif %}
118129

130+
master_authorized_networks_config = length(var.master_authorized_networks) == 0 ? [] : [{
131+
cidr_blocks : var.master_authorized_networks
132+
}]
133+
119134
cluster_output_node_pools_names = concat(google_container_node_pool.pools.*.name, [""])
120135
cluster_output_node_pools_versions = concat(google_container_node_pool.pools.*.version, [""])
121136

autogen/outputs.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ output "monitoring_service" {
7575

7676
output "master_authorized_networks_config" {
7777
description = "Networks from which access to master is permitted"
78-
value = var.master_authorized_networks_config
78+
value = google_container_cluster.primary.master_authorized_networks_config
7979
}
8080

8181
output "master_version" {

autogen/variables.tf.tmpl

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ variable "node_version" {
7878
default = ""
7979
}
8080

81-
variable "master_authorized_networks_config" {
82-
type = list(object({ cidr_blocks = list(object({ cidr_block = string, display_name = string })) }))
83-
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)."
81+
variable "master_authorized_networks" {
82+
type = list(object({ cidr_block = string, display_name = string }))
83+
description = "List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists)."
8484
default = []
8585
}
8686

@@ -174,8 +174,26 @@ variable "node_pools_metadata" {
174174
default-node-pool = {}
175175
}
176176
}
177-
178177
{% if beta_cluster %}
178+
179+
variable "cluster_autoscaling" {
180+
type = object({
181+
enabled = bool
182+
min_cpu_cores = number
183+
max_cpu_cores = number
184+
min_memory_gb = number
185+
max_memory_gb = number
186+
})
187+
default = {
188+
enabled = false
189+
max_cpu_cores = 0
190+
min_cpu_cores = 0
191+
max_memory_gb = 0
192+
min_memory_gb = 0
193+
}
194+
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
195+
}
196+
179197
variable "node_pools_taints" {
180198
type = map(list(object({ key = string, value = string, effect = string })))
181199
description = "Map of lists containing node taints by node-pool name"

cluster.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ resource "google_container_cluster" "primary" {
4949
monitoring_service = var.monitoring_service
5050

5151
dynamic "master_authorized_networks_config" {
52-
for_each = var.master_authorized_networks_config
52+
for_each = local.master_authorized_networks_config
5353
content {
5454
dynamic "cidr_blocks" {
5555
for_each = master_authorized_networks_config.value.cidr_blocks

docs/upgrading_to_v6.0.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Upgrading to v6.0
2+
3+
The v6.0 release of *kubernetes-engine* is a backwards incompatible
4+
release.
5+
6+
## Dropped support
7+
Due to changes in GKE, the module has dropped support for setting the `kubernetes_dashboard` variable.
8+
9+
Additionally, support for Google provider versions older than v2.18 has been removed.
10+
11+
## Migration Instructions
12+
13+
### Master Authorized Networks
14+
Previously, setting up master authorized networks required setting a nested config within `master_authorized_networks_config`.
15+
Now, to set up master authorized networks you can simply pass a list of authorized networks.
16+
17+
```diff
18+
module "kubernetes_engine_private_cluster" {
19+
source = "terraform-google-modules/kubernetes-engine/google"
20+
- version = "~> 5.0"
21+
+ version = "~> 6.0"
22+
23+
- master_authorized_networks_config = [
24+
+ master_authorized_networks = [
25+
{
26+
- cidr_blocks = [
27+
- {
28+
- cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
29+
- display_name = "VPC"
30+
- },
31+
- ]
32+
+ cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
33+
+ display_name = "VPC"
34+
},
35+
]
36+
}
37+
```

examples/node_pool/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This example illustrates how to create a cluster with multiple custom node-pool
77

88
| Name | Description | Type | Default | Required |
99
|------|-------------|:----:|:-----:|:-----:|
10+
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | object | `<map>` | no |
1011
| cluster\_name\_suffix | A suffix to append to the default cluster name | string | `""` | no |
1112
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | string | n/a | yes |
1213
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |

examples/node_pool/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module "gke" {
3636
create_service_account = false
3737
remove_default_node_pool = true
3838
disable_legacy_metadata_endpoints = false
39+
cluster_autoscaling = var.cluster_autoscaling
3940

4041
node_pools = [
4142
{

examples/node_pool/variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,20 @@ variable "compute_engine_service_account" {
5252
description = "Service account to associate to the nodes in the cluster"
5353
}
5454

55+
variable "cluster_autoscaling" {
56+
type = object({
57+
enabled = bool
58+
min_cpu_cores = number
59+
max_cpu_cores = number
60+
min_memory_gb = number
61+
max_memory_gb = number
62+
})
63+
default = {
64+
enabled = false
65+
max_cpu_cores = 0
66+
min_cpu_cores = 0
67+
max_memory_gb = 0
68+
min_memory_gb = 0
69+
}
70+
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
71+
}

examples/node_pool_update_variant/main.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,10 @@ module "gke" {
4646
enable_private_nodes = true
4747
master_ipv4_cidr_block = "172.16.0.0/28"
4848

49-
master_authorized_networks_config = [
49+
master_authorized_networks = [
5050
{
51-
cidr_blocks = [
52-
{
53-
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
54-
display_name = "VPC"
55-
},
56-
]
51+
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
52+
display_name = "VPC"
5753
},
5854
]
5955

examples/node_pool_update_variant_beta/main.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,10 @@ module "gke" {
4747
enable_private_nodes = true
4848
master_ipv4_cidr_block = "172.16.0.0/28"
4949

50-
master_authorized_networks_config = [
50+
master_authorized_networks = [
5151
{
52-
cidr_blocks = [
53-
{
54-
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
55-
display_name = "VPC"
56-
},
57-
]
52+
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
53+
display_name = "VPC"
5854
},
5955
]
6056

examples/private_zonal_with_networking/main.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,10 @@ module "gke" {
7171
enable_private_nodes = true
7272
master_ipv4_cidr_block = "172.16.0.0/28"
7373

74-
master_authorized_networks_config = [
74+
master_authorized_networks = [
7575
{
76-
cidr_blocks = [
77-
{
78-
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
79-
display_name = "VPC"
80-
},
81-
]
76+
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
77+
display_name = "VPC"
8278
},
8379
]
8480
}

examples/regional_private_node_pool_oauth_scopes/main.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,10 @@ module "gke" {
3333
remove_default_node_pool = true
3434
disable_legacy_metadata_endpoints = true
3535

36-
master_authorized_networks_config = [
36+
master_authorized_networks = [
3737
{
38-
cidr_blocks = [
39-
{
40-
cidr_block = module.gke-network.subnets_ips[0]
41-
display_name = "VPC"
42-
},
43-
]
38+
cidr_block = module.gke-network.subnets_ips[0]
39+
display_name = "VPC"
4440
},
4541
]
4642

examples/safer_cluster/main.tf

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@ module "gke" {
4949
ip_range_services = local.svc_range_name
5050
compute_engine_service_account = var.compute_engine_service_account
5151
master_ipv4_cidr_block = "172.16.0.0/28"
52-
master_authorized_networks_config = [
52+
53+
master_authorized_networks = [
5354
{
54-
cidr_blocks = [
55-
{
56-
cidr_block = "10.60.0.0/17"
57-
display_name = "VPC"
58-
},
59-
]
55+
cidr_block = "10.60.0.0/17"
56+
display_name = "VPC"
6057
},
6158
]
59+
6260
istio = true
6361
cloudrun = true
6462
}

examples/simple_regional_private/main.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,10 @@ module "gke" {
4545
enable_private_nodes = true
4646
master_ipv4_cidr_block = "172.16.0.0/28"
4747

48-
master_authorized_networks_config = [
48+
master_authorized_networks = [
4949
{
50-
cidr_blocks = [
51-
{
52-
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
53-
display_name = "VPC"
54-
},
55-
]
50+
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
51+
display_name = "VPC"
5652
},
5753
]
5854
}

examples/simple_regional_private_beta/main.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,10 @@ module "gke" {
4444
enable_private_nodes = true
4545
master_ipv4_cidr_block = "172.16.0.0/28"
4646

47-
master_authorized_networks_config = [
47+
master_authorized_networks = [
4848
{
49-
cidr_blocks = [
50-
{
51-
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
52-
display_name = "VPC"
53-
},
54-
]
49+
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
50+
display_name = "VPC"
5551
},
5652
]
5753

examples/simple_zonal_private/main.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,10 @@ module "gke" {
4646
enable_private_nodes = true
4747
master_ipv4_cidr_block = "172.16.0.0/28"
4848

49-
master_authorized_networks_config = [
49+
master_authorized_networks = [
5050
{
51-
cidr_blocks = [
52-
{
53-
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
54-
display_name = "VPC"
55-
},
56-
]
51+
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
52+
display_name = "VPC"
5753
},
5854
]
5955
}

examples/stub_domains_private/main.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,10 @@ module "gke" {
4040
enable_private_endpoint = false
4141
enable_private_nodes = true
4242

43-
master_authorized_networks_config = [
43+
master_authorized_networks = [
4444
{
45-
cidr_blocks = [
46-
{
47-
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
48-
display_name = "VPC"
49-
},
50-
]
45+
cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range
46+
display_name = "VPC"
5147
},
5248
]
5349

0 commit comments

Comments
 (0)