Skip to content

Commit

Permalink
added check for optional fields
Browse files Browse the repository at this point in the history
added optional field lookup and resource usage export config

changed to dataset_id

revert examples

fixed bug where resource_usage_export_dataset_id was being set even if empty string

check for null
  • Loading branch information
richardmcsong authored and paulpalamarchuk committed Aug 22, 2019
1 parent 0fca886 commit a95ce1b
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 12 deletions.
10 changes: 9 additions & 1 deletion autogen/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ resource "google_container_cluster" "primary" {
enabled = pod_security_policy_config.value.enabled
}
}

dynamic "resource_usage_export_config" {
for_each = var.resource_usage_export_dataset_id != "" ? [var.resource_usage_export_dataset_id] : []
content {
enable_network_egress_metering = true
bigquery_destination {
dataset_id = resource_usage_export_dataset_id.value
}
}
}
{% endif %}
dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
Expand Down
6 changes: 3 additions & 3 deletions autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ locals {

{% if beta_cluster %}
# BETA features
cluster_output_istio_enabled = google_container_cluster.primary.addons_config.0.istio_config.0.disabled
cluster_output_pod_security_policy_enabled = google_container_cluster.primary.pod_security_policy_config.0.enabled
cluster_output_istio_enabled = google_container_cluster.primary.addons_config.0.istio_config != null ? google_container_cluster.primary.addons_config.0.istio_config.0.disabled : "true"
cluster_output_pod_security_policy_enabled = google_container_cluster.primary.pod_security_policy_config != null ? google_container_cluster.primary.pod_security_policy_config.0.enabled : "false"
cluster_output_intranode_visbility_enabled = google_container_cluster.primary.enable_intranode_visibility
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling.0.enabled
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling != null ? google_container_cluster.primary.vertical_pod_autoscaling.0.enabled : "false"

# /BETA features
{% endif %}
Expand Down
5 changes: 5 additions & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ variable "pod_security_policy_config" {
}]
}

variable "resource_usage_export_dataset_id" {
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."
default = ""
}

variable "node_metadata" {
description = "Specifies how node metadata is exposed to the workload running on the node"
default = "UNSPECIFIED"
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
| 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 |
| 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 |
| 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 |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
Expand Down
10 changes: 9 additions & 1 deletion modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ resource "google_container_cluster" "primary" {
enabled = pod_security_policy_config.value.enabled
}
}

dynamic "resource_usage_export_config" {
for_each = var.resource_usage_export_dataset_id != "" ? [var.resource_usage_export_dataset_id] : []
content {
enable_network_egress_metering = true
bigquery_destination {
dataset_id = resource_usage_export_dataset_id.value
}
}
}
dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
content {
Expand Down
6 changes: 3 additions & 3 deletions modules/beta-private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ locals {
cluster_output_kubernetes_dashboard_enabled = google_container_cluster.primary.addons_config.0.kubernetes_dashboard.0.disabled

# BETA features
cluster_output_istio_enabled = google_container_cluster.primary.addons_config.0.istio_config.0.disabled
cluster_output_pod_security_policy_enabled = google_container_cluster.primary.pod_security_policy_config.0.enabled
cluster_output_istio_enabled = google_container_cluster.primary.addons_config.0.istio_config != null ? google_container_cluster.primary.addons_config.0.istio_config.0.disabled : "true"
cluster_output_pod_security_policy_enabled = google_container_cluster.primary.pod_security_policy_config != null ? google_container_cluster.primary.pod_security_policy_config.0.enabled : "false"
cluster_output_intranode_visbility_enabled = google_container_cluster.primary.enable_intranode_visibility
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling.0.enabled
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling != null ? google_container_cluster.primary.vertical_pod_autoscaling.0.enabled : "false"

# /BETA features

Expand Down
5 changes: 5 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ variable "pod_security_policy_config" {
}]
}

variable "resource_usage_export_dataset_id" {
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."
default = ""
}

variable "node_metadata" {
description = "Specifies how node metadata is exposed to the workload running on the node"
default = "UNSPECIFIED"
Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
| 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 |
| 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 |
| 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 |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
Expand Down
10 changes: 9 additions & 1 deletion modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ resource "google_container_cluster" "primary" {
enabled = pod_security_policy_config.value.enabled
}
}

dynamic "resource_usage_export_config" {
for_each = var.resource_usage_export_dataset_id != "" ? [var.resource_usage_export_dataset_id] : []
content {
enable_network_egress_metering = true
bigquery_destination {
dataset_id = resource_usage_export_dataset_id.value
}
}
}
dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
content {
Expand Down
6 changes: 3 additions & 3 deletions modules/beta-public-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ locals {
cluster_output_kubernetes_dashboard_enabled = google_container_cluster.primary.addons_config.0.kubernetes_dashboard.0.disabled

# BETA features
cluster_output_istio_enabled = google_container_cluster.primary.addons_config.0.istio_config.0.disabled
cluster_output_pod_security_policy_enabled = google_container_cluster.primary.pod_security_policy_config.0.enabled
cluster_output_istio_enabled = google_container_cluster.primary.addons_config.0.istio_config != null ? google_container_cluster.primary.addons_config.0.istio_config.0.disabled : "true"
cluster_output_pod_security_policy_enabled = google_container_cluster.primary.pod_security_policy_config != null ? google_container_cluster.primary.pod_security_policy_config.0.enabled : "false"
cluster_output_intranode_visbility_enabled = google_container_cluster.primary.enable_intranode_visibility
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling.0.enabled
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling != null ? google_container_cluster.primary.vertical_pod_autoscaling.0.enabled : "false"

# /BETA features

Expand Down
5 changes: 5 additions & 0 deletions modules/beta-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ variable "pod_security_policy_config" {
}]
}

variable "resource_usage_export_dataset_id" {
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."
default = ""
}

variable "node_metadata" {
description = "Specifies how node metadata is exposed to the workload running on the node"
default = "UNSPECIFIED"
Expand Down

0 comments on commit a95ce1b

Please sign in to comment.