Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: cost_management_config is out of beta now #1470

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Then perform the following commands on the root folder:
| 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 |
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
| 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 |
| 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 |
| 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 |
| enable\_shielded\_nodes | Enable Shielded Nodes features on all nodes in this cluster | `bool` | `true` | no |
Expand Down
6 changes: 3 additions & 3 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ resource "google_container_cluster" "primary" {
channel = release_channel.value.channel
}
}
{% if beta_cluster %}
dynamic "cost_management_config" {
for_each = var.enable_cost_allocation ? [1] : []
content {
enabled = var.enable_cost_allocation
}
}
{% if beta_cluster %}
dynamic "confidential_nodes" {
for_each = local.confidential_node_config
content {
Expand Down Expand Up @@ -598,7 +598,7 @@ resource "google_container_node_pool" "windows_pools" {
for_each = local.node_pools
{% else %}
for_each = local.windows_node_pools
{% endif %}
{% endif %}
{% if update_variant %}
name = { for k, v in random_id.name : k => v.hex }[each.key]
{% else %}
Expand Down Expand Up @@ -645,7 +645,7 @@ resource "google_container_node_pool" "windows_pools" {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
Expand Down
2 changes: 0 additions & 2 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,11 @@ variable "node_pools_linux_node_configs_sysctls" {
{% endif %}
{% endif %}

{% if beta_cluster %}
variable "enable_cost_allocation" {
type = bool
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"
default = false
}
{% endif %}
variable "resource_usage_export_dataset_id" {
type = string
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."
Expand Down
2 changes: 1 addition & 1 deletion autogen/main/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.36.0, < 5.0"
version = ">= 4.42.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
8 changes: 6 additions & 2 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ resource "google_container_cluster" "primary" {
channel = release_channel.value.channel
}
}
dynamic "cost_management_config" {
for_each = var.enable_cost_allocation ? [1] : []
content {
enabled = var.enable_cost_allocation
}
}

subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"

Expand Down Expand Up @@ -303,7 +309,6 @@ resource "google_container_cluster" "primary" {
resource "google_container_node_pool" "pools" {
provider = google
for_each = local.node_pools

name = each.key
project = var.project_id
location = local.location
Expand Down Expand Up @@ -458,7 +463,6 @@ resource "google_container_node_pool" "pools" {
resource "google_container_node_pool" "windows_pools" {
provider = google
for_each = local.windows_node_pools

name = each.key
project = var.project_id
location = local.location
Expand Down
2 changes: 1 addition & 1 deletion docs/upgrading_to_v24.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ To avoid this, it is possible to edit the remote state of the `random_id` resour

### Minimum Google Provider versions

Minimum Google Provider versions have been updated to `4.36.0`.
Minimum Google Provider versions have been updated to `4.42.0`.
1 change: 1 addition & 0 deletions examples/simple_regional/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module "gke" {
ip_range_services = var.ip_range_services
create_service_account = false
service_account = var.compute_engine_service_account
enable_cost_allocation = true
enable_binary_authorization = var.enable_binary_authorization
skip_provisioners = var.skip_provisioners
}
2 changes: 1 addition & 1 deletion modules/beta-autopilot-private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.36.0, < 5.0"
version = ">= 4.42.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-autopilot-public-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.36.0, < 5.0"
version = ">= 4.42.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
2 changes: 0 additions & 2 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ resource "random_id" "name" {
resource "google_container_node_pool" "pools" {
provider = google-beta
for_each = local.node_pools

name = { for k, v in random_id.name : k => v.hex }[each.key]
project = var.project_id
location = local.location
Expand Down Expand Up @@ -732,7 +731,6 @@ resource "google_container_node_pool" "pools" {
resource "google_container_node_pool" "windows_pools" {
provider = google-beta
for_each = local.windows_node_pools

name = { for k, v in random_id.name : k => v.hex }[each.key]
project = var.project_id
location = local.location
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.36.0, < 5.0"
version = ">= 4.42.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
2 changes: 0 additions & 2 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ resource "google_container_cluster" "primary" {
resource "google_container_node_pool" "pools" {
provider = google-beta
for_each = local.node_pools

name = each.key
project = var.project_id
location = local.location
Expand Down Expand Up @@ -637,7 +636,6 @@ resource "google_container_node_pool" "pools" {
resource "google_container_node_pool" "windows_pools" {
provider = google-beta
for_each = local.windows_node_pools

name = each.key
project = var.project_id
location = local.location
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.36.0, < 5.0"
version = ">= 4.42.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
2 changes: 0 additions & 2 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ resource "random_id" "name" {
resource "google_container_node_pool" "pools" {
provider = google-beta
for_each = local.node_pools

name = { for k, v in random_id.name : k => v.hex }[each.key]
project = var.project_id
location = local.location
Expand Down Expand Up @@ -713,7 +712,6 @@ resource "google_container_node_pool" "pools" {
resource "google_container_node_pool" "windows_pools" {
provider = google-beta
for_each = local.windows_node_pools

name = { for k, v in random_id.name : k => v.hex }[each.key]
project = var.project_id
location = local.location
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.36.0, < 5.0"
version = ">= 4.42.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
2 changes: 0 additions & 2 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ resource "google_container_cluster" "primary" {
resource "google_container_node_pool" "pools" {
provider = google-beta
for_each = local.node_pools

name = each.key
project = var.project_id
location = local.location
Expand Down Expand Up @@ -618,7 +617,6 @@ resource "google_container_node_pool" "pools" {
resource "google_container_node_pool" "windows_pools" {
provider = google-beta
for_each = local.windows_node_pools

name = each.key
project = var.project_id
location = local.location
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.36.0, < 5.0"
version = ">= 4.42.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
1 change: 1 addition & 0 deletions modules/private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Then perform the following commands on the root folder:
| 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 |
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
| 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 |
| 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 |
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | `bool` | `false` | no |
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | `bool` | `false` | no |
Expand Down
8 changes: 6 additions & 2 deletions modules/private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ resource "google_container_cluster" "primary" {
channel = release_channel.value.channel
}
}
dynamic "cost_management_config" {
for_each = var.enable_cost_allocation ? [1] : []
content {
enabled = var.enable_cost_allocation
}
}

subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"

Expand Down Expand Up @@ -416,7 +422,6 @@ resource "random_id" "name" {
resource "google_container_node_pool" "pools" {
provider = google
for_each = local.node_pools

name = { for k, v in random_id.name : k => v.hex }[each.key]
project = var.project_id
location = local.location
Expand Down Expand Up @@ -572,7 +577,6 @@ resource "google_container_node_pool" "pools" {
resource "google_container_node_pool" "windows_pools" {
provider = google
for_each = local.windows_node_pools

name = { for k, v in random_id.name : k => v.hex }[each.key]
project = var.project_id
location = local.location
Expand Down
5 changes: 5 additions & 0 deletions modules/private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ variable "node_pools_metadata" {
}
}

variable "enable_cost_allocation" {
type = bool
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"
default = false
}
variable "resource_usage_export_dataset_id" {
type = string
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."
Expand Down
1 change: 1 addition & 0 deletions modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Then perform the following commands on the root folder:
| 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 |
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
| 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 |
| 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 |
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | `bool` | `false` | no |
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | `bool` | `false` | no |
Expand Down
8 changes: 6 additions & 2 deletions modules/private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ resource "google_container_cluster" "primary" {
channel = release_channel.value.channel
}
}
dynamic "cost_management_config" {
for_each = var.enable_cost_allocation ? [1] : []
content {
enabled = var.enable_cost_allocation
}
}

subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"

Expand Down Expand Up @@ -322,7 +328,6 @@ resource "google_container_cluster" "primary" {
resource "google_container_node_pool" "pools" {
provider = google
for_each = local.node_pools

name = each.key
project = var.project_id
location = local.location
Expand Down Expand Up @@ -477,7 +482,6 @@ resource "google_container_node_pool" "pools" {
resource "google_container_node_pool" "windows_pools" {
provider = google
for_each = local.windows_node_pools

name = each.key
project = var.project_id
location = local.location
Expand Down
5 changes: 5 additions & 0 deletions modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ variable "node_pools_metadata" {
}
}

variable "enable_cost_allocation" {
type = bool
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"
default = false
}
variable "resource_usage_export_dataset_id" {
type = string
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ variable "node_pools_metadata" {
}
}

variable "enable_cost_allocation" {
type = bool
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"
default = false
}
variable "resource_usage_export_dataset_id" {
type = string
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."
Expand Down