Skip to content

Commit b267933

Browse files
authored
Merge branch 'master' into fix/180
2 parents 5ca69ce + c1ecd54 commit b267933

File tree

47 files changed

+384
-154
lines changed

Some content is hidden

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

47 files changed

+384
-154
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +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+
1015
### Added
1116

17+
* Added support for resource usage export config [#238]
18+
* Added `sandbox_enabled` variable to use GKE Sandbox [#241]
19+
* Added `grant_registry_access` variable to grant Container Registry access to created SA [#236]
1220
* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
21+
* Support for Workload Identity beta feature [#234]
22+
* 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]
1324

1425
## [v4.1.0] 2019-07-24
1526

@@ -167,6 +178,13 @@ Extending the adopted spec, each change should have a link to its corresponding
167178
[v0.3.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.2.0...v0.3.0
168179
[v0.2.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.1.0...v0.2.0
169180

181+
[#228]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/228
182+
[#238]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/238
183+
[#241]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/241
184+
[#250]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/250
185+
[#236]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/236
186+
[#217]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/217
187+
[#234]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/234
170188
[#216]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/216
171189
[#214]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/214
172190
[#210]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/210

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
137137
| create\_service\_account | Defines if service account specified to run nodes should be created. | bool | `"true"` | no |
138138
| description | The description of the cluster | string | `""` | no |
139139
| 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. | bool | `"true"` | no |
140+
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
140141
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
141142
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |
142143
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | number | `"0"` | no |
@@ -161,7 +162,6 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
161162
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) | `<map>` | no |
162163
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) | `<map>` | no |
163164
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map(list(string)) | `<map>` | no |
164-
| node\_pools\_taints | Map of lists containing node taints by node-pool name | object | `<map>` | no |
165165
| 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 |
166166
| 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 |
167167
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |

autogen/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 47 additions & 4 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
@@ -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
}
@@ -181,14 +198,33 @@ resource "google_container_cluster" "primary" {
181198
state = database_encryption.value.state
182199
}
183200
}
201+
202+
dynamic "workload_identity_config" {
203+
for_each = local.cluster_workload_identity_config
204+
205+
content {
206+
identity_namespace = workload_identity_config.value.identity_namespace
207+
}
208+
}
209+
210+
dynamic "authenticator_groups_config" {
211+
for_each = local.cluster_authenticator_security_group
212+
content {
213+
security_group = authenticator_groups_config.value.security_group
214+
}
215+
}
184216
{% endif %}
185217
}
186218

187219
/******************************************
188220
Create Container Cluster node pools
189221
*****************************************/
190222
resource "google_container_node_pool" "pools" {
223+
{% if beta_cluster %}
191224
provider = google-beta
225+
{% else %}
226+
provider = google
227+
{% endif %}
192228
count = length(var.node_pools)
193229
name = var.node_pools[count.index]["name"]
194230
project = var.project_id
@@ -208,9 +244,14 @@ resource "google_container_node_pool" "pools" {
208244
max_pods_per_node = lookup(var.node_pools[count.index], "max_pods_per_node", null)
209245
{% endif %}
210246

211-
autoscaling {
212-
min_node_count = lookup(var.node_pools[count.index], "min_count", 1)
213-
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+
}
214255
}
215256

216257
management {
@@ -244,6 +285,7 @@ resource "google_container_node_pool" "pools" {
244285
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
245286
},
246287
)
288+
{% if beta_cluster %}
247289
dynamic "taint" {
248290
for_each = concat(
249291
var.node_pools_taints["all"],
@@ -255,6 +297,7 @@ resource "google_container_node_pool" "pools" {
255297
value = taint.value.value
256298
}
257299
}
300+
{% endif %}
258301
tags = concat(
259302
["gke-${var.name}"],
260303
["gke-${var.name}-${var.node_pools[count.index]["name"]}"],

autogen/main.tf

Lines changed: 10 additions & 1 deletion
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
@@ -71,6 +71,12 @@ locals {
7171
node_metadata = var.node_metadata
7272
}]
7373

74+
cluster_authenticator_security_group = var.authenticator_security_group == null ? [] : [{
75+
security_group = var.authenticator_security_group
76+
}]
77+
78+
cluster_sandbox_enabled = var.sandbox_enabled ? ["gvisor"] : []
79+
7480
{% endif %}
7581

7682
cluster_output_name = google_container_cluster.primary.name
@@ -136,6 +142,9 @@ locals {
136142
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
137143
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled
138144
cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled
145+
cluster_workload_identity_config = var.identity_namespace == "" ? [] : [{
146+
identity_namespace = var.identity_namespace
147+
}]
139148
# /BETA features
140149
{% endif %}
141150
}

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/sa.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
6161
role = "roles/monitoring.viewer"
6262
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
6363
}
64+
65+
resource "google_project_iam_member" "cluster_service_account-gcr" {
66+
count = var.create_service_account && var.grant_registry_access ? 1 : 0
67+
project = var.project_id
68+
role = "roles/storage.objectViewer"
69+
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
70+
}
71+

autogen/variables.tf

Lines changed: 34 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"
@@ -261,6 +263,12 @@ variable "create_service_account" {
261263
default = true
262264
}
263265

266+
variable "grant_registry_access" {
267+
type = bool
268+
description = "Grants created cluster-specific service account storage.objectViewer role."
269+
default = false
270+
}
271+
264272
variable "service_account" {
265273
type = string
266274
description = "The service account to run nodes as if not overridden in `node_pools`. The create_service_account variable default value (true) will cause a cluster-specific service account to be created."
@@ -360,20 +368,45 @@ variable "pod_security_policy_config" {
360368
}]
361369
}
362370

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+
363377
variable "node_metadata" {
364378
description = "Specifies how node metadata is exposed to the workload running on the node"
365379
default = "UNSPECIFIED"
366380
}
367381

382+
variable "sandbox_enabled" {
383+
type = bool
384+
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)."
385+
default = false
386+
}
387+
368388
variable "enable_intranode_visibility" {
369389
type = bool
370390
description = "Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network"
371391
default = false
372392
}
373393

374-
variable "enable_vertical_pod_autoscaling" {
394+
variable "enable_vertical_pod_autoscaling" {
375395
type = bool
376396
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"
377397
default = false
378398
}
399+
400+
variable "identity_namespace" {
401+
description = "Workload Identity namespace"
402+
type = string
403+
default = ""
404+
}
405+
406+
variable "authenticator_security_group" {
407+
type = string
408+
description = "The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected]"
409+
default = null
410+
}
411+
379412
{% endif %}

cluster.tf

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 2.9.0"
23-
region = var.region
24-
}
25-
26-
provider "google-beta" {
27-
version = "~> 2.9.0"
22+
version = "~> 2.12.0"
2823
region = var.region
2924
}
3025

examples/disable_client_cert/main.tf

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 2.9.0"
23-
region = var.region
24-
}
25-
26-
provider "google-beta" {
27-
version = "~> 2.9.0"
22+
version = "~> 2.12.0"
2823
region = var.region
2924
}
3025

0 commit comments

Comments
 (0)