Skip to content

Commit dc2448d

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

File tree

27 files changed

+125
-85
lines changed

27 files changed

+125
-85
lines changed

.kitchen.yml

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -54,80 +54,80 @@ 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
64-
- name: "simple_regional"
65-
driver:
66-
root_module_directory: test/fixtures/simple_regional
67-
verifier:
68-
systems:
69-
- name: simple_regional
70-
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
57+
# - name: "shared_vpc"
10858
# driver:
109-
# root_module_directory: test/fixtures/stub_domains_private
59+
# root_module_directory: test/fixtures/shared_vpc
60+
# verifier:
11061
# systems:
111-
# - name: stub_domains_private
62+
# - name: shared_vpc
63+
# backend: local
64+
# - name: "simple_regional"
65+
# driver:
66+
# root_module_directory: test/fixtures/simple_regional
67+
# verifier:
68+
# systems:
69+
# - name: simple_regional
70+
# 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
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
112133
# 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

README.md

Lines changed: 1 addition & 0 deletions
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 |

autogen/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
201201
| 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 |
202202
| 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 |
203203
| 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 |
204+
| skip\_provisioners | Flag to skip local-exec provisioners. Does not affect if `stub_domains` or `upstream_nameservers` variable set. | bool | `"false"` | no |
204205
| 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 |
205206
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
206207
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |

autogen/cluster.tf

Lines changed: 1 addition & 0 deletions
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 ? 0 : 1
355356

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

autogen/dns.tf

Lines changed: 1 addition & 1 deletion
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"

autogen/variables.tf

Lines changed: 5 additions & 0 deletions
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" {

cluster.tf

Lines changed: 1 addition & 0 deletions
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 ? 0 : 1
230231

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

dns.tf

Lines changed: 1 addition & 1 deletion
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"

examples/disable_client_cert/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ This example illustrates how to create a simple cluster and disable deprecated s
1212
|------|-------------|:----:|:-----:|:-----:|
1313
| cluster\_name\_suffix | A suffix to append to the default cluster name | string | `""` | no |
1414
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | string | n/a | yes |
15-
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
1615
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |
1716
| ip\_range\_services | The secondary ip range to use for pods | string | n/a | yes |
1817
| network | The VPC network to host the cluster in | string | n/a | yes |
1918
| network\_project\_id | The GCP project housing the VPC network to host the cluster in | string | n/a | yes |
2019
| project\_id | The project ID to host the cluster in | string | n/a | yes |
2120
| region | The region to host the cluster in | string | n/a | yes |
21+
| skip\_provisioners | Flag to skip local-exec provisioners | bool | `"false"` | no |
2222
| subnetwork | The subnetwork to host the cluster in | string | n/a | yes |
2323

2424
## Outputs

examples/disable_client_cert/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module "gke" {
3737
create_service_account = false
3838
service_account = var.compute_engine_service_account
3939
issue_client_certificate = false
40+
skip_provisioners = var.skip_provisioners
4041
}
4142

4243
data "google_client_config" "default" {

examples/disable_client_cert/variables.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ variable "project_id" {
1818
description = "The project ID to host the cluster in"
1919
}
2020

21-
variable "credentials_path" {
22-
description = "The path to the GCP credentials JSON file"
23-
}
24-
2521
variable "cluster_name_suffix" {
2622
description = "A suffix to append to the default cluster name"
2723
default = ""
@@ -55,3 +51,9 @@ variable "compute_engine_service_account" {
5551
description = "Service account to associate to the nodes in the cluster"
5652
}
5753

54+
variable "skip_provisioners" {
55+
type = bool
56+
description = "Flag to skip local-exec provisioners"
57+
default = false
58+
}
59+

examples/simple_regional/README.md

Lines changed: 1 addition & 0 deletions
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

examples/simple_regional/main.tf

Lines changed: 1 addition & 0 deletions
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" {

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
194194
| 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 |
195195
| 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 |
196196
| 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 |
197+
| skip\_provisioners | Flag to skip local-exec provisioners. Does not affect if `stub_domains` or `upstream_nameservers` variable set. | bool | `"false"` | no |
197198
| 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 |
198199
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
199200
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |

modules/beta-private-cluster/cluster.tf

Lines changed: 1 addition & 0 deletions
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 ? 0 : 1
331332

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

modules/beta-private-cluster/dns.tf

Lines changed: 1 addition & 1 deletion
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"

modules/beta-private-cluster/variables.tf

Lines changed: 5 additions & 0 deletions
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

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
185185
| 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 |
186186
| 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 |
187187
| 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 |
188189
| 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 |
189190
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
190191
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |

modules/beta-public-cluster/cluster.tf

Lines changed: 1 addition & 0 deletions
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 ? 0 : 1
326327

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

modules/beta-public-cluster/dns.tf

Lines changed: 1 addition & 1 deletion
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"

modules/beta-public-cluster/variables.tf

Lines changed: 5 additions & 0 deletions
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 "istio" {
307312
description = "(Beta) Enable Istio addon"

modules/private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
178178
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
179179
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
180180
| 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 |
181182
| 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 |
182183
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
183184
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |

modules/private-cluster/cluster.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ resource "google_container_node_pool" "pools" {
232232
}
233233

234234
resource "null_resource" "wait_for_cluster" {
235+
count = var.skip_provisioners ? 0 : 1
235236

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

modules/private-cluster/dns.tf

Lines changed: 1 addition & 1 deletion
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"

modules/private-cluster/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ variable "cluster_resource_labels" {
292292
default = {}
293293
}
294294

295+
variable "skip_provisioners" {
296+
type = bool
297+
description = "Flag to skip local-exec provisioners. Does not affect if `stub_domains` or `upstream_nameservers` variable set."
298+
default = false
299+
}
295300

296301
variable "deploy_using_private_endpoint" {
297302
type = bool

0 commit comments

Comments
 (0)