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

Changed region variable #247

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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

* Made `region` variable optional for zonal clusters [#247]
* Added `grant_registry_access` variable to grant Container Registry access to created SA [#236]
* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
* Support for Workload Identity beta feature [#234]
Expand Down Expand Up @@ -170,6 +171,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

[#247]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/247
[#236]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/236
[#217]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/217
[#234]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/234
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,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 |
| 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/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 |
| 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/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 @@ -175,7 +175,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-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/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/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