Skip to content

Commit ba3dcd0

Browse files
akshaybathija-githubAkshay Bathijabharathkkb
authored
feat!: Adding Support for Cost Allocation Feature in Beta (#1413)
* Adding Support for Cost Allocation Feature in Beta * Making Changes to make the module Dynamic * Bumping Min Provider Version Co-authored-by: Akshay Bathija <[email protected]> Co-authored-by: Bharath KKB <[email protected]>
1 parent d9a44c6 commit ba3dcd0

File tree

27 files changed

+92
-7
lines changed

27 files changed

+92
-7
lines changed

autogen/main/cluster.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ resource "google_container_cluster" "primary" {
5454
}
5555
}
5656
{% if beta_cluster %}
57+
dynamic "cost_management_config" {
58+
for_each = var.enable_cost_allocation ? [1] : []
59+
content {
60+
enabled = var.enable_cost_allocation
61+
}
62+
}
5763
dynamic "confidential_nodes" {
5864
for_each = local.confidential_node_config
5965
content {

autogen/main/variables.tf.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ variable "node_pools_linux_node_configs_sysctls" {
190190
{% endif %}
191191
{% endif %}
192192

193+
{% if beta_cluster %}
194+
variable "enable_cost_allocation" {
195+
type = bool
196+
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
197+
default = false
198+
}
199+
{% endif %}
193200
variable "resource_usage_export_dataset_id" {
194201
type = string
195202
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

autogen/main/versions.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ terraform {
2424
required_providers {
2525
google-beta = {
2626
source = "hashicorp/google-beta"
27-
version = ">= 4.31.0, < 5.0"
27+
version = ">= 4.35.0, < 5.0"
2828
}
2929
kubernetes = {
3030
source = "hashicorp/kubernetes"

modules/beta-autopilot-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Then perform the following commands on the root folder:
8383
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |
8484
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `true` | no |
8585
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
86+
| enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no |
8687
| 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 |
8788
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | `bool` | `false` | no |
8889
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | `bool` | `false` | no |

modules/beta-autopilot-private-cluster/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ resource "google_container_cluster" "primary" {
3939
channel = release_channel.value.channel
4040
}
4141
}
42+
dynamic "cost_management_config" {
43+
for_each = var.enable_cost_allocation ? [1] : []
44+
content {
45+
enabled = var.enable_cost_allocation
46+
}
47+
}
4248
dynamic "confidential_nodes" {
4349
for_each = local.confidential_node_config
4450
content {

modules/beta-autopilot-private-cluster/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ variable "ip_range_services" {
137137
}
138138

139139

140+
variable "enable_cost_allocation" {
141+
type = bool
142+
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
143+
default = false
144+
}
140145
variable "resource_usage_export_dataset_id" {
141146
type = string
142147
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

modules/beta-autopilot-private-cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 4.31.0, < 5.0"
24+
version = ">= 4.35.0, < 5.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

modules/beta-autopilot-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Then perform the following commands on the root folder:
7676
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |
7777
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `true` | no |
7878
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
79+
| enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no |
7980
| 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 |
8081
| 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 |
8182
| enable\_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | `bool` | `false` | no |

modules/beta-autopilot-public-cluster/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ resource "google_container_cluster" "primary" {
3939
channel = release_channel.value.channel
4040
}
4141
}
42+
dynamic "cost_management_config" {
43+
for_each = var.enable_cost_allocation ? [1] : []
44+
content {
45+
enabled = var.enable_cost_allocation
46+
}
47+
}
4248
dynamic "confidential_nodes" {
4349
for_each = local.confidential_node_config
4450
content {

modules/beta-autopilot-public-cluster/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ variable "ip_range_services" {
137137
}
138138

139139

140+
variable "enable_cost_allocation" {
141+
type = bool
142+
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
143+
default = false
144+
}
140145
variable "resource_usage_export_dataset_id" {
141146
type = string
142147
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

modules/beta-autopilot-public-cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 4.31.0, < 5.0"
24+
version = ">= 4.35.0, < 5.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ Then perform the following commands on the root folder:
185185
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
186186
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
187187
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
188+
| enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no |
188189
| enable\_identity\_service | Enable the Identity Service component, which allows customers to use external identity providers with the K8S API. | `bool` | `false` | no |
189190
| 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 |
190191
| 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 |

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ resource "google_container_cluster" "primary" {
4747
channel = release_channel.value.channel
4848
}
4949
}
50+
dynamic "cost_management_config" {
51+
for_each = var.enable_cost_allocation ? [1] : []
52+
content {
53+
enabled = var.enable_cost_allocation
54+
}
55+
}
5056
dynamic "confidential_nodes" {
5157
for_each = local.confidential_node_config
5258
content {

modules/beta-private-cluster-update-variant/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ variable "node_pools_linux_node_configs_sysctls" {
186186
}
187187
}
188188

189+
variable "enable_cost_allocation" {
190+
type = bool
191+
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
192+
default = false
193+
}
189194
variable "resource_usage_export_dataset_id" {
190195
type = string
191196
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

modules/beta-private-cluster-update-variant/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 4.31.0, < 5.0"
24+
version = ">= 4.35.0, < 5.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ Then perform the following commands on the root folder:
163163
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
164164
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
165165
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
166+
| enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no |
166167
| enable\_identity\_service | Enable the Identity Service component, which allows customers to use external identity providers with the K8S API. | `bool` | `false` | no |
167168
| 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 |
168169
| 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 |

modules/beta-private-cluster/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ resource "google_container_cluster" "primary" {
4747
channel = release_channel.value.channel
4848
}
4949
}
50+
dynamic "cost_management_config" {
51+
for_each = var.enable_cost_allocation ? [1] : []
52+
content {
53+
enabled = var.enable_cost_allocation
54+
}
55+
}
5056
dynamic "confidential_nodes" {
5157
for_each = local.confidential_node_config
5258
content {

modules/beta-private-cluster/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ variable "node_pools_linux_node_configs_sysctls" {
186186
}
187187
}
188188

189+
variable "enable_cost_allocation" {
190+
type = bool
191+
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
192+
default = false
193+
}
189194
variable "resource_usage_export_dataset_id" {
190195
type = string
191196
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

modules/beta-private-cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 4.31.0, < 5.0"
24+
version = ">= 4.35.0, < 5.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ Then perform the following commands on the root folder:
178178
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
179179
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
180180
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
181+
| enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no |
181182
| enable\_identity\_service | Enable the Identity Service component, which allows customers to use external identity providers with the K8S API. | `bool` | `false` | no |
182183
| 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 |
183184
| 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 |

modules/beta-public-cluster-update-variant/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ resource "google_container_cluster" "primary" {
4747
channel = release_channel.value.channel
4848
}
4949
}
50+
dynamic "cost_management_config" {
51+
for_each = var.enable_cost_allocation ? [1] : []
52+
content {
53+
enabled = var.enable_cost_allocation
54+
}
55+
}
5056
dynamic "confidential_nodes" {
5157
for_each = local.confidential_node_config
5258
content {

modules/beta-public-cluster-update-variant/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ variable "node_pools_linux_node_configs_sysctls" {
186186
}
187187
}
188188

189+
variable "enable_cost_allocation" {
190+
type = bool
191+
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
192+
default = false
193+
}
189194
variable "resource_usage_export_dataset_id" {
190195
type = string
191196
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

modules/beta-public-cluster-update-variant/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 4.31.0, < 5.0"
24+
version = ">= 4.35.0, < 5.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ Then perform the following commands on the root folder:
156156
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
157157
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
158158
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
159+
| enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no |
159160
| enable\_identity\_service | Enable the Identity Service component, which allows customers to use external identity providers with the K8S API. | `bool` | `false` | no |
160161
| 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 |
161162
| 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 |

modules/beta-public-cluster/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ resource "google_container_cluster" "primary" {
4747
channel = release_channel.value.channel
4848
}
4949
}
50+
dynamic "cost_management_config" {
51+
for_each = var.enable_cost_allocation ? [1] : []
52+
content {
53+
enabled = var.enable_cost_allocation
54+
}
55+
}
5056
dynamic "confidential_nodes" {
5157
for_each = local.confidential_node_config
5258
content {

modules/beta-public-cluster/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ variable "node_pools_linux_node_configs_sysctls" {
186186
}
187187
}
188188

189+
variable "enable_cost_allocation" {
190+
type = bool
191+
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
192+
default = false
193+
}
189194
variable "resource_usage_export_dataset_id" {
190195
type = string
191196
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

modules/beta-public-cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 4.31.0, < 5.0"
24+
version = ">= 4.35.0, < 5.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

0 commit comments

Comments
 (0)