Skip to content

Commit

Permalink
Added support for resource usage export config
Browse files Browse the repository at this point in the history
 * Based on PR #230
 * Add support for beta feature resource_usage_export_config (Fixes #232)
 * Fixed `google-beta` provider version
  • Loading branch information
paulpalamarchuk committed Aug 21, 2019
1 parent 6ae2caa commit 8cbc1d0
Show file tree
Hide file tree
Showing 30 changed files with 61 additions and 58 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Extending the adopted spec, each change should have a link to its corresponding
## [Unreleased]
### Added

* Added support for resource usage export config [#238]
* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
* Support for Workload Identity beta feature [#234]

Expand Down Expand Up @@ -168,6 +169,7 @@ Extending the adopted spec, each change should have a link to its corresponding
[v0.3.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.2.0...v0.3.0
[v0.2.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.1.0...v0.2.0

[#238]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/238
[#234]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/234
[#216]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/216
[#214]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/214
Expand Down
3 changes: 2 additions & 1 deletion autogen/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ 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
dataset_id = resource_usage_export_config.value
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ locals {

{% if beta_cluster %}
# BETA features
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_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_intranode_visbility_enabled = google_container_cluster.primary.enable_intranode_visibility
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling != null ? google_container_cluster.primary.vertical_pod_autoscaling.0.enabled : "false"
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling.0.enabled

# /BETA features
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ variable "pod_security_policy_config" {
}

variable "resource_usage_export_dataset_id" {
type = string
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 = ""
}
Expand Down
4 changes: 4 additions & 0 deletions autogen/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@

terraform {
required_version = ">= 0.12"
required_providers {
google-beta = "~> 2.12.0"
google = "~> 2.12.0"
}
}
4 changes: 1 addition & 3 deletions examples/deploy_service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "kubernetes" {
Expand Down
6 changes: 2 additions & 4 deletions examples/disable_client_cert/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

module "gke" {
Expand Down
6 changes: 2 additions & 4 deletions examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

module "gke" {
Expand Down
6 changes: 2 additions & 4 deletions examples/shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

module "gke" {
Expand Down
6 changes: 2 additions & 4 deletions examples/simple_regional/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

module "gke" {
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_regional_beta/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
credentials = file(var.credentials_path)
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
credentials = file(var.credentials_path)
region = var.region
}
Expand Down
3 changes: 1 addition & 2 deletions examples/simple_regional_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

data "google_compute_subnetwork" "subnetwork" {
Expand Down
1 change: 0 additions & 1 deletion examples/simple_regional_private_beta/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ locals {
}

provider "google-beta" {
version = "~> 2.12.0"
credentials = file(var.credentials_path)
region = var.region
}
Expand Down
6 changes: 2 additions & 4 deletions examples/simple_zonal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

module "gke" {
Expand Down
3 changes: 1 addition & 2 deletions examples/simple_zonal_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

data "google_compute_subnetwork" "subnetwork" {
Expand Down
6 changes: 2 additions & 4 deletions examples/stub_domains/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

module "gke" {
Expand Down
3 changes: 1 addition & 2 deletions examples/stub_domains_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "random" {
Expand Down
6 changes: 2 additions & 4 deletions examples/stub_domains_upstream_nameservers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

module "gke" {
Expand Down
6 changes: 2 additions & 4 deletions examples/upstream_nameservers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ locals {
}

provider "google" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

module "gke" {
Expand Down
3 changes: 1 addition & 2 deletions examples/workload_metadata_config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 2.12.0"
region = var.region
region = var.region
}

data "google_compute_subnetwork" "subnetwork" {
Expand Down
3 changes: 2 additions & 1 deletion modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ 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
dataset_id = resource_usage_export_config.value
}
}
}
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 @@ -87,10 +87,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 != 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_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_intranode_visbility_enabled = google_container_cluster.primary.enable_intranode_visibility
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling != null ? google_container_cluster.primary.vertical_pod_autoscaling.0.enabled : "false"
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling.0.enabled

# /BETA features

Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ variable "pod_security_policy_config" {
}

variable "resource_usage_export_dataset_id" {
type = string
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 = ""
}
Expand Down
4 changes: 4 additions & 0 deletions modules/beta-private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@

terraform {
required_version = ">= 0.12"
required_providers {
google-beta = "~> 2.12.0"
google = "~> 2.12.0"
}
}
3 changes: 2 additions & 1 deletion modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ 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
dataset_id = resource_usage_export_config.value
}
}
}
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 @@ -87,10 +87,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 != 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_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_intranode_visbility_enabled = google_container_cluster.primary.enable_intranode_visibility
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling != null ? google_container_cluster.primary.vertical_pod_autoscaling.0.enabled : "false"
cluster_output_vertical_pod_autoscaling_enabled = google_container_cluster.primary.vertical_pod_autoscaling.0.enabled

# /BETA features

Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ variable "pod_security_policy_config" {
}

variable "resource_usage_export_dataset_id" {
type = string
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 = ""
}
Expand Down
4 changes: 4 additions & 0 deletions modules/beta-public-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@

terraform {
required_version = ">= 0.12"
required_providers {
google-beta = "~> 2.12.0"
google = "~> 2.12.0"
}
}
4 changes: 4 additions & 0 deletions modules/private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@

terraform {
required_version = ">= 0.12"
required_providers {
google-beta = "~> 2.12.0"
google = "~> 2.12.0"
}
}
4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@

terraform {
required_version = ">= 0.12"
required_providers {
google-beta = "~> 2.12.0"
google = "~> 2.12.0"
}
}

0 comments on commit 8cbc1d0

Please sign in to comment.