Skip to content

Commit

Permalink
Merge pull request terraform-google-modules#247 from paulpalamarchuk/…
Browse files Browse the repository at this point in the history
…region_var_became_optional

Changed `region` variable
  • Loading branch information
morgante committed Oct 15, 2019
2 parents ace1045 + f79dab9 commit 62ba116
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Extending the adopted spec, each change should have a link to its corresponding

## [Unreleased]

### Changed

* Made `region` variable optional for zonal clusters [#247]

### Added

* Added [private](https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/tree/master/modules/private-cluster-update-variant) and [beta private](https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/tree/master/modules/beta-private-cluster-update-variant) variants which allow node pools to be created before being destroyed. [#256]
Expand Down Expand Up @@ -200,6 +204,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
[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

[#247]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/247
[#256]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/256
[#248]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/248
[#228]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/228
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| node\_version | The Kubernetes version of the node pools. Defaults kubernetes_version (master) variable and can be overridden for individual node pools by setting the `version` key on them. Must be empyty or set the same as master at cluster creation. | string | `""` | no |
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) | `<list>` | no |
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
| region | The region to host the cluster in (required) | string | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string | `"null"` | no |
| 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 |
| 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 |
Expand Down
3 changes: 2 additions & 1 deletion autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ data "google_compute_zones" "available" {
{% endif %}

project = var.project_id
region = var.region
region = local.region
}

resource "random_shuffle" "available_zones" {
Expand All @@ -38,6 +38,7 @@ resource "random_shuffle" "available_zones" {
locals {
// location
location = var.regional ? var.region : var.zones[0]
region = var.region == null ? join("-", slice(split("-", var.zones[0]), 0, 2)) : var.region
// for regional cluster - use var.zones if provided, use available otherwise, for zonal cluster use var.zones with first element extracted
node_locations = var.regional ? coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result)) : slice(var.zones, 1, length(var.zones))
// kuberentes version
Expand Down
2 changes: 1 addition & 1 deletion autogen/networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ data "google_compute_subnetwork" "gke_subnetwork" {
{% endif %}

name = var.subnetwork
region = var.region
region = local.region
project = local.network_project_id
}
3 changes: 2 additions & 1 deletion autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ variable "regional" {

variable "region" {
type = string
description = "The region to host the cluster in (required)"
description = "The region to host the cluster in (optional if zonal cluster / required if regional)"
default = null
}

variable "zones" {
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ data "google_compute_zones" "available" {
provider = google

project = var.project_id
region = var.region
region = local.region
}

resource "random_shuffle" "available_zones" {
Expand All @@ -34,6 +34,7 @@ resource "random_shuffle" "available_zones" {
locals {
// location
location = var.regional ? var.region : var.zones[0]
region = var.region == null ? join("-", slice(split("-", var.zones[0]), 0, 2)) : var.region
// for regional cluster - use var.zones if provided, use available otherwise, for zonal cluster use var.zones with first element extracted
node_locations = var.regional ? coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result)) : slice(var.zones, 1, length(var.zones))
// kuberentes version
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) | `<list>` | no |
| pod\_security\_policy\_config | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. | list | `<list>` | no |
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
| region | The region to host the cluster in (required) | string | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string | `"null"` | no |
| 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 |
Expand Down
3 changes: 2 additions & 1 deletion modules/beta-private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ data "google_compute_zones" "available" {
provider = google-beta

project = var.project_id
region = var.region
region = local.region
}

resource "random_shuffle" "available_zones" {
Expand All @@ -34,6 +34,7 @@ resource "random_shuffle" "available_zones" {
locals {
// location
location = var.regional ? var.region : var.zones[0]
region = var.region == null ? join("-", slice(split("-", var.zones[0]), 0, 2)) : var.region
// for regional cluster - use var.zones if provided, use available otherwise, for zonal cluster use var.zones with first element extracted
node_locations = var.regional ? coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result)) : slice(var.zones, 1, length(var.zones))
// kuberentes version
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ data "google_compute_subnetwork" "gke_subnetwork" {
provider = google-beta

name = var.subnetwork
region = var.region
region = local.region
project = local.network_project_id
}
3 changes: 2 additions & 1 deletion modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ variable "regional" {

variable "region" {
type = string
description = "The region to host the cluster in (required)"
description = "The region to host the cluster in (optional if zonal cluster / required if regional)"
default = null
}

variable "zones" {
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) | `<list>` | no |
| pod\_security\_policy\_config | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. | list | `<list>` | no |
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
| region | The region to host the cluster in (required) | string | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string | `"null"` | no |
| 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 |
Expand Down
3 changes: 2 additions & 1 deletion modules/beta-public-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ data "google_compute_zones" "available" {
provider = google-beta

project = var.project_id
region = var.region
region = local.region
}

resource "random_shuffle" "available_zones" {
Expand All @@ -34,6 +34,7 @@ resource "random_shuffle" "available_zones" {
locals {
// location
location = var.regional ? var.region : var.zones[0]
region = var.region == null ? join("-", slice(split("-", var.zones[0]), 0, 2)) : var.region
// for regional cluster - use var.zones if provided, use available otherwise, for zonal cluster use var.zones with first element extracted
node_locations = var.regional ? coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result)) : slice(var.zones, 1, length(var.zones))
// kuberentes version
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster/networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ data "google_compute_subnetwork" "gke_subnetwork" {
provider = google-beta

name = var.subnetwork
region = var.region
region = local.region
project = local.network_project_id
}
3 changes: 2 additions & 1 deletion modules/beta-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ variable "regional" {

variable "region" {
type = string
description = "The region to host the cluster in (required)"
description = "The region to host the cluster in (optional if zonal cluster / required if regional)"
default = null
}

variable "zones" {
Expand Down
2 changes: 1 addition & 1 deletion modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| node\_version | The Kubernetes version of the node pools. Defaults kubernetes_version (master) variable and can be overridden for individual node pools by setting the `version` key on them. Must be empyty or set the same as master at cluster creation. | string | `""` | no |
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) | `<list>` | no |
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
| region | The region to host the cluster in (required) | string | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string | `"null"` | no |
| 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 |
| 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 |
Expand Down
3 changes: 2 additions & 1 deletion modules/private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ data "google_compute_zones" "available" {
provider = google

project = var.project_id
region = var.region
region = local.region
}

resource "random_shuffle" "available_zones" {
Expand All @@ -34,6 +34,7 @@ resource "random_shuffle" "available_zones" {
locals {
// location
location = var.regional ? var.region : var.zones[0]
region = var.region == null ? join("-", slice(split("-", var.zones[0]), 0, 2)) : var.region
// for regional cluster - use var.zones if provided, use available otherwise, for zonal cluster use var.zones with first element extracted
node_locations = var.regional ? coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result)) : slice(var.zones, 1, length(var.zones))
// kuberentes version
Expand Down
2 changes: 1 addition & 1 deletion modules/private-cluster/networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ data "google_compute_subnetwork" "gke_subnetwork" {
provider = google

name = var.subnetwork
region = var.region
region = local.region
project = local.network_project_id
}
3 changes: 2 additions & 1 deletion modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ variable "regional" {

variable "region" {
type = string
description = "The region to host the cluster in (required)"
description = "The region to host the cluster in (optional if zonal cluster / required if regional)"
default = null
}

variable "zones" {
Expand Down
2 changes: 1 addition & 1 deletion networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ data "google_compute_subnetwork" "gke_subnetwork" {
provider = google

name = var.subnetwork
region = var.region
region = local.region
project = local.network_project_id
}
3 changes: 2 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ variable "regional" {

variable "region" {
type = string
description = "The region to host the cluster in (required)"
description = "The region to host the cluster in (optional if zonal cluster / required if regional)"
default = null
}

variable "zones" {
Expand Down

0 comments on commit 62ba116

Please sign in to comment.