Skip to content

Commit ce97874

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 ce97874

File tree

33 files changed

+286
-69
lines changed

33 files changed

+286
-69
lines changed

.kitchen.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,10 @@ suites:
131131
systems:
132132
- name: workload_metadata_config
133133
backend: local
134+
- name: "simple_regional_skip_local_exec"
135+
driver:
136+
root_module_directory: test/fixtures/simple_regional_skip_local_exec
137+
verifier:
138+
systems:
139+
- name: simple_regional
140+
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 all local-exec provisioners. It breaks down `stub_domains` and `upstream_nameservers` variables functionality. | 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 & 16 deletions
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 |

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 ? 1 : 0
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 all local-exec provisioners. It breaks down `stub_domains` and `upstream_nameservers` variables functionality."
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 ? 1 : 0
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/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" {

examples/simple_regional/variables.tf

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

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 16 deletions
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 all local-exec provisioners. It breaks down `stub_domains` and `upstream_nameservers` variables functionality. | 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 |

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 ? 1 : 0
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 all local-exec provisioners. It breaks down `stub_domains` and `upstream_nameservers` variables functionality."
308+
default = false
309+
}
305310

306311
variable "deploy_using_private_endpoint" {
307312
type = bool

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 16 deletions
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 all local-exec provisioners. It breaks down `stub_domains` and `upstream_nameservers` variables functionality. | 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 |

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 ? 1 : 0
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 all local-exec provisioners. It breaks down `stub_domains` and `upstream_nameservers` variables functionality."
308+
default = false
309+
}
305310

306311
variable "istio" {
307312
description = "(Beta) Enable Istio addon"

modules/private-cluster/README.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,6 @@ Then perform the following commands on the root folder:
113113
- `terraform apply` to apply the infrastructure build
114114
- `terraform destroy` to destroy the built infrastructure
115115

116-
## Upgrade to v3.0.0
117-
118-
v3.0.0 is a breaking release. Refer to the
119-
[Upgrading to v3.0 guide][upgrading-to-v3.0] for details.
120-
121-
## Upgrade to v2.0.0
122-
123-
v2.0.0 is a breaking release. Refer to the
124-
[Upgrading to v2.0 guide][upgrading-to-v2.0] for details.
125-
126-
## Upgrade to v1.0.0
127-
128-
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.
129-
130-
In either case, upgrading to module version `v1.0.0` will trigger a recreation of all node pools in the cluster.
131-
132116
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
133117
## Inputs
134118

@@ -178,6 +162,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
178162
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
179163
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
180164
| 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 |
165+
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks down `stub_domains` and `upstream_nameservers` variables functionality. | bool | `"false"` | no |
181166
| 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 |
182167
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
183168
| 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 ? 1 : 0
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 all local-exec provisioners. It breaks down `stub_domains` and `upstream_nameservers` variables functionality."
298+
default = false
299+
}
295300

296301
variable "deploy_using_private_endpoint" {
297302
type = bool

test/fixtures/simple_regional/example.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ module "example" {
2525
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
2626
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
2727
compute_engine_service_account = var.compute_engine_service_account
28+
skip_provisioners = local.skip_provisioners
2829
}

0 commit comments

Comments
 (0)