Skip to content

Commit 1e6098d

Browse files
Added variable skip_provisioners to skip 'local-exec'
* Fix terraform-google-modules#258 * Added test `simple_regional_skip_local_exec` * Remove old upgrading guide from README's
1 parent 81eb717 commit 1e6098d

File tree

31 files changed

+167
-139
lines changed

31 files changed

+167
-139
lines changed

Diff for: .kitchen.yml

+77-70
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ suites:
3838
# systems:
3939
# - name: deploy_service
4040
# backend: local
41-
- name: "disable_client_cert"
42-
driver:
43-
root_module_directory: test/fixtures/disable_client_cert
44-
verifier:
45-
systems:
46-
- name: disable_client_cert
47-
backend: local
41+
# - name: "disable_client_cert"
42+
# driver:
43+
# root_module_directory: test/fixtures/disable_client_cert
44+
# verifier:
45+
# systems:
46+
# - name: disable_client_cert
47+
# backend: local
4848
# Disabled due to issue #274
4949
# (https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/issues/274)
5050
# - name: "node_pool"
@@ -54,80 +54,87 @@ suites:
5454
# systems:
5555
# - name: node_pool
5656
# backend: local
57-
- name: "shared_vpc"
58-
driver:
59-
root_module_directory: test/fixtures/shared_vpc
60-
verifier:
61-
systems:
62-
- name: shared_vpc
63-
backend: local
57+
# - name: "shared_vpc"
58+
# driver:
59+
# root_module_directory: test/fixtures/shared_vpc
60+
# verifier:
61+
# systems:
62+
# - name: shared_vpc
63+
# backend: local
6464
- name: "simple_regional"
6565
driver:
6666
root_module_directory: test/fixtures/simple_regional
6767
verifier:
6868
systems:
6969
- name: simple_regional
7070
backend: local
71-
- name: "simple_regional_private"
72-
driver:
73-
root_module_directory: test/fixtures/simple_regional_private
74-
verifier:
75-
systems:
76-
- name: simple_regional_private
77-
backend: local
78-
- name: "simple_zonal"
79-
driver:
80-
root_module_directory: test/fixtures/simple_zonal
81-
verifier:
82-
systems:
83-
- name: gcloud
84-
backend: local
85-
controls:
86-
- gcloud
87-
- name: gcp
88-
backend: gcp
89-
controls:
90-
- gcp
91-
- name: "simple_zonal_private"
92-
driver:
93-
root_module_directory: test/fixtures/simple_zonal_private
94-
verifier:
95-
systems:
96-
- name: simple_zonal_private
97-
backend: local
98-
- name: "stub_domains"
99-
driver:
100-
root_module_directory: test/fixtures/stub_domains
101-
verifier:
102-
systems:
103-
- name: stub_domains
104-
backend: local
105-
# Disabled due to issue #264
106-
# (https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/issues/264)
107-
# - name: stub_domains_private
71+
# - name: "simple_regional_private"
10872
# driver:
109-
# root_module_directory: test/fixtures/stub_domains_private
73+
# root_module_directory: test/fixtures/simple_regional_private
74+
# verifier:
11075
# systems:
111-
# - name: stub_domains_private
76+
# - name: simple_regional_private
11277
# backend: local
113-
- name: "upstream_nameservers"
114-
driver:
115-
root_module_directory: test/fixtures/upstream_nameservers
116-
verifier:
117-
systems:
118-
- name: upstream_nameservers
119-
backend: local
120-
- name: "stub_domains_upstream_nameservers"
121-
driver:
122-
root_module_directory: test/fixtures/stub_domains_upstream_nameservers
123-
verifier:
124-
systems:
125-
- name: stub_domains_upstream_nameservers
126-
backend: local
127-
- name: "workload_metadata_config"
78+
# - name: "simple_zonal"
79+
# driver:
80+
# root_module_directory: test/fixtures/simple_zonal
81+
# verifier:
82+
# systems:
83+
# - name: gcloud
84+
# backend: local
85+
# controls:
86+
# - gcloud
87+
# - name: gcp
88+
# backend: gcp
89+
# controls:
90+
# - gcp
91+
# - name: "simple_zonal_private"
92+
# driver:
93+
# root_module_directory: test/fixtures/simple_zonal_private
94+
# verifier:
95+
# systems:
96+
# - name: simple_zonal_private
97+
# backend: local
98+
# - name: "stub_domains"
99+
# driver:
100+
# root_module_directory: test/fixtures/stub_domains
101+
# verifier:
102+
# systems:
103+
# - name: stub_domains
104+
# backend: local
105+
## Disabled due to issue #264
106+
## (https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/issues/264)
107+
## - name: stub_domains_private
108+
## driver:
109+
## root_module_directory: test/fixtures/stub_domains_private
110+
## systems:
111+
## - name: stub_domains_private
112+
## backend: local
113+
# - name: "upstream_nameservers"
114+
# driver:
115+
# root_module_directory: test/fixtures/upstream_nameservers
116+
# verifier:
117+
# systems:
118+
# - name: upstream_nameservers
119+
# backend: local
120+
# - name: "stub_domains_upstream_nameservers"
121+
# driver:
122+
# root_module_directory: test/fixtures/stub_domains_upstream_nameservers
123+
# verifier:
124+
# systems:
125+
# - name: stub_domains_upstream_nameservers
126+
# backend: local
127+
# - name: "workload_metadata_config"
128+
# driver:
129+
# root_module_directory: test/fixtures/workload_metadata_config
130+
# verifier:
131+
# systems:
132+
# - name: workload_metadata_config
133+
# backend: local
134+
- name: "simple_regional_skip_local_exec"
128135
driver:
129-
root_module_directory: test/fixtures/workload_metadata_config
136+
root_module_directory: test/fixtures/simple_regional_skip_local_exec
130137
verifier:
131138
systems:
132-
- name: workload_metadata_config
139+
- name: simple_regional
133140
backend: local

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Then perform the following commands on the root folder:
153153
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
154154
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
155155
| 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 |
156+
| skip\_provisioners | Flag to skip local-exec provisioners. Does not affect if `stub_domains` or `upstream_nameservers` variable set. | bool | `"false"` | no |
156157
| 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 |
157158
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
158159
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |

Diff for: autogen/README.md

+1-16
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,6 @@ Then perform the following commands on the root folder:
122122
- `terraform apply` to apply the infrastructure build
123123
- `terraform destroy` to destroy the built infrastructure
124124

125-
## Upgrade to v3.0.0
126-
127-
v3.0.0 is a breaking release. Refer to the
128-
[Upgrading to v3.0 guide][upgrading-to-v3.0] for details.
129-
130-
## Upgrade to v2.0.0
131-
132-
v2.0.0 is a breaking release. Refer to the
133-
[Upgrading to v2.0 guide][upgrading-to-v2.0] for details.
134-
135-
## Upgrade to v1.0.0
136-
137-
Version 1.0.0 of this module introduces a breaking change: adding the `disable-legacy-endpoints` metadata field to all node pools. This metadata is required by GKE and [determines whether the `/0.1/` and `/v1beta1/` paths are available in the nodes' metadata server](https://cloud.google.com/kubernetes-engine/docs/how-to/protecting-cluster-metadata#disable-legacy-apis). If your applications do not require access to the node's metadata server, you can leave the default value of `true` provided by the module. If your applications require access to the metadata server, be sure to read the linked documentation to see if you need to set the value for this field to `false` to allow your applications access to the above metadata server paths.
138-
139-
In either case, upgrading to module version `v1.0.0` will trigger a recreation of all node pools in the cluster.
140-
141125
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
142126
## Inputs
143127

@@ -201,6 +185,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
201185
| 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 |
202186
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it). | bool | `"false"` | no |
203187
| 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 |
188+
| skip\_provisioners | Flag to skip local-exec provisioners. Does not affect if `stub_domains` or `upstream_nameservers` variable set. | bool | `"false"` | no |
204189
| 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 |
205190
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
206191
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |

Diff for: autogen/cluster.tf

+1
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ resource "google_container_node_pool" "pools" {
352352
}
353353

354354
resource "null_resource" "wait_for_cluster" {
355+
count = var.skip_provisioners ? 1 : 0
355356

356357
provisioner "local-exec" {
357358
command = "${path.module}/scripts/wait-for-cluster.sh ${var.project_id} ${var.name}"

Diff for: autogen/dns.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Delete default kube-dns configmap
2121
*****************************************/
2222
resource "null_resource" "delete_default_kube_dns_configmap" {
23-
count = local.custom_kube_dns_config || local.upstream_nameservers_config ? 1 : 0
23+
count = (local.custom_kube_dns_config || local.upstream_nameservers_config) || var.skip_provisioners ? 1 : 0
2424

2525
provisioner "local-exec" {
2626
command = "${path.module}/scripts/kubectl_wrapper.sh https://${local.cluster_endpoint} ${data.google_client_config.default.access_token} ${local.cluster_ca_certificate} ${path.module}/scripts/delete-default-resource.sh kube-system configmap kube-dns"

Diff for: autogen/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ variable "cluster_resource_labels" {
304304
default = {}
305305
}
306306

307+
variable "skip_provisioners" {
308+
type = bool
309+
description = "Flag to skip local-exec provisioners. Does not affect if `stub_domains` or `upstream_nameservers` variable set."
310+
default = false
311+
}
307312
{% if private_cluster %}
308313

309314
variable "deploy_using_private_endpoint" {

Diff for: cluster.tf

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ resource "google_container_node_pool" "pools" {
227227
}
228228

229229
resource "null_resource" "wait_for_cluster" {
230+
count = var.skip_provisioners ? 1 : 0
230231

231232
provisioner "local-exec" {
232233
command = "${path.module}/scripts/wait-for-cluster.sh ${var.project_id} ${var.name}"

Diff for: dns.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Delete default kube-dns configmap
2121
*****************************************/
2222
resource "null_resource" "delete_default_kube_dns_configmap" {
23-
count = local.custom_kube_dns_config || local.upstream_nameservers_config ? 1 : 0
23+
count = (local.custom_kube_dns_config || local.upstream_nameservers_config) || var.skip_provisioners ? 1 : 0
2424

2525
provisioner "local-exec" {
2626
command = "${path.module}/scripts/kubectl_wrapper.sh https://${local.cluster_endpoint} ${data.google_client_config.default.access_token} ${local.cluster_ca_certificate} ${path.module}/scripts/delete-default-resource.sh kube-system configmap kube-dns"

Diff for: examples/simple_regional/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This example illustrates how to create a simple cluster.
1414
| network | The VPC network to host the cluster in | string | n/a | yes |
1515
| project\_id | The project ID to host the cluster in | string | n/a | yes |
1616
| region | The region to host the cluster in | string | n/a | yes |
17+
| skip\_provisioners | Flag to skip local-exec provisioners | bool | `"false"` | no |
1718
| subnetwork | The subnetwork to host the cluster in | string | n/a | yes |
1819

1920
## Outputs

Diff for: examples/simple_regional/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module "gke" {
3535
ip_range_services = var.ip_range_services
3636
create_service_account = false
3737
service_account = var.compute_engine_service_account
38+
skip_provisioners = var.skip_provisioners
3839
}
3940

4041
data "google_client_config" "default" {

Diff for: examples/simple_regional/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ variable "compute_engine_service_account" {
4747
description = "Service account to associate to the nodes in the cluster"
4848
}
4949

50+
variable "skip_provisioners" {
51+
type = bool
52+
description = "Flag to skip local-exec provisioners"
53+
default = false
54+
}

Diff for: modules/beta-private-cluster/README.md

+1-16
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,6 @@ Then perform the following commands on the root folder:
115115
- `terraform apply` to apply the infrastructure build
116116
- `terraform destroy` to destroy the built infrastructure
117117

118-
## Upgrade to v3.0.0
119-
120-
v3.0.0 is a breaking release. Refer to the
121-
[Upgrading to v3.0 guide][upgrading-to-v3.0] for details.
122-
123-
## Upgrade to v2.0.0
124-
125-
v2.0.0 is a breaking release. Refer to the
126-
[Upgrading to v2.0 guide][upgrading-to-v2.0] for details.
127-
128-
## Upgrade to v1.0.0
129-
130-
Version 1.0.0 of this module introduces a breaking change: adding the `disable-legacy-endpoints` metadata field to all node pools. This metadata is required by GKE and [determines whether the `/0.1/` and `/v1beta1/` paths are available in the nodes' metadata server](https://cloud.google.com/kubernetes-engine/docs/how-to/protecting-cluster-metadata#disable-legacy-apis). If your applications do not require access to the node's metadata server, you can leave the default value of `true` provided by the module. If your applications require access to the metadata server, be sure to read the linked documentation to see if you need to set the value for this field to `false` to allow your applications access to the above metadata server paths.
131-
132-
In either case, upgrading to module version `v1.0.0` will trigger a recreation of all node pools in the cluster.
133-
134118
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
135119
## Inputs
136120

@@ -194,6 +178,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
194178
| 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 |
195179
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it). | bool | `"false"` | no |
196180
| 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 |
181+
| skip\_provisioners | Flag to skip local-exec provisioners. Does not affect if `stub_domains` or `upstream_nameservers` variable set. | bool | `"false"` | no |
197182
| 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 |
198183
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
199184
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |

Diff for: modules/beta-private-cluster/cluster.tf

+1
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ resource "google_container_node_pool" "pools" {
328328
}
329329

330330
resource "null_resource" "wait_for_cluster" {
331+
count = var.skip_provisioners ? 1 : 0
331332

332333
provisioner "local-exec" {
333334
command = "${path.module}/scripts/wait-for-cluster.sh ${var.project_id} ${var.name}"

Diff for: modules/beta-private-cluster/dns.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Delete default kube-dns configmap
2121
*****************************************/
2222
resource "null_resource" "delete_default_kube_dns_configmap" {
23-
count = local.custom_kube_dns_config || local.upstream_nameservers_config ? 1 : 0
23+
count = (local.custom_kube_dns_config || local.upstream_nameservers_config) || var.skip_provisioners ? 1 : 0
2424

2525
provisioner "local-exec" {
2626
command = "${path.module}/scripts/kubectl_wrapper.sh https://${local.cluster_endpoint} ${data.google_client_config.default.access_token} ${local.cluster_ca_certificate} ${path.module}/scripts/delete-default-resource.sh kube-system configmap kube-dns"

Diff for: modules/beta-private-cluster/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ variable "cluster_resource_labels" {
302302
default = {}
303303
}
304304

305+
variable "skip_provisioners" {
306+
type = bool
307+
description = "Flag to skip local-exec provisioners. Does not affect if `stub_domains` or `upstream_nameservers` variable set."
308+
default = false
309+
}
305310

306311
variable "deploy_using_private_endpoint" {
307312
type = bool

Diff for: modules/beta-public-cluster/README.md

+1-16
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,6 @@ Then perform the following commands on the root folder:
110110
- `terraform apply` to apply the infrastructure build
111111
- `terraform destroy` to destroy the built infrastructure
112112

113-
## Upgrade to v3.0.0
114-
115-
v3.0.0 is a breaking release. Refer to the
116-
[Upgrading to v3.0 guide][upgrading-to-v3.0] for details.
117-
118-
## Upgrade to v2.0.0
119-
120-
v2.0.0 is a breaking release. Refer to the
121-
[Upgrading to v2.0 guide][upgrading-to-v2.0] for details.
122-
123-
## Upgrade to v1.0.0
124-
125-
Version 1.0.0 of this module introduces a breaking change: adding the `disable-legacy-endpoints` metadata field to all node pools. This metadata is required by GKE and [determines whether the `/0.1/` and `/v1beta1/` paths are available in the nodes' metadata server](https://cloud.google.com/kubernetes-engine/docs/how-to/protecting-cluster-metadata#disable-legacy-apis). If your applications do not require access to the node's metadata server, you can leave the default value of `true` provided by the module. If your applications require access to the metadata server, be sure to read the linked documentation to see if you need to set the value for this field to `false` to allow your applications access to the above metadata server paths.
126-
127-
In either case, upgrading to module version `v1.0.0` will trigger a recreation of all node pools in the cluster.
128-
129113
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
130114
## Inputs
131115

@@ -185,6 +169,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
185169
| 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 |
186170
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it). | bool | `"false"` | no |
187171
| 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 |
172+
| skip\_provisioners | Flag to skip local-exec provisioners. Does not affect if `stub_domains` or `upstream_nameservers` variable set. | bool | `"false"` | no |
188173
| 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 |
189174
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
190175
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |

Diff for: modules/beta-public-cluster/cluster.tf

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ resource "google_container_node_pool" "pools" {
323323
}
324324

325325
resource "null_resource" "wait_for_cluster" {
326+
count = var.skip_provisioners ? 1 : 0
326327

327328
provisioner "local-exec" {
328329
command = "${path.module}/scripts/wait-for-cluster.sh ${var.project_id} ${var.name}"

Diff for: modules/beta-public-cluster/dns.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Delete default kube-dns configmap
2121
*****************************************/
2222
resource "null_resource" "delete_default_kube_dns_configmap" {
23-
count = local.custom_kube_dns_config || local.upstream_nameservers_config ? 1 : 0
23+
count = (local.custom_kube_dns_config || local.upstream_nameservers_config) || var.skip_provisioners ? 1 : 0
2424

2525
provisioner "local-exec" {
2626
command = "${path.module}/scripts/kubectl_wrapper.sh https://${local.cluster_endpoint} ${data.google_client_config.default.access_token} ${local.cluster_ca_certificate} ${path.module}/scripts/delete-default-resource.sh kube-system configmap kube-dns"

0 commit comments

Comments
 (0)