Skip to content

Commit 6244963

Browse files
authored
Merge branch 'master' into master
2 parents 5915886 + 9f71320 commit 6244963

File tree

40 files changed

+202
-159
lines changed

40 files changed

+202
-159
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
Extending the adopted spec, each change should have a link to its corresponding pull request appended.
88

99
## [Unreleased]
10+
11+
### Changed
12+
13+
* All Beta functionality removed from non-beta clusters, some properties like node_pool taints available only in beta cluster now [#228]
14+
* **Breaking**: Enabled metadata-concealment by default [#248]
15+
1016
### Added
11-
* Enabled metadata-concealment by default [#248]
17+
* Added support for resource usage export config [#238]
18+
* Added `sandbox_enabled` variable to use GKE Sandbox [#241]
1219
* Added `grant_registry_access` variable to grant Container Registry access to created SA [#236]
1320
* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
1421
* Support for Workload Identity beta feature [#234]
1522
* Support for Google Groups based RBAC beta feature [#217]
23+
* Support for disabling node pool autoscaling by setting `autoscaling` to `false` within the node pool variable. [#250]
1624

1725
## [v4.1.0] 2019-07-24
1826

@@ -171,6 +179,10 @@ Extending the adopted spec, each change should have a link to its corresponding
171179
[v0.2.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.1.0...v0.2.0
172180

173181
[#248]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/248
182+
[#228]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/228
183+
[#238]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/238
184+
[#241]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/241
185+
[#250]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/250
174186
[#236]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/236
175187
[#217]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/217
176188
[#234]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/234

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
162162
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) | `<map>` | no |
163163
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) | `<map>` | no |
164164
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map(list(string)) | `<map>` | no |
165-
| node\_pools\_taints | Map of lists containing node taints by node-pool name | object | `<map>` | no |
166165
| node\_version | The Kubernetes version of the node pools. Defaults kubernetes_version (master) variable and can be overridden for individual node pools by setting the `version` key on them. Must be empyty or set the same as master at cluster creation. | string | `""` | no |
167166
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) | `<list>` | no |
168167
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |

autogen/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ There are multiple examples included in the [examples](./examples/) folder but s
2828

2929
```hcl
3030
module "gke" {
31-
source = "terraform-google-modules/kubernetes-engine/google{% if private_cluster %}//modules/private-cluster{% endif %}"
31+
source = "terraform-google-modules/kubernetes-engine/google{{ module_path }}"
3232
project_id = "<PROJECT ID>"
3333
name = "gke-test-1"
3434
region = "us-central1"
@@ -157,7 +157,7 @@ The [project factory](https://github.com/terraform-google-modules/terraform-goog
157157
- [kubectl](https://github.com/kubernetes/kubernetes/releases) 1.9.x
158158
#### Terraform and Plugins
159159
- [Terraform](https://www.terraform.io/downloads.html) 0.12
160-
{% if private_cluster or beta_cluster %}
160+
{% if beta_cluster %}
161161
- [Terraform Provider for GCP Beta][terraform-provider-google-beta] v2.9
162162
{% else %}
163163
- [Terraform Provider for GCP][terraform-provider-google] v2.9
@@ -339,7 +339,7 @@ command.
339339
{% else %}
340340
[upgrading-to-v3.0]: docs/upgrading_to_v3.0.md
341341
{% endif %}
342-
{% if private_cluster or beta_cluster %}
342+
{% if beta_cluster %}
343343
[terraform-provider-google-beta]: https://github.com/terraform-providers/terraform-provider-google-beta
344344
{% else %}
345345
[terraform-provider-google]: https://github.com/terraform-providers/terraform-provider-google

autogen/auth.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Retrieve authentication token
2121
*****************************************/
2222
data "google_client_config" "default" {
23-
{% if private_cluster or beta_cluster %}
23+
{% if beta_cluster %}
2424
provider = google-beta
2525
{% else %}
2626
provider = google

autogen/cluster.tf

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Create Container Cluster
2121
*****************************************/
2222
resource "google_container_cluster" "primary" {
23-
{% if private_cluster or beta_cluster %}
23+
{% if beta_cluster %}
2424
provider = google-beta
2525
{% else %}
2626
provider = google
@@ -67,6 +67,15 @@ resource "google_container_cluster" "primary" {
6767
}
6868
}
6969

70+
dynamic "resource_usage_export_config" {
71+
for_each = var.resource_usage_export_dataset_id != "" ? [var.resource_usage_export_dataset_id] : []
72+
content {
73+
enable_network_egress_metering = true
74+
bigquery_destination {
75+
dataset_id = resource_usage_export_config.value
76+
}
77+
}
78+
}
7079
{% endif %}
7180
dynamic "master_authorized_networks_config" {
7281
for_each = var.master_authorized_networks_config
@@ -134,7 +143,7 @@ resource "google_container_cluster" "primary" {
134143
}
135144

136145
lifecycle {
137-
ignore_changes = [node_pool]
146+
ignore_changes = [node_pool, initial_node_count]
138147
}
139148

140149
timeouts {
@@ -158,6 +167,14 @@ resource "google_container_cluster" "primary" {
158167
node_metadata = workload_metadata_config.value.node_metadata
159168
}
160169
}
170+
171+
dynamic "sandbox_config" {
172+
for_each = local.cluster_sandbox_enabled
173+
174+
content {
175+
sandbox_type = sandbox_config.value
176+
}
177+
}
161178
{% endif %}
162179
}
163180
}
@@ -203,7 +220,11 @@ resource "google_container_cluster" "primary" {
203220
Create Container Cluster node pools
204221
*****************************************/
205222
resource "google_container_node_pool" "pools" {
223+
{% if beta_cluster %}
206224
provider = google-beta
225+
{% else %}
226+
provider = google
227+
{% endif %}
207228
count = length(var.node_pools)
208229
name = var.node_pools[count.index]["name"]
209230
project = var.project_id
@@ -223,9 +244,14 @@ resource "google_container_node_pool" "pools" {
223244
max_pods_per_node = lookup(var.node_pools[count.index], "max_pods_per_node", null)
224245
{% endif %}
225246

226-
autoscaling {
227-
min_node_count = lookup(var.node_pools[count.index], "min_count", 1)
228-
max_node_count = lookup(var.node_pools[count.index], "max_count", 100)
247+
node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "min_count", 1)
248+
249+
dynamic "autoscaling" {
250+
for_each = lookup(var.node_pools[count.index], "autoscaling", true) ? [var.node_pools[count.index]] : []
251+
content {
252+
min_node_count = lookup(autoscaling.value, "min_count", 1)
253+
max_node_count = lookup(autoscaling.value, "max_count", 100)
254+
}
229255
}
230256

231257
management {
@@ -259,6 +285,7 @@ resource "google_container_node_pool" "pools" {
259285
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
260286
},
261287
)
288+
{% if beta_cluster %}
262289
dynamic "taint" {
263290
for_each = concat(
264291
var.node_pools_taints["all"],
@@ -270,6 +297,7 @@ resource "google_container_node_pool" "pools" {
270297
value = taint.value.value
271298
}
272299
}
300+
{% endif %}
273301
tags = concat(
274302
["gke-${var.name}"],
275303
["gke-${var.name}-${var.node_pools[count.index]["name"]}"],

autogen/main.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Get available zones in region
2121
*****************************************/
2222
data "google_compute_zones" "available" {
23-
{% if private_cluster or beta_cluster %}
23+
{% if beta_cluster %}
2424
provider = google-beta
2525
{% else %}
2626
provider = google
@@ -75,6 +75,8 @@ locals {
7575
security_group = var.authenticator_security_group
7676
}]
7777

78+
cluster_sandbox_enabled = var.sandbox_enabled ? ["gvisor"] : []
79+
7880
{% endif %}
7981

8082
cluster_output_name = google_container_cluster.primary.name
@@ -102,10 +104,10 @@ locals {
102104

103105
{% if beta_cluster %}
104106
# BETA features
105-
cluster_output_istio_enabled = google_container_cluster.primary.addons_config.0.istio_config.0.disabled
106-
cluster_output_pod_security_policy_enabled = google_container_cluster.primary.pod_security_policy_config.0.enabled
107+
cluster_output_istio_disabled = google_container_cluster.primary.addons_config.0.istio_config != null && length(google_container_cluster.primary.addons_config.0.istio_config) == 1 ? google_container_cluster.primary.addons_config.0.istio_config.0.disabled : false
108+
cluster_output_pod_security_policy_enabled = google_container_cluster.primary.pod_security_policy_config != null && length(google_container_cluster.primary.pod_security_policy_config) == 1 ? google_container_cluster.primary.pod_security_policy_config.0.enabled : false
107109
cluster_output_intranode_visbility_enabled = google_container_cluster.primary.enable_intranode_visibility
108-
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling.0.enabled
110+
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling != null && length(google_container_cluster.primary.vertical_pod_autoscaling) == 1 ? google_container_cluster.primary.vertical_pod_autoscaling.0.enabled : false
109111

110112
# /BETA features
111113
{% endif %}
@@ -135,7 +137,7 @@ locals {
135137
cluster_kubernetes_dashboard_enabled = ! local.cluster_output_kubernetes_dashboard_enabled
136138
{% if beta_cluster %}
137139
# BETA features
138-
cluster_istio_enabled = ! local.cluster_output_istio_enabled
140+
cluster_istio_enabled = ! local.cluster_output_istio_disabled
139141
cluster_cloudrun_enabled = var.cloudrun
140142
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
141143
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled

autogen/networks.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{{ autogeneration_note }}
1818

1919
data "google_compute_network" "gke_network" {
20-
{% if private_cluster or beta_cluster %}
20+
{% if beta_cluster %}
2121
provider = google-beta
2222
{% else %}
2323
provider = google
@@ -28,7 +28,7 @@ data "google_compute_network" "gke_network" {
2828
}
2929

3030
data "google_compute_subnetwork" "gke_subnetwork" {
31-
{% if private_cluster or beta_cluster %}
31+
{% if beta_cluster %}
3232
provider = google-beta
3333
{% else %}
3434
provider = google

autogen/variables.tf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ variable "node_pools_metadata" {
178178
}
179179
}
180180

181+
{% if beta_cluster %}
181182
variable "node_pools_taints" {
182183
type = map(list(object({key=string,value=string,effect=string})))
183184
description = "Map of lists containing node taints by node-pool name"
@@ -188,6 +189,7 @@ variable "node_pools_taints" {
188189
}
189190
}
190191

192+
{% endif %}
191193
variable "node_pools_tags" {
192194
type = map(list(string))
193195
description = "Map of lists containing node network tags by node-pool name"
@@ -366,19 +368,31 @@ variable "pod_security_policy_config" {
366368
}]
367369
}
368370

371+
variable "resource_usage_export_dataset_id" {
372+
type = string
373+
description = "The dataset id for which network egress metering for this cluster will be enabled. If enabled, a daemonset will be created in the cluster to meter network egress traffic."
374+
default = ""
375+
}
376+
369377
variable "node_metadata" {
370378
description = "Specifies how node metadata is exposed to the workload running on the node"
371379
default = "SECURE"
372380
type = string
373381
}
374382

383+
variable "sandbox_enabled" {
384+
type = bool
385+
description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it)."
386+
default = false
387+
}
388+
375389
variable "enable_intranode_visibility" {
376390
type = bool
377391
description = "Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network"
378392
default = false
379393
}
380394

381-
variable "enable_vertical_pod_autoscaling" {
395+
variable "enable_vertical_pod_autoscaling" {
382396
type = bool
383397
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"
384398
default = false

cluster.tf

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ resource "google_container_cluster" "primary" {
9999
}
100100

101101
lifecycle {
102-
ignore_changes = [node_pool]
102+
ignore_changes = [node_pool, initial_node_count]
103103
}
104104

105105
timeouts {
@@ -125,7 +125,7 @@ resource "google_container_cluster" "primary" {
125125
Create Container Cluster node pools
126126
*****************************************/
127127
resource "google_container_node_pool" "pools" {
128-
provider = google-beta
128+
provider = google
129129
count = length(var.node_pools)
130130
name = var.node_pools[count.index]["name"]
131131
project = var.project_id
@@ -142,9 +142,14 @@ resource "google_container_node_pool" "pools" {
142142
lookup(var.node_pools[count.index], "min_count", 1),
143143
)
144144

145-
autoscaling {
146-
min_node_count = lookup(var.node_pools[count.index], "min_count", 1)
147-
max_node_count = lookup(var.node_pools[count.index], "max_count", 100)
145+
node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "min_count", 1)
146+
147+
dynamic "autoscaling" {
148+
for_each = lookup(var.node_pools[count.index], "autoscaling", true) ? [var.node_pools[count.index]] : []
149+
content {
150+
min_node_count = lookup(autoscaling.value, "min_count", 1)
151+
max_node_count = lookup(autoscaling.value, "max_count", 100)
152+
}
148153
}
149154

150155
management {
@@ -178,17 +183,6 @@ resource "google_container_node_pool" "pools" {
178183
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
179184
},
180185
)
181-
dynamic "taint" {
182-
for_each = concat(
183-
var.node_pools_taints["all"],
184-
var.node_pools_taints[var.node_pools[count.index]["name"]],
185-
)
186-
content {
187-
effect = taint.value.effect
188-
key = taint.value.key
189-
value = taint.value.value
190-
}
191-
}
192186
tags = concat(
193187
["gke-${var.name}"],
194188
["gke-${var.name}-${var.node_pools[count.index]["name"]}"],

examples/deploy_service/main.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ provider "google" {
2323
region = var.region
2424
}
2525

26-
provider "google-beta" {
27-
version = "~> 2.12.0"
28-
region = var.region
29-
}
30-
3126
provider "kubernetes" {
3227
load_config_file = false
3328
host = "https://${module.gke.endpoint}"

examples/disable_client_cert/main.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ provider "google" {
2323
region = var.region
2424
}
2525

26-
provider "google-beta" {
27-
version = "~> 2.12.0"
28-
region = var.region
29-
}
30-
3126
module "gke" {
3227
source = "../../"
3328

examples/node_pool/main.tf

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@ locals {
1818
cluster_type = "node-pool"
1919
}
2020

21-
provider "google" {
22-
version = "~> 2.12.0"
23-
region = var.region
24-
}
25-
2621
provider "google-beta" {
2722
version = "~> 2.12.0"
2823
region = var.region
2924
}
3025

3126
module "gke" {
32-
source = "../../"
27+
source = "../../modules/beta-public-cluster/"
3328
project_id = var.project_id
3429
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
3530
regional = false

examples/shared_vpc/main.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ provider "google" {
2323
region = var.region
2424
}
2525

26-
provider "google-beta" {
27-
version = "~> 2.12.0"
28-
region = var.region
29-
}
30-
3126
module "gke" {
3227
source = "../../"
3328
project_id = var.project_id

0 commit comments

Comments
 (0)