Skip to content

Commit 8507e09

Browse files
feat: Allow enabling cost management for safer_cluster module (#1475)
1 parent aaeb66d commit 8507e09

File tree

8 files changed

+29
-0
lines changed

8 files changed

+29
-0
lines changed

autogen/safer-cluster/main.tf.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ module "gke" {
161161
// We suggest to define policies about which images can run on a cluster.
162162
enable_binary_authorization = true
163163

164+
// Enable cost allocation support
165+
enable_cost_allocation = var.enable_cost_allocation
166+
164167
// Use of PodSecurityPolicy admission controller
165168
// https://cloud.google.com/kubernetes-engine/docs/how-to/pod-security-policies
166169
enable_pod_security_policy = var.enable_pod_security_policy

autogen/safer-cluster/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ variable "enable_resource_consumption_export" {
356356
default = true
357357
}
358358

359+
variable "enable_cost_allocation" {
360+
type = bool
361+
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"
362+
default = false
363+
}
364+
359365
variable "sandbox_enabled" {
360366
type = bool
361367
description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it)."

modules/safer-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ For simplicity, we suggest using `roles/container.admin` and
217217
| description | The description of the cluster | `string` | `""` | no |
218218
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |
219219
| dns\_cache | (Beta) The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
220+
| 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 |
220221
| 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 |
221222
| 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 |
222223
| enable\_pod\_security\_policy | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. | `bool` | `false` | no |

modules/safer-cluster-update-variant/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ module "gke" {
157157
// We suggest to define policies about which images can run on a cluster.
158158
enable_binary_authorization = true
159159

160+
// Enable cost allocation support
161+
enable_cost_allocation = var.enable_cost_allocation
162+
160163
// Use of PodSecurityPolicy admission controller
161164
// https://cloud.google.com/kubernetes-engine/docs/how-to/pod-security-policies
162165
enable_pod_security_policy = var.enable_pod_security_policy

modules/safer-cluster-update-variant/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ variable "enable_resource_consumption_export" {
356356
default = true
357357
}
358358

359+
variable "enable_cost_allocation" {
360+
type = bool
361+
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"
362+
default = false
363+
}
364+
359365
variable "sandbox_enabled" {
360366
type = bool
361367
description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it)."

modules/safer-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ For simplicity, we suggest using `roles/container.admin` and
217217
| description | The description of the cluster | `string` | `""` | no |
218218
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |
219219
| dns\_cache | (Beta) The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
220+
| 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 |
220221
| 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 |
221222
| 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 |
222223
| enable\_pod\_security\_policy | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. | `bool` | `false` | no |

modules/safer-cluster/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ module "gke" {
157157
// We suggest to define policies about which images can run on a cluster.
158158
enable_binary_authorization = true
159159

160+
// Enable cost allocation support
161+
enable_cost_allocation = var.enable_cost_allocation
162+
160163
// Use of PodSecurityPolicy admission controller
161164
// https://cloud.google.com/kubernetes-engine/docs/how-to/pod-security-policies
162165
enable_pod_security_policy = var.enable_pod_security_policy

modules/safer-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ variable "enable_resource_consumption_export" {
356356
default = true
357357
}
358358

359+
variable "enable_cost_allocation" {
360+
type = bool
361+
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"
362+
default = false
363+
}
364+
359365
variable "sandbox_enabled" {
360366
type = bool
361367
description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it)."

0 commit comments

Comments
 (0)