Skip to content

Commit ca8d16b

Browse files
authored
Merge pull request #177 from terraform-google-modules/aaron-lane-0.12
Add support for Terraform v0.12
2 parents 0cb8bd6 + a807f21 commit ca8d16b

File tree

161 files changed

+4691
-2669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+4691
-2669
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Extending the adopted spec, each change should have a link to its corresponding
88

99
## [Unreleased]
1010

11+
## [4.0.0] 2019-07-ZZ
12+
13+
### Changed
14+
15+
* Supported version of Terraform is 0.12. [#58]
16+
1117
## [v3.0.0] - 2019-07-08
1218

1319
### Added

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ruby "~> 2.5"
1616

1717
source 'https://rubygems.org/' do
18-
gem "kitchen-terraform", "~> 4.0"
18+
gem "kitchen-terraform", "~> 4.9"
1919
gem "kubeclient", "~> 4.0"
2020
gem "rest-client", "~> 2.0"
2121
end

Makefile

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ SHELL := /usr/bin/env bash
1818
# Docker build config variables
1919
CREDENTIALS_PATH ?= /cft/workdir/credentials.json
2020
DOCKER_ORG := gcr.io/cloud-foundation-cicd
21-
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 1.3.0
21+
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 2.1.0
2222
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}
23-
DOCKER_TAG_KITCHEN_TERRAFORM ?= ${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}
24-
DOCKER_IMAGE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform_terraform-google-kubernetes-engine
2523

2624
# All is the first target in the file so it will get picked up when you just run 'make' on its own
2725
.PHONY: all
@@ -105,19 +103,6 @@ dev: generate generate_docs
105103
version:
106104
@source helpers/version-repo.sh
107105

108-
# Build Docker
109-
.PHONY: docker_build_kitchen_terraform
110-
docker_build_kitchen_terraform:
111-
docker build -f build/docker/kitchen_terraform/Dockerfile \
112-
--build-arg BASE_IMAGE=${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
113-
-t ${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} .
114-
115-
# Push Docker image
116-
.PHONY: docker_push_kitchen_terraform
117-
docker_push_kitchen_terraform:
118-
docker tag ${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} ${DOCKER_ORG}/${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM}
119-
docker push ${DOCKER_ORG}/${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM}
120-
121106
# Run docker
122107
.PHONY: docker_run
123108
docker_run:
@@ -130,7 +115,7 @@ docker_run:
130115
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
131116
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
132117
-v "$(CURDIR)":/cft/workdir \
133-
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
118+
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
134119
/bin/bash -c "source test/ci_integration.sh && setup_environment && exec /bin/bash"
135120

136121
.PHONY: docker_create
@@ -144,7 +129,7 @@ docker_create: docker_build_kitchen_terraform
144129
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
145130
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
146131
-v "$(CURDIR)":/cft/workdir \
147-
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
132+
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
148133
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen create"
149134

150135
.PHONY: docker_converge
@@ -158,7 +143,7 @@ docker_converge:
158143
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
159144
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
160145
-v "$(CURDIR)":/cft/workdir \
161-
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
146+
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
162147
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen converge && kitchen converge"
163148

164149
.PHONY: docker_verify
@@ -172,7 +157,7 @@ docker_verify:
172157
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
173158
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
174159
-v "$(CURDIR)":/cft/workdir \
175-
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
160+
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
176161
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen verify"
177162

178163
.PHONY: docker_destroy
@@ -186,7 +171,7 @@ docker_destroy:
186171
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
187172
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
188173
-v "$(CURDIR)":/cft/workdir \
189-
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
174+
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
190175
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen destroy"
191176

192177
.PHONY: test_integration_docker
@@ -198,5 +183,5 @@ test_integration_docker:
198183
-e ZONES \
199184
-e SERVICE_ACCOUNT_JSON \
200185
-v "$(CURDIR)":/cft/workdir \
201-
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
186+
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
202187
/bin/bash -c "test/ci_integration.sh"

README.md

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ The resources/services/activations/deletions that this module will create/trigge
88
- Activate network policy if `network_policy` is true
99
- Add `ip-masq-agent` configmap with provided `non_masquerade_cidrs` if `network_policy` is true
1010

11+
12+
## Compatibility
13+
14+
This module is meant for use with Terraform 0.12. If you haven't
15+
[upgraded][terraform-0.12-upgrade] and need a Terraform
16+
0.11.x-compatible version of this module, the last released version
17+
intended for Terraform 0.11.x is [3.0.0].
18+
1119
## Usage
1220
There are multiple examples included in the [examples](./examples/) folder but simple usage is as follows:
1321

@@ -56,7 +64,7 @@ module "gke" {
5664
all = {}
5765
5866
default-node-pool = {
59-
default-node-pool = "true"
67+
default-node-pool = true
6068
}
6169
}
6270
@@ -74,7 +82,7 @@ module "gke" {
7482
default-node-pool = [
7583
{
7684
key = "default-node-pool"
77-
value = "true"
85+
value = true
7886
effect = "PREFER_NO_SCHEDULE"
7987
},
8088
]
@@ -113,8 +121,7 @@ Version 1.0.0 of this module introduces a breaking change: adding the `disable-l
113121

114122
In either case, upgrading to module version `v1.0.0` will trigger a recreation of all node pools in the cluster.
115123

116-
[^]: (autogen_docs_start)
117-
124+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
118125
## Inputs
119126

120127
| Name | Description | Type | Default | Required |
@@ -124,43 +131,43 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
124131
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string | `""` | no |
125132
| configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | string | `"false"` | no |
126133
| description | The description of the cluster | string | `""` | no |
127-
| 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 |
128-
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | string | `"true"` | no |
129-
| http\_load\_balancing | Enable httpload balancer addon | string | `"true"` | no |
130-
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | string | `"0"` | no |
131-
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | string | `"false"` | no |
134+
| 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. | bool | `"true"` | no |
135+
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
136+
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |
137+
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | number | `"0"` | no |
138+
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | bool | `"false"` | no |
132139
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string | `"60s"` | no |
133140
| ip\_range\_pods | The _name_ of the secondary subnet ip range to use for pods | string | n/a | yes |
134141
| ip\_range\_services | The _name_ of the secondary subnet range to use for services | string | n/a | yes |
135-
| issue\_client\_certificate | 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! | string | `"false"` | no |
136-
| kubernetes\_dashboard | Enable kubernetes dashboard addon | string | `"false"` | no |
142+
| issue\_client\_certificate | 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! | bool | `"false"` | no |
143+
| kubernetes\_dashboard | Enable kubernetes dashboard addon | bool | `"false"` | no |
137144
| kubernetes\_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string | `"latest"` | no |
138145
| logging\_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string | `"logging.googleapis.com"` | no |
139146
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
140-
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists)<br><br> ### example format ### master_authorized_networks_config = [{ cidr_blocks = [{ cidr_block = "10.0.0.0/8" display_name = "example_network" }], }] | list | `<list>` | no |
147+
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. The object format is {cidr_blocks = list(object({cidr_block = string, display_name = string}))}. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
141148
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string | `"monitoring.googleapis.com"` | no |
142149
| name | The name of the cluster (required) | string | n/a | yes |
143150
| network | The VPC network to host the cluster in (required) | string | n/a | yes |
144-
| network\_policy | Enable network policy addon | string | `"false"` | no |
151+
| network\_policy | Enable network policy addon | bool | `"false"` | no |
145152
| network\_policy\_provider | The network policy provider. | string | `"CALICO"` | no |
146153
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | string | `""` | no |
147-
| node\_pools | List of maps containing node pools | list | `<list>` | no |
148-
| node\_pools\_labels | Map of maps containing node labels by node-pool name | map | `<map>` | no |
149-
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map | `<map>` | no |
150-
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map | `<map>` | no |
151-
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map | `<map>` | no |
152-
| node\_pools\_taints | Map of lists containing node taints by node-pool name | map | `<map>` | no |
154+
| node\_pools | List of maps containing node pools | list(map(string)) | `<list>` | no |
155+
| node\_pools\_labels | Map of maps containing node labels by node-pool name | map(map(string)) | `<map>` | no |
156+
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) | `<map>` | no |
157+
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) | `<map>` | no |
158+
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map(list(string)) | `<map>` | no |
159+
| node\_pools\_taints | Map of lists containing node taints by node-pool name | object | `<map>` | no |
153160
| 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 |
154-
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list | `<list>` | no |
161+
| 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 |
155162
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
156163
| region | The region to host the cluster in (required) | string | n/a | yes |
157-
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | string | `"true"` | no |
158-
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | string | `"false"` | no |
164+
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
165+
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
159166
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created. | string | `"create"` | no |
160-
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map | `<map>` | no |
167+
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map(list(string)) | `<map>` | no |
161168
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
162169
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |
163-
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list | `<list>` | no |
170+
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) | `<list>` | no |
164171

165172
## Outputs
166173

@@ -186,7 +193,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
186193
| type | Cluster type (regional / zonal) |
187194
| zones | List of zones in which the cluster resides |
188195

189-
[^]: (autogen_docs_end)
196+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
190197

191198
## Requirements
192199

@@ -203,7 +210,7 @@ The [project factory](https://github.com/terraform-google-modules/terraform-goog
203210
#### Kubectl
204211
- [kubectl](https://github.com/kubernetes/kubernetes/releases) 1.9.x
205212
#### Terraform and Plugins
206-
- [Terraform](https://www.terraform.io/downloads.html) 0.11.x
213+
- [Terraform](https://www.terraform.io/downloads.html) 0.12
207214
- [Terraform Provider for GCP][terraform-provider-google] v2.9
208215

209216
### Configure a Service Account
@@ -374,3 +381,5 @@ command.
374381
[upgrading-to-v2.0]: docs/upgrading_to_v2.0.md
375382
[upgrading-to-v3.0]: docs/upgrading_to_v3.0.md
376383
[terraform-provider-google]: https://github.com/terraform-providers/terraform-provider-google
384+
[3.0.0]: https://registry.terraform.io/modules/terraform-google-modules/kubernetes-engine/google/3.0.0
385+
[terraform-0.12-upgrade]: https://www.terraform.io/upgrade-guides/0-12.html

auth.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Retrieve authentication token
2121
*****************************************/
2222
data "google_client_config" "default" {
23-
provider = "google"
23+
provider = google
2424
}
2525

2626
/******************************************
@@ -29,6 +29,6 @@ data "google_client_config" "default" {
2929
provider "kubernetes" {
3030
load_config_file = false
3131
host = "https://${local.cluster_endpoint}"
32-
token = "${data.google_client_config.default.access_token}"
33-
cluster_ca_certificate = "${base64decode(local.cluster_ca_certificate)}"
32+
token = data.google_client_config.default.access_token
33+
cluster_ca_certificate = base64decode(local.cluster_ca_certificate)
3434
}

autogen/README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ The resources/services/activations/deletions that this module will create/trigge
1313
**Note**: You must run Terraform from a VM on the same VPC as your cluster, otherwise there will be issues connecting to the GKE master.
1414

1515
{% endif %}
16+
17+
## Compatibility
18+
19+
This module is meant for use with Terraform 0.12. If you haven't
20+
[upgraded][terraform-0.12-upgrade] and need a Terraform
21+
0.11.x-compatible version of this module, the last released version
22+
intended for Terraform 0.11.x is [3.0.0].
23+
1624
## Usage
1725
There are multiple examples included in the [examples](./examples/) folder but simple usage is as follows:
1826

@@ -70,7 +78,7 @@ module "gke" {
7078
all = {}
7179
7280
default-node-pool = {
73-
default-node-pool = "true"
81+
default-node-pool = true
7482
}
7583
}
7684
@@ -88,7 +96,7 @@ module "gke" {
8896
default-node-pool = [
8997
{
9098
key = "default-node-pool"
91-
value = "true"
99+
value = true
92100
effect = "PREFER_NO_SCHEDULE"
93101
},
94102
]
@@ -127,8 +135,8 @@ Version 1.0.0 of this module introduces a breaking change: adding the `disable-l
127135

128136
In either case, upgrading to module version `v1.0.0` will trigger a recreation of all node pools in the cluster.
129137

130-
[^]: (autogen_docs_start)
131-
[^]: (autogen_docs_end)
138+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
139+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
132140

133141
## Requirements
134142

@@ -145,7 +153,7 @@ The [project factory](https://github.com/terraform-google-modules/terraform-goog
145153
#### Kubectl
146154
- [kubectl](https://github.com/kubernetes/kubernetes/releases) 1.9.x
147155
#### Terraform and Plugins
148-
- [Terraform](https://www.terraform.io/downloads.html) 0.11.x
156+
- [Terraform](https://www.terraform.io/downloads.html) 0.12
149157
{% if private_cluster or beta_cluster %}
150158
- [Terraform Provider for GCP Beta][terraform-provider-google-beta] v2.9
151159
{% else %}
@@ -332,3 +340,5 @@ command.
332340
{% else %}
333341
[terraform-provider-google]: https://github.com/terraform-providers/terraform-provider-google
334342
{% endif %}
343+
[3.0.0]: https://registry.terraform.io/modules/terraform-google-modules/kubernetes-engine/google/3.0.0
344+
[terraform-0.12-upgrade]: https://www.terraform.io/upgrade-guides/0-12.html

autogen/auth.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
Retrieve authentication token
2121
*****************************************/
2222
data "google_client_config" "default" {
23-
provider = "{% if private_cluster or beta_cluster %}google-beta{% else %}google{% endif %}"
23+
{% if private_cluster or beta_cluster %}
24+
provider = google-beta
25+
{% else %}
26+
provider = google
27+
{% endif %}
2428
}
2529

2630
/******************************************
@@ -29,6 +33,6 @@ data "google_client_config" "default" {
2933
provider "kubernetes" {
3034
load_config_file = false
3135
host = "https://${local.cluster_endpoint}"
32-
token = "${data.google_client_config.default.access_token}"
33-
cluster_ca_certificate = "${base64decode(local.cluster_ca_certificate)}"
36+
token = data.google_client_config.default.access_token
37+
cluster_ca_certificate = base64decode(local.cluster_ca_certificate)
3438
}

0 commit comments

Comments
 (0)