Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/311-autoscaling_node_count
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Lane authored Nov 11, 2019
2 parents 70688ee + ee90e45 commit c88ba66
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Extending the adopted spec, each change should have a link to its corresponding
### Added

* Support for Shielded Nodes beta feature via `enabled_shielded_nodes` variable. [#300]
* Support for setting node_locations on node pools. [#303]

## [v5.1.1] - 2019-10-25

Expand Down Expand Up @@ -225,6 +226,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
[v0.3.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.2.0...v0.3.0
[v0.2.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.1.0...v0.2.0

[#303]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/303
[#286]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/286
[#285]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/285
[#284]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/284
Expand Down
3 changes: 3 additions & 0 deletions autogen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ module "gke" {
{
name = "default-node-pool"
machine_type = "n1-standard-2"
{% if beta_cluster %}
node_locations = "us-central1-b,us-central1-c"
{% endif %}
min_count = 1
max_count = 100
disk_size_gb = 100
Expand Down
4 changes: 4 additions & 0 deletions autogen/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ resource "google_container_node_pool" "pools" {
{% endif %}
project = var.project_id
location = local.location
{% if beta_cluster %}
// use node_locations if provided, defaults to cluster level node_locations if not specified
node_locations = lookup(var.node_pools[count.index], "node_locations", "") != "" ? split(",", var.node_pools[count.index]["node_locations"]) : google_container_cluster.primary.node_locations
{% endif %}
cluster = google_container_cluster.primary.name
version = lookup(var.node_pools[count.index], "auto_upgrade", false) ? "" : lookup(
var.node_pools[count.index],
Expand Down
7 changes: 5 additions & 2 deletions examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module "gke" {
source = "../../modules/beta-public-cluster/"
project_id = var.project_id
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
regional = false
region = var.region
zones = var.zones
network = var.network
Expand Down Expand Up @@ -61,10 +60,14 @@ module "gke" {
},
{
name = "pool-03"
node_locations = "us-east4-b,us-east4-c"
autoscaling = false
node_count = 2
service_account = var.compute_engine_service_account
machine_type = "n1-standard-2"
disk_type = "pd-standard"
image_type = "COS"
auto_upgrade = true
service_account = var.compute_engine_service_account
},
]

Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module "gke" {
{
name = "default-node-pool"
machine_type = "n1-standard-2"
node_locations = "us-central1-b,us-central1-c"
min_count = 1
max_count = 100
disk_size_gb = 100
Expand Down
4 changes: 3 additions & 1 deletion modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ resource "google_container_node_pool" "pools" {
name = random_id.name.*.hex[count.index]
project = var.project_id
location = local.location
cluster = google_container_cluster.primary.name
// use node_locations if provided, defaults to cluster level node_locations if not specified
node_locations = lookup(var.node_pools[count.index], "node_locations", "") != "" ? split(",", var.node_pools[count.index]["node_locations"]) : google_container_cluster.primary.node_locations
cluster = google_container_cluster.primary.name
version = lookup(var.node_pools[count.index], "auto_upgrade", false) ? "" : lookup(
var.node_pools[count.index],
"version",
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module "gke" {
{
name = "default-node-pool"
machine_type = "n1-standard-2"
node_locations = "us-central1-b,us-central1-c"
min_count = 1
max_count = 100
disk_size_gb = 100
Expand Down
4 changes: 3 additions & 1 deletion modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ resource "google_container_node_pool" "pools" {
name = var.node_pools[count.index]["name"]
project = var.project_id
location = local.location
cluster = google_container_cluster.primary.name
// use node_locations if provided, defaults to cluster level node_locations if not specified
node_locations = lookup(var.node_pools[count.index], "node_locations", "") != "" ? split(",", var.node_pools[count.index]["node_locations"]) : google_container_cluster.primary.node_locations
cluster = google_container_cluster.primary.name
version = lookup(var.node_pools[count.index], "auto_upgrade", false) ? "" : lookup(
var.node_pools[count.index],
"version",
Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module "gke" {
{
name = "default-node-pool"
machine_type = "n1-standard-2"
node_locations = "us-central1-b,us-central1-c"
min_count = 1
max_count = 100
disk_size_gb = 100
Expand Down
4 changes: 3 additions & 1 deletion modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ resource "google_container_node_pool" "pools" {
name = var.node_pools[count.index]["name"]
project = var.project_id
location = local.location
cluster = google_container_cluster.primary.name
// use node_locations if provided, defaults to cluster level node_locations if not specified
node_locations = lookup(var.node_pools[count.index], "node_locations", "") != "" ? split(",", var.node_pools[count.index]["node_locations"]) : google_container_cluster.primary.node_locations
cluster = google_container_cluster.primary.name
version = lookup(var.node_pools[count.index], "auto_upgrade", false) ? "" : lookup(
var.node_pools[count.index],
"version",
Expand Down
25 changes: 25 additions & 0 deletions test/integration/node_pool/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,29 @@
end
end
end

describe command("gcloud beta --project=#{project_id} container clusters --zone=#{location} describe #{cluster_name} --format=json") do
its(:exit_status) { should eq 0 }
its(:stderr) { should eq '' }

let!(:data) do
if subject.exit_status == 0
JSON.parse(subject.stdout)
else
{}
end
end

it "pool-03 has nodes in correct locations" do
expect(data['nodePools']).to include(
including(
"name" => "pool-03",
"locations" => match_array([
"us-east4-b",
"us-east4-c",
]),
)
)
end
end
end

0 comments on commit c88ba66

Please sign in to comment.