Skip to content

Commit 8ec5679

Browse files
author
Rishi Malik
committed
Merge branch 'issue_43' of github.com:ogreface/terraform-google-kubernetes-engine into issue_43
2 parents 8427c3c + a62416e commit 8ec5679

File tree

25 files changed

+75
-21
lines changed

25 files changed

+75
-21
lines changed

.kitchen.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ suites:
3131
root_module_directory: test/fixtures/deploy_service
3232
verifier:
3333
name: terraform
34+
color: false
3435
systems:
3536
- name: deploy_service
3637
backend: local
@@ -43,6 +44,7 @@ suites:
4344
root_module_directory: test/fixtures/node_pool
4445
verifier:
4546
name: terraform
47+
color: false
4648
systems:
4749
- name: node_pool
4850
backend: local
@@ -55,6 +57,7 @@ suites:
5557
root_module_directory: test/fixtures/shared_vpc
5658
verifier:
5759
name: terraform
60+
color: false
5861
systems:
5962
- name: shared_vpc
6063
backend: local
@@ -67,6 +70,7 @@ suites:
6770
root_module_directory: test/fixtures/simple_regional
6871
verifier:
6972
name: terraform
73+
color: false
7074
systems:
7175
- name: simple_regional
7276
backend: local
@@ -79,6 +83,7 @@ suites:
7983
root_module_directory: test/fixtures/simple_zonal
8084
verifier:
8185
name: terraform
86+
color: false
8287
systems:
8388
- name: simple_zonal
8489
backend: local
@@ -91,6 +96,7 @@ suites:
9196
root_module_directory: test/fixtures/stub_domains
9297
verifier:
9398
name: terraform
99+
color: false
94100
systems:
95101
- name: stub_domains
96102
backend: local

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
88
## [Unreleased]
99
### Changed
1010
* Set `horizontal_pod_autoscaling` to `true` by default. #42
11+
* Add `remove_default_node_pool` set to `false` by default #15
1112

1213
## [v0.4.0] - 2018-12-19
1314
### Added

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Then perform the following commands on the root folder:
106106
| network | The VPC network to host the cluster in (required) | string | - | yes |
107107
| network_policy | Enable network policy addon | string | `false` | no |
108108
| network_project_id | The project ID of the shared VPC's host (for shared vpc support) | string | `` | no |
109+
| remove_default_node_pool | Boolean value determining removal of default node pool | bool | false | no |
109110
| node_pools | List of maps containing node pools | list | `<list>` | no |
110111
| node_pools_labels | Map of maps containing node labels by node-pool name | map | `<map>` | no |
111112
| node_pools_tags | Map of lists containing node network tags by node-pool name | map | `<map>` | no |

cluster_regional.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ resource "google_container_cluster" "primary" {
2626
region = "${var.region}"
2727
additional_zones = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"]
2828

29-
network = "${data.google_compute_network.gke_network.self_link}"
30-
subnetwork = "${data.google_compute_subnetwork.gke_subnetwork.self_link}"
29+
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
30+
subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}"
3131
min_master_version = "${local.kubernetes_version}"
3232

3333
logging_service = "${var.logging_service}"
@@ -81,6 +81,8 @@ resource "google_container_cluster" "primary" {
8181
service_account = "${lookup(var.node_pools[0], "service_account", var.service_account)}"
8282
}
8383
}
84+
85+
remove_default_node_pool = "${var.remove_default_node_pool}"
8486
}
8587

8688
/******************************************
@@ -110,7 +112,7 @@ resource "google_container_node_pool" "pools" {
110112
machine_type = "${lookup(var.node_pools[count.index], "machine_type", "n1-standard-2")}"
111113
labels = "${merge(map("cluster_name", var.name), map("node_pool", lookup(var.node_pools[count.index], "name")), var.node_pools_labels["all"], var.node_pools_labels[lookup(var.node_pools[count.index], "name")])}"
112114
taint = "${concat(var.node_pools_taints["all"], var.node_pools_taints[lookup(var.node_pools[count.index], "name")])}"
113-
tags = "${concat(list("gke-${var.name}"), list("gke-${var.name}-${lookup(var.node_pools[count.index], "name")}"), var.node_pools_tags["all"], var.node_pools_tags[lookup(var.node_pools[count.index], "name")])}"
115+
tags = ["${concat(list("gke-${var.name}"), list("gke-${var.name}-${lookup(var.node_pools[count.index], "name")}"), var.node_pools_tags["all"], var.node_pools_tags[lookup(var.node_pools[count.index], "name")])}"]
114116

115117
disk_size_gb = "${lookup(var.node_pools[count.index], "disk_size_gb", 100)}"
116118
disk_type = "${lookup(var.node_pools[count.index], "disk_type", "pd-standard")}"

cluster_zonal.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ resource "google_container_cluster" "zonal_primary" {
2626
zone = "${var.zones[0]}"
2727
additional_zones = ["${slice(var.zones,1,length(var.zones))}"]
2828

29-
network = "${data.google_compute_network.gke_network.self_link}"
30-
subnetwork = "${data.google_compute_subnetwork.gke_subnetwork.self_link}"
29+
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
30+
subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}"
3131
min_master_version = "${local.kubernetes_version}"
3232

3333
logging_service = "${var.logging_service}"
@@ -81,6 +81,8 @@ resource "google_container_cluster" "zonal_primary" {
8181
service_account = "${lookup(var.node_pools[0], "service_account", var.service_account)}"
8282
}
8383
}
84+
85+
remove_default_node_pool = "${var.remove_default_node_pool}"
8486
}
8587

8688
/******************************************
@@ -110,7 +112,7 @@ resource "google_container_node_pool" "zonal_pools" {
110112
machine_type = "${lookup(var.node_pools[count.index], "machine_type", "n1-standard-2")}"
111113
labels = "${merge(map("cluster_name", var.name), map("node_pool", lookup(var.node_pools[count.index], "name")), var.node_pools_labels["all"], var.node_pools_labels[lookup(var.node_pools[count.index], "name")])}"
112114
taint = "${concat(var.node_pools_taints["all"], var.node_pools_taints[lookup(var.node_pools[count.index], "name")])}"
113-
tags = "${concat(list("gke-${var.name}"), list("gke-${var.name}-${lookup(var.node_pools[count.index], "name")}"), var.node_pools_tags["all"], var.node_pools_tags[lookup(var.node_pools[count.index], "name")])}"
115+
tags = ["${concat(list("gke-${var.name}"), list("gke-${var.name}-${lookup(var.node_pools[count.index], "name")}"), var.node_pools_tags["all"], var.node_pools_tags[lookup(var.node_pools[count.index], "name")])}"]
114116

115117
disk_size_gb = "${lookup(var.node_pools[count.index], "disk_size_gb", 100)}"
116118
disk_type = "${lookup(var.node_pools[count.index], "disk_type", "pd-standard")}"

examples/deploy_service/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ provider "kubernetes" {
3333
data "google_client_config" "default" {}
3434

3535
module "gke" {
36-
source = "../../"
37-
project_id = "${var.project_id}"
38-
name = "${local.cluster_type}-cluster"
39-
region = "${var.region}"
40-
network = "${var.network}"
41-
subnetwork = "${var.subnetwork}"
36+
source = "../../"
37+
project_id = "${var.project_id}"
38+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
39+
region = "${var.region}"
40+
network = "${var.network}"
41+
subnetwork = "${var.subnetwork}"
42+
4243
ip_range_pods = "${var.ip_range_pods}"
4344
ip_range_services = "${var.ip_range_services}"
4445
kubernetes_version = "1.11.5-gke.4"

examples/deploy_service/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ variable "credentials_path" {
2222
description = "The path to the GCP credentials JSON file"
2323
}
2424

25+
variable "cluster_name_suffix" {
26+
description = "A suffix to append to the default cluster name"
27+
default = ""
28+
}
29+
2530
variable "region" {
2631
description = "The region to host the cluster in"
2732
}

examples/node_pool/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ provider "google" {
2626
module "gke" {
2727
source = "../../"
2828
project_id = "${var.project_id}"
29-
name = "${local.cluster_type}-cluster"
29+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
3030
region = "${var.region}"
3131
network = "${var.network}"
3232
subnetwork = "${var.subnetwork}"

examples/node_pool/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ variable "credentials_path" {
2222
description = "The path to the GCP credentials JSON file"
2323
}
2424

25+
variable "cluster_name_suffix" {
26+
description = "A suffix to append to the default cluster name"
27+
default = ""
28+
}
29+
2530
variable "region" {
2631
description = "The region to host the cluster in"
2732
}

examples/shared_vpc/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ provider "google" {
2626
module "gke" {
2727
source = "../../"
2828
project_id = "${var.project_id}"
29-
name = "${local.cluster_type}-cluster"
29+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
3030
region = "${var.region}"
3131
network = "${var.network}"
3232
network_project_id = "${var.network_project_id}"

examples/shared_vpc/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ variable "credentials_path" {
2222
description = "The path to the GCP credentials JSON file"
2323
}
2424

25+
variable "cluster_name_suffix" {
26+
description = "A suffix to append to the default cluster name"
27+
default = ""
28+
}
29+
2530
variable "region" {
2631
description = "The region to host the cluster in"
2732
}

examples/simple_regional/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ provider "google" {
2626
module "gke" {
2727
source = "../../"
2828
project_id = "${var.project_id}"
29-
name = "${local.cluster_type}-cluster"
29+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
3030
regional = true
3131
region = "${var.region}"
3232
network = "${var.network}"

examples/simple_regional/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ variable "credentials_path" {
2222
description = "The path to the GCP credentials JSON file"
2323
}
2424

25+
variable "cluster_name_suffix" {
26+
description = "A suffix to append to the default cluster name"
27+
default = ""
28+
}
29+
2530
variable "region" {
2631
description = "The region to host the cluster in"
2732
}

examples/simple_zonal/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ provider "google" {
2626
module "gke" {
2727
source = "../../"
2828
project_id = "${var.project_id}"
29-
name = "${local.cluster_type}-cluster"
29+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
3030
regional = false
3131
region = "${var.region}"
3232
zones = "${var.zones}"

examples/simple_zonal/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ variable "credentials_path" {
2222
description = "The path to the GCP credentials JSON file"
2323
}
2424

25+
variable "cluster_name_suffix" {
26+
description = "A suffix to append to the default cluster name"
27+
default = ""
28+
}
29+
2530
variable "region" {
2631
description = "The region to host the cluster in"
2732
}

examples/stub_domains/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ provider "google" {
2626
module "gke" {
2727
source = "../../"
2828
project_id = "${var.project_id}"
29-
name = "${local.cluster_type}-cluster"
29+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
3030
region = "${var.region}"
3131
network = "${var.network}"
3232
subnetwork = "${var.subnetwork}"

examples/stub_domains/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ variable "credentials_path" {
2222
description = "The path to the GCP credentials JSON file"
2323
}
2424

25+
variable "cluster_name_suffix" {
26+
description = "A suffix to append to the default cluster name"
27+
default = ""
28+
}
29+
2530
variable "region" {
2631
description = "The region to host the cluster in"
2732
}

test/fixtures/deploy_service/example.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module "example" {
1919

2020
project_id = "${var.project_id}"
2121
credentials_path = "${local.credentials_path}"
22+
cluster_name_suffix = "-${random_string.suffix.result}"
2223
region = "${var.region}"
2324
network = "${google_compute_network.main.name}"
2425
subnetwork = "${google_compute_subnetwork.main.name}"

test/fixtures/node_pool/example.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module "example" {
1919

2020
project_id = "${var.project_id}"
2121
credentials_path = "${local.credentials_path}"
22+
cluster_name_suffix = "-${random_string.suffix.result}"
2223
region = "${var.region}"
2324
network = "${google_compute_network.main.name}"
2425
subnetwork = "${google_compute_subnetwork.main.name}"

test/fixtures/shared_vpc/example.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module "example" {
1919

2020
project_id = "${var.project_id}"
2121
credentials_path = "${local.credentials_path}"
22+
cluster_name_suffix = "-${random_string.suffix.result}"
2223
region = "${var.region}"
2324
network = "${google_compute_network.main.name}"
2425
network_project_id = "${var.project_id}"

test/fixtures/simple_regional/example.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module "example" {
1919

2020
project_id = "${var.project_id}"
2121
credentials_path = "${local.credentials_path}"
22+
cluster_name_suffix = "-${random_string.suffix.result}"
2223
region = "${var.region}"
2324
network = "${google_compute_network.main.name}"
2425
subnetwork = "${google_compute_subnetwork.main.name}"

test/fixtures/simple_zonal/example.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module "example" {
1919

2020
project_id = "${var.project_id}"
2121
credentials_path = "${local.credentials_path}"
22+
cluster_name_suffix = "-${random_string.suffix.result}"
2223
region = "${var.region}"
2324
zones = ["${slice(var.zones,0,1)}"]
2425
network = "${google_compute_network.main.name}"

test/fixtures/stub_domains/example.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module "example" {
1919

2020
project_id = "${var.project_id}"
2121
credentials_path = "${local.credentials_path}"
22+
cluster_name_suffix = "-${random_string.suffix.result}"
2223
region = "${var.region}"
2324
network = "${google_compute_network.main.name}"
2425
subnetwork = "${google_compute_subnetwork.main.name}"

test/integration/node_pool/controls/gcloud.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@
128128
"tags" => match_array([
129129
"all-node-example",
130130
"pool-01-example",
131-
"gke-node-pool-cluster",
132-
"gke-node-pool-cluster-pool-01",
131+
"gke-#{cluster_name}",
132+
"gke-#{cluster_name}-pool-01",
133133
]),
134134
),
135135
)
@@ -245,8 +245,8 @@
245245
"config" => including(
246246
"tags" => match_array([
247247
"all-node-example",
248-
"gke-node-pool-cluster",
249-
"gke-node-pool-cluster-pool-02",
248+
"gke-#{cluster_name}",
249+
"gke-#{cluster_name}-pool-02",
250250
])
251251
),
252252
)

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ variable "ip_range_services" {
117117
description = "The secondary ip range to use for pods"
118118
}
119119

120+
variable "remove_default_node_pool" {
121+
description = "Remove default node pool while setting up the cluster"
122+
default = false
123+
}
124+
120125
variable "node_pools" {
121126
type = "list"
122127
description = "List of maps containing node pools"

0 commit comments

Comments
 (0)