Skip to content

Commit

Permalink
Ensure that GA modules don't depend on beta functionality
Browse files Browse the repository at this point in the history
Beta functionality removed fully from public and private cluster modules and related exampled.
As long node_pool example used taints that in beta, it switched to public-cluster-beta module from root one.

Fixes #181
  • Loading branch information
kopachevsky committed Aug 16, 2019
1 parent 98b6e7f commit 6492b45
Show file tree
Hide file tree
Showing 30 changed files with 27 additions and 123 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Extending the adopted spec, each change should have a link to its corresponding pull request appended.

## [Unreleased]

### Changed

* All Beta functionality removed from non-beta clusters, some properties like node_pool taints available only in beta cluster now [#228]

### Added

* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
Expand Down Expand Up @@ -168,6 +173,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

[#228]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/228
[#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
[#210]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/210
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) | `<map>` | no |
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) | `<map>` | no |
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map(list(string)) | `<map>` | no |
| node\_pools\_taints | Map of lists containing node taints by node-pool name | object | `<map>` | no |
| 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 |
Expand Down
2 changes: 1 addition & 1 deletion autogen/auth.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Retrieve authentication token
*****************************************/
data "google_client_config" "default" {
{% if private_cluster or beta_cluster %}
{% if beta_cluster %}
provider = google-beta
{% else %}
provider = google
Expand Down
8 changes: 7 additions & 1 deletion autogen/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Create Container Cluster
*****************************************/
resource "google_container_cluster" "primary" {
{% if private_cluster or beta_cluster %}
{% if beta_cluster %}
provider = google-beta
{% else %}
provider = google
Expand Down Expand Up @@ -192,7 +192,11 @@ resource "google_container_cluster" "primary" {
Create Container Cluster node pools
*****************************************/
resource "google_container_node_pool" "pools" {
{% if private_cluster or beta_cluster %}
provider = google-beta
{% else %}
provider = google
{% endif %}
count = length(var.node_pools)
name = var.node_pools[count.index]["name"]
project = var.project_id
Expand Down Expand Up @@ -248,6 +252,7 @@ resource "google_container_node_pool" "pools" {
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
},
)
{% if beta_cluster %}
dynamic "taint" {
for_each = concat(
var.node_pools_taints["all"],
Expand All @@ -259,6 +264,7 @@ resource "google_container_node_pool" "pools" {
value = taint.value.value
}
}
{% endif %}
tags = concat(
["gke-${var.name}"],
["gke-${var.name}-${var.node_pools[count.index]["name"]}"],
Expand Down
2 changes: 1 addition & 1 deletion autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Get available zones in region
*****************************************/
data "google_compute_zones" "available" {
{% if private_cluster or beta_cluster %}
{% if beta_cluster %}
provider = google-beta
{% else %}
provider = google
Expand Down
4 changes: 2 additions & 2 deletions autogen/networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{{ autogeneration_note }}

data "google_compute_network" "gke_network" {
{% if private_cluster or beta_cluster %}
{% if beta_cluster %}
provider = google-beta
{% else %}
provider = google
Expand All @@ -28,7 +28,7 @@ data "google_compute_network" "gke_network" {
}

data "google_compute_subnetwork" "gke_subnetwork" {
{% if private_cluster or beta_cluster %}
{% if beta_cluster %}
provider = google-beta
{% else %}
provider = google
Expand Down
2 changes: 2 additions & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ variable "node_pools_metadata" {
}
}

{% if beta_cluster %}
variable "node_pools_taints" {
type = map(list(object({key=string,value=string,effect=string})))
description = "Map of lists containing node taints by node-pool name"
Expand All @@ -187,6 +188,7 @@ variable "node_pools_taints" {
default-node-pool = []
}
}
{% endif %}

variable "node_pools_tags" {
type = map(list(string))
Expand Down
13 changes: 1 addition & 12 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ resource "google_container_cluster" "primary" {
Create Container Cluster node pools
*****************************************/
resource "google_container_node_pool" "pools" {
provider = google-beta
provider = google
count = length(var.node_pools)
name = var.node_pools[count.index]["name"]
project = var.project_id
Expand Down Expand Up @@ -178,17 +178,6 @@ resource "google_container_node_pool" "pools" {
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
},
)
dynamic "taint" {
for_each = concat(
var.node_pools_taints["all"],
var.node_pools_taints[var.node_pools[count.index]["name"]],
)
content {
effect = taint.value.effect
key = taint.value.key
value = taint.value.value
}
}
tags = concat(
["gke-${var.name}"],
["gke-${var.name}-${var.node_pools[count.index]["name"]}"],
Expand Down
5 changes: 0 additions & 5 deletions examples/deploy_service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ provider "google" {
region = var.region
}

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

provider "kubernetes" {
load_config_file = false
host = "https://${module.gke.endpoint}"
Expand Down
5 changes: 0 additions & 5 deletions examples/disable_client_cert/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ provider "google" {
region = var.region
}

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

module "gke" {
source = "../../"

Expand Down
7 changes: 1 addition & 6 deletions examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ provider "google" {
region = var.region
}

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

module "gke" {
source = "../../"
source = "../../modules/beta-public-cluster/"
project_id = var.project_id
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
regional = false
Expand Down
5 changes: 0 additions & 5 deletions examples/shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ provider "google" {
region = var.region
}

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

module "gke" {
source = "../../"
project_id = var.project_id
Expand Down
5 changes: 0 additions & 5 deletions examples/simple_regional/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ provider "google" {
region = var.region
}

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

module "gke" {
source = "../../"
project_id = var.project_id
Expand Down
6 changes: 0 additions & 6 deletions examples/simple_regional_beta/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ provider "google" {
region = var.region
}

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

module "gke" {
source = "../../modules/beta-public-cluster/"
project_id = var.project_id
Expand Down
5 changes: 0 additions & 5 deletions examples/simple_regional_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ locals {
cluster_type = "simple-regional-private"
}

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

data "google_compute_subnetwork" "subnetwork" {
name = var.subnetwork
project = var.project_id
Expand Down
5 changes: 0 additions & 5 deletions examples/simple_zonal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ provider "google" {
region = var.region
}

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

module "gke" {
source = "../../"
project_id = var.project_id
Expand Down
5 changes: 0 additions & 5 deletions examples/simple_zonal_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ locals {
cluster_type = "simple-regional-private"
}

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

data "google_compute_subnetwork" "subnetwork" {
name = var.subnetwork
project = var.project_id
Expand Down
5 changes: 0 additions & 5 deletions examples/stub_domains/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ provider "google" {
region = var.region
}

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

module "gke" {
source = "../../"
project_id = var.project_id
Expand Down
2 changes: 1 addition & 1 deletion examples/stub_domains_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

provider "google-beta" {
provider "google" {
version = "~> 2.9.0"
region = var.region
}
Expand Down
5 changes: 0 additions & 5 deletions examples/stub_domains_upstream_nameservers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ provider "google" {
region = var.region
}

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

module "gke" {
source = "../../"
project_id = var.project_id
Expand Down
5 changes: 0 additions & 5 deletions examples/upstream_nameservers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ provider "google" {
region = var.region
}

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

module "gke" {
source = "../../"
project_id = var.project_id
Expand Down
1 change: 0 additions & 1 deletion modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) | `<map>` | no |
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) | `<map>` | no |
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map(list(string)) | `<map>` | no |
| node\_pools\_taints | Map of lists containing node taints by node-pool name | object | `<map>` | no |
| 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 |
Expand Down
2 changes: 1 addition & 1 deletion modules/private-cluster/auth.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Retrieve authentication token
*****************************************/
data "google_client_config" "default" {
provider = google-beta
provider = google
}

/******************************************
Expand Down
13 changes: 1 addition & 12 deletions modules/private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Create Container Cluster
*****************************************/
resource "google_container_cluster" "primary" {
provider = google-beta
provider = google

name = var.name
description = var.description
Expand Down Expand Up @@ -183,17 +183,6 @@ resource "google_container_node_pool" "pools" {
"disable-legacy-endpoints" = var.disable_legacy_metadata_endpoints
},
)
dynamic "taint" {
for_each = concat(
var.node_pools_taints["all"],
var.node_pools_taints[var.node_pools[count.index]["name"]],
)
content {
effect = taint.value.effect
key = taint.value.key
value = taint.value.value
}
}
tags = concat(
["gke-${var.name}"],
["gke-${var.name}-${var.node_pools[count.index]["name"]}"],
Expand Down
2 changes: 1 addition & 1 deletion modules/private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Get available zones in region
*****************************************/
data "google_compute_zones" "available" {
provider = google-beta
provider = google

project = var.project_id
region = var.region
Expand Down
4 changes: 2 additions & 2 deletions modules/private-cluster/networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
// This file was automatically generated from a template in ./autogen

data "google_compute_network" "gke_network" {
provider = google-beta
provider = google

name = var.network
project = local.network_project_id
}

data "google_compute_subnetwork" "gke_subnetwork" {
provider = google-beta
provider = google

name = var.subnetwork
region = var.region
Expand Down
9 changes: 0 additions & 9 deletions modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,6 @@ variable "node_pools_metadata" {
}
}

variable "node_pools_taints" {
type = map(list(object({ key = string, value = string, effect = string })))
description = "Map of lists containing node taints by node-pool name"

default = {
all = []
default-node-pool = []
}
}

variable "node_pools_tags" {
type = map(list(string))
Expand Down
4 changes: 0 additions & 4 deletions test/fixtures/simple_regional_private/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ resource "random_string" "suffix" {
upper = false
}

provider "google-beta" {
project = var.project_id
}

resource "google_compute_network" "main" {
project = var.project_id
name = "cft-gke-test-${random_string.suffix.result}"
Expand Down
Loading

0 comments on commit 6492b45

Please sign in to comment.