Skip to content

Commit 54eca6b

Browse files
authored
feat: Add fully configurable resource usage export block in GA and upgrade GCP provider (#491)
BREAKING CHANGE: Minimum Google provider version increased to 3.16.
1 parent 16bdd6e commit 54eca6b

File tree

63 files changed

+338
-109
lines changed

Some content is hidden

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

63 files changed

+338
-109
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ Then perform the following commands on the root folder:
110110
| default\_max\_pods\_per\_node | The maximum number of pods to schedule per node | string | `"110"` | no |
111111
| description | The description of the cluster | string | `""` | no |
112112
| 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 |
113+
| enable\_network\_egress\_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | bool | `"false"` | no |
114+
| enable\_resource\_consumption\_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | bool | `"true"` | no |
113115
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers | list(string) | `<list>` | no |
114116
| firewall\_priority | Priority rule for firewall rules | number | `"1000"` | no |
115117
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
@@ -142,6 +144,7 @@ Then perform the following commands on the root folder:
142144
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
143145
| registry\_project\_id | Project holding the Google Container Registry. If empty, we use the cluster project. If grant_registry_access is true, storage.objectViewer role is assigned on this project. | string | `""` | no |
144146
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
147+
| resource\_usage\_export\_dataset\_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | string | `""` | no |
145148
| service\_account | 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. | string | `""` | no |
146149
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks `stub_domains` and `upstream_nameservers` variables functionality. | bool | `"false"` | no |
147150
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map(list(string)) | `<map>` | no |

autogen/main/cluster.tf.tmpl

+16-10
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,6 @@ resource "google_container_cluster" "primary" {
9999
enabled = pod_security_policy_config.value.enabled
100100
}
101101
}
102-
103-
dynamic "resource_usage_export_config" {
104-
for_each = var.resource_usage_export_dataset_id != "" ? [var.resource_usage_export_dataset_id] : []
105-
content {
106-
enable_network_egress_metering = true
107-
bigquery_destination {
108-
dataset_id = resource_usage_export_config.value
109-
}
110-
}
111-
}
112102
{% endif %}
113103
dynamic "master_authorized_networks_config" {
114104
for_each = local.master_authorized_networks_config
@@ -223,6 +213,22 @@ resource "google_container_cluster" "primary" {
223213
}
224214
}
225215

216+
dynamic "resource_usage_export_config" {
217+
for_each = var.resource_usage_export_dataset_id != "" ? [{
218+
enable_network_egress_metering = var.enable_network_egress_export
219+
enable_resource_consumption_metering = var.enable_resource_consumption_export
220+
dataset_id = var.resource_usage_export_dataset_id
221+
}] : []
222+
223+
content {
224+
enable_network_egress_metering = resource_usage_export_config.value.enable_network_egress_metering
225+
enable_resource_consumption_metering = resource_usage_export_config.value.enable_resource_consumption_metering
226+
bigquery_destination {
227+
dataset_id = resource_usage_export_config.value.dataset_id
228+
}
229+
}
230+
}
231+
226232
{% if private_cluster %}
227233
dynamic "private_cluster_config" {
228234
for_each = var.enable_private_nodes ? [{

autogen/main/variables.tf.tmpl

+18-6
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,24 @@ variable "node_pools_metadata" {
182182
default-node-pool = {}
183183
}
184184
}
185+
186+
variable "resource_usage_export_dataset_id" {
187+
type = string
188+
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."
189+
default = ""
190+
}
191+
192+
variable "enable_network_egress_export" {
193+
type = bool
194+
description = "Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic."
195+
default = false
196+
}
197+
198+
variable "enable_resource_consumption_export" {
199+
type = bool
200+
description = "Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export."
201+
default = true
202+
}
185203
{% if beta_cluster %}
186204

187205
variable "enable_kubernetes_alpha" {
@@ -428,12 +446,6 @@ variable "pod_security_policy_config" {
428446
}]
429447
}
430448

431-
variable "resource_usage_export_dataset_id" {
432-
type = string
433-
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."
434-
default = ""
435-
}
436-
437449
variable "node_metadata" {
438450
description = "Specifies how node metadata is exposed to the workload running on the node"
439451
default = "SECURE"

autogen/main/versions.tf.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ terraform {
1919

2020
required_providers {
2121
{% if beta_cluster %}
22-
google-beta = ">= 3.1, <4.0.0"
22+
google-beta = ">= 3.16, <4.0.0"
2323
{% else %}
24-
google = ">= 2.18, <4.0.0"
24+
google = ">= 3.16, <4.0.0"
2525
{% endif %}
2626
}
2727
}

autogen/safer-cluster/variables.tf.tmpl

+12
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,18 @@ variable "resource_usage_export_dataset_id" {
268268
default = ""
269269
}
270270

271+
variable "enable_network_egress_export" {
272+
type = bool
273+
description = "Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic."
274+
default = false
275+
}
276+
277+
variable "enable_resource_consumption_export" {
278+
type = bool
279+
description = "Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export."
280+
default = true
281+
}
282+
271283
variable "sandbox_enabled" {
272284
type = bool
273285
description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it)."

cluster.tf

+16
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,22 @@ resource "google_container_cluster" "primary" {
118118
}
119119
}
120120

121+
dynamic "resource_usage_export_config" {
122+
for_each = var.resource_usage_export_dataset_id != "" ? [{
123+
enable_network_egress_metering = var.enable_network_egress_export
124+
enable_resource_consumption_metering = var.enable_resource_consumption_export
125+
dataset_id = var.resource_usage_export_dataset_id
126+
}] : []
127+
128+
content {
129+
enable_network_egress_metering = resource_usage_export_config.value.enable_network_egress_metering
130+
enable_resource_consumption_metering = resource_usage_export_config.value.enable_resource_consumption_metering
131+
bigquery_destination {
132+
dataset_id = resource_usage_export_config.value.dataset_id
133+
}
134+
}
135+
}
136+
121137

122138
remove_default_node_pool = var.remove_default_node_pool
123139
}

examples/deploy_service/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/disable_client_cert/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/node_pool/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/node_pool_update_variant/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/node_pool_update_variant_beta/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
credentials = file(var.credentials_path)
2424
region = var.region
2525
}

examples/regional_private_node_pool_oauth_scopes/provider.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616

1717
provider "google" {
18-
version = "3.14.0"
18+
version = "3.16.0"
1919
}
2020

2121
provider "google-beta" {
22-
version = "3.14.0"
22+
version = "3.16.0"
2323
}

examples/safer_cluster/main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ locals {
3030
}
3131

3232
provider "google" {
33-
version = "~> 3.14.0"
33+
version = "~> 3.16.0"
3434
}
3535

3636
provider "google-beta" {
37-
version = "~> 3.14.0"
37+
version = "~> 3.16.0"
3838
}
3939

4040
module "gke" {

examples/shared_vpc/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/simple_regional/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/simple_regional_beta/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/simple_regional_private/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/simple_regional_private_beta/main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

2626
provider "google-beta" {
27-
version = "~> 3.14.0"
27+
version = "~> 3.16.0"
2828
region = var.region
2929
}
3030

examples/simple_regional_with_kubeconfig/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.3.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/simple_regional_with_networking/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
provider "google" {
18-
version = "~> 3.14.0"
18+
version = "~> 3.16.0"
1919
}
2020

2121
module "gcp-network" {

examples/simple_zonal_private/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/simple_zonal_with_acm/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/stub_domains/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/stub_domains_private/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
provider "google" {
18-
version = "~> 3.14.0"
18+
version = "~> 3.16.0"
1919
region = var.region
2020
}
2121

examples/stub_domains_upstream_nameservers/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/upstream_nameservers/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/workload_identity/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

examples/workload_metadata_config/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.14.0"
22+
version = "~> 3.16.0"
2323
region = var.region
2424
}
2525

modules/beta-private-cluster-update-variant/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ Then perform the following commands on the root folder:
175175
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
176176
| enable\_intranode\_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | bool | `"false"` | no |
177177
| enable\_kubernetes\_alpha | Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days. | bool | `"false"` | no |
178+
| enable\_network\_egress\_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | bool | `"false"` | no |
178179
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | bool | `"false"` | no |
179180
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | bool | `"false"` | no |
181+
| enable\_resource\_consumption\_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | bool | `"true"` | no |
180182
| enable\_shielded\_nodes | Enable Shielded Nodes features on all nodes in this cluster | bool | `"true"` | no |
181183
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool | `"false"` | no |
182184
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers | list(string) | `<list>` | no |
@@ -221,7 +223,7 @@ Then perform the following commands on the root folder:
221223
| registry\_project\_id | Project holding the Google Container Registry. If empty, we use the cluster project. If grant_registry_access is true, storage.objectViewer role is assigned on this project. | string | `""` | no |
222224
| release\_channel | (Beta) The release channel of this cluster. Accepted values are `UNSPECIFIED`, `RAPID`, `REGULAR` and `STABLE`. Defaults to `UNSPECIFIED`. | string | `"null"` | no |
223225
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
224-
| resource\_usage\_export\_dataset\_id | 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. | string | `""` | no |
226+
| resource\_usage\_export\_dataset\_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | string | `""` | no |
225227
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it). | bool | `"false"` | no |
226228
| service\_account | 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. | string | `""` | no |
227229
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks `stub_domains` and `upstream_nameservers` variables functionality. | bool | `"false"` | no |

0 commit comments

Comments
 (0)