Skip to content

Commit

Permalink
provided a workaround variable to prevent breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonjbjelland committed Apr 25, 2019
1 parent 879c29b commit 190bff9
Show file tree
Hide file tree
Showing 28 changed files with 145 additions and 83 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ crash.log
**/.kitchen
**/.kitchen.local.yml
**/Gemfile.lock
terraform.tfvars

test/fixtures/shared/terraform.tfvars

Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@ Extending the adopted spec, each change should have a link to its corresponding

## [Unreleased]

### Added

* variable `initial_node_count` added to provide a mechanism to control the
default node pool's size. This replaces the cluster's inline `node_pool` block
as that block no longer works with recent provider versions.
**Note for admins of existing clusters:** depending on a cluster's state,
cluster admins may need to adjust this variable when upgrading this module and
provider to ensure clusters aren't deleted and recreated. Review the
`terraform plan` carefully!

### Changed

* `google_container_engine_versions` data lookups and cluster resources now use
the `location` attribute instead of `zone` or `region` (deprecated). This also
allowed 2 data lookups to collapse into one.
* `initial_node_count` replaces the cluster's `node_pool` inline block as that
block no longer works with recent provider versions.
* updated `combine_docfiles.py` to match that of
[terraform-google-module-template](https://github.com/terraform-google-modules/terraform-google-module-template)
* `make` tasks and `generation` processes improved around the edges

## [v2.0.0] - 2019-04-12

Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ test_integration:
generate_docs:
@source test/make.sh && generate_docs

.PHONY: generate
generate:
.PHONY: generate_code
generate_code:
@source test/make.sh && generate

.PHONY: generate
generate: generate_code generate_docs

# Versioning
.PHONY: version
version:
Expand Down
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ The resources/services/activations/deletions that this module will create/trigge
There are multiple examples included in the [examples](./examples/) folder but simple usage is as follows:

```hcl
provider "google" {
project = "<PROJECT ID>"
region = "us-central1"
version = "~> 2.5"
}
provider "google-beta" {
project = "<PROJECT ID>"
region = "us-central1"
version = "~> 2.5"
}
module "gke" {
source = "terraform-google-modules/kubernetes-engine/google"
project_id = "<PROJECT ID>"
Expand All @@ -26,6 +38,8 @@ module "gke" {
horizontal_pod_autoscaling = true
kubernetes_dashboard = true
network_policy = true
remove_default_node_pool = true
initial_node_count = 1
node_pools = [
{
Expand Down Expand Up @@ -53,19 +67,13 @@ module "gke" {
}
node_pools_labels = {
all = {}
default-node-pool = {
default-node-pool = "true"
}
all = {}
default-node-pool = {}
}
node_pools_metadata = {
all = {}
default-node-pool = {
node-pool-metadata-custom-value = "my-node-pool"
}
all = {}
default-node-pool = {}
}
node_pools_taints = {
Expand All @@ -81,11 +89,8 @@ module "gke" {
}
node_pools_tags = {
all = []
default-node-pool = [
"default-node-pool",
]
all = []
default-node-pool = []
}
}
```
Expand Down Expand Up @@ -120,6 +125,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | string | `"true"` | no |
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | string | `"true"` | no |
| http\_load\_balancing | Enable httpload balancer addon | string | `"true"` | no |
| initial\_node\_count | The initial size of the default cluster. Clusters having `remove_default_node_pool` set to `true` and any new clusters must specify this variable >= 1. | string | `"0"` | no |
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | string | `"false"` | no |
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string | `"60s"` | no |
| ip\_range\_pods | The _name_ of the secondary subnet ip range to use for pods | string | n/a | yes |
Expand Down Expand Up @@ -194,7 +200,7 @@ The [project factory](https://github.com/terraform-google-modules/terraform-goog
- [kubectl](https://github.com/kubernetes/kubernetes/releases) 1.9.x
#### Terraform and Plugins
- [Terraform](https://www.terraform.io/downloads.html) 0.11.x
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) v2.0.0
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) v2.5.0

### Configure a Service Account
In order to execute this module you must have a Service Account with the
Expand Down
4 changes: 2 additions & 2 deletions autogen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ The [project factory](https://github.com/terraform-google-modules/terraform-goog
#### Terraform and Plugins
- [Terraform](https://www.terraform.io/downloads.html) 0.11.x
{% if private_cluster %}
- [terraform-provider-google-beta](https://github.com/terraform-providers/terraform-provider-google-beta) v2.0.0
- [terraform-provider-google-beta](https://github.com/terraform-providers/terraform-provider-google-beta) v2.5.0
{% else %}
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) v2.0.0
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) v2.5.0
{% endif %}

### Configure a Service Account
Expand Down
2 changes: 1 addition & 1 deletion autogen/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ resource "google_container_cluster" "primary" {
{% endif %}

remove_default_node_pool = "${var.remove_default_node_pool}"
initial_node_count = 0
initial_node_count = "${var.initial_node_count}"
}

/******************************************
Expand Down
2 changes: 1 addition & 1 deletion autogen/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ resource "google_container_cluster" "zonal_primary" {
{% endif %}

remove_default_node_pool = "${var.remove_default_node_pool}"
initial_node_count = 0
initial_node_count = "${var.initial_node_count}"
}

/******************************************
Expand Down
5 changes: 5 additions & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,8 @@ variable "issue_client_certificate" {
description = "Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive!"
default = "false"
}

variable "initial_node_count" {
description = "The initial size of the default cluster. Clusters having `remove_default_node_pool` set to `true` and any new clusters must specify this variable >= 1."
default = 0
}
2 changes: 1 addition & 1 deletion cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ resource "google_container_cluster" "primary" {
}

remove_default_node_pool = "${var.remove_default_node_pool}"
initial_node_count = 0
initial_node_count = "${var.initial_node_count}"
}

/******************************************
Expand Down
3 changes: 2 additions & 1 deletion cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ resource "google_container_cluster" "zonal_primary" {
delete = "30m"
}


remove_default_node_pool = "${var.remove_default_node_pool}"
initial_node_count = 0
initial_node_count = "${var.initial_node_count}"
}

/******************************************
Expand Down
22 changes: 10 additions & 12 deletions examples/deploy_service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,16 @@ provider "kubernetes" {
data "google_client_config" "default" {}

module "gke" {
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = "${var.region}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"

kubernetes_version = "1.11.7-gke.12"

ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = "${var.region}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
initial_node_count = 1
}

resource "kubernetes_pod" "nginx-example" {
Expand Down
10 changes: 8 additions & 2 deletions examples/disable_client_cert/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ locals {
}

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

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

module "gke" {
Expand All @@ -36,6 +41,7 @@ module "gke" {
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
issue_client_certificate = false
initial_node_count = 1
}

data "google_client_config" "default" {}
3 changes: 2 additions & 1 deletion examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ module "gke" {
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
remove_default_node_pool = "true"
disable_legacy_metadata_endpoints = "false"
initial_node_count = 1
remove_default_node_pool = true

node_pools = [
{
Expand Down
1 change: 1 addition & 0 deletions examples/shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module "gke" {
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
initial_node_count = 1
}

data "google_client_config" "default" {}
21 changes: 11 additions & 10 deletions examples/simple_regional/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ provider "google-beta" {
}

module "gke" {
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
regional = true
region = "${var.region}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
regional = true
region = "${var.region}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
initial_node_count = 1
}

data "google_client_config" "default" {}
6 changes: 6 additions & 0 deletions examples/simple_regional_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ locals {
cluster_type = "simple-regional-private"
}

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

provider "google-beta" {
version = "~> 2.5"
region = "${var.region}"
Expand All @@ -43,6 +48,7 @@ module "gke" {
enable_private_endpoint = true
enable_private_nodes = true
master_ipv4_cidr_block = "172.16.0.0/28"
initial_node_count = 1

master_authorized_networks_config = [{
cidr_blocks = [{
Expand Down
23 changes: 12 additions & 11 deletions examples/simple_zonal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ provider "google-beta" {
}

module "gke" {
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
regional = false
region = "${var.region}"
zones = "${var.zones}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "create"
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
regional = false
region = "${var.region}"
zones = "${var.zones}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "create"
initial_node_count = 1
}

data "google_client_config" "default" {}
6 changes: 6 additions & 0 deletions examples/simple_zonal_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ locals {
cluster_type = "simple-regional-private"
}

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

provider "google-beta" {
version = "~> 2.5"
region = "${var.region}"
Expand All @@ -44,6 +49,7 @@ module "gke" {
enable_private_endpoint = true
enable_private_nodes = true
master_ipv4_cidr_block = "172.16.0.0/28"
initial_node_count = 1

master_authorized_networks_config = [{
cidr_blocks = [{
Expand Down
21 changes: 11 additions & 10 deletions examples/stub_domains/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ provider "google-beta" {
}

module "gke" {
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = "${var.region}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
network_policy = true
service_account = "${var.compute_engine_service_account}"
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = "${var.region}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
network_policy = true
service_account = "${var.compute_engine_service_account}"
initial_node_count = 1

stub_domains {
"example.com" = [
Expand Down
1 change: 1 addition & 0 deletions helpers/combine_docfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
exclude_separator_regex = r'(.*?)Copyright 20\d\d Google LLC.*?limitations under the License.(.*?)$' # noqa: E501

if len(sys.argv) != 3:
print("3 arguments must be given.")
sys.exit(1)

if not os.path.isfile(sys.argv[1]):
Expand Down
Loading

0 comments on commit 190bff9

Please sign in to comment.