Skip to content

Commit

Permalink
Fix node_count when autoscaling disabled on node pool. Fixes terrafor…
Browse files Browse the repository at this point in the history
…m-google-modules#311

Dont set initial_node_count when autoscaling is disabled on node pool.
Use new node pool var  when setting desired size of pool - matches provider var
  • Loading branch information
taylorludwig committed Nov 9, 2019
1 parent 1690c85 commit eb2bb96
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 28 deletions.
10 changes: 6 additions & 4 deletions autogen/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,18 @@ resource "google_container_node_pool" "pools" {
"version",
local.node_version,
)
initial_node_count = lookup(

initial_node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? lookup(
var.node_pools[count.index],
"initial_node_count",
lookup(var.node_pools[count.index], "min_count", 1),
)
lookup(var.node_pools[count.index], "min_count", 1)
) : null

{% if beta_cluster %}
max_pods_per_node = lookup(var.node_pools[count.index], "max_pods_per_node", null)
{% endif %}

node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "min_count", 1)
node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "node_count", 1)

dynamic "autoscaling" {
for_each = lookup(var.node_pools[count.index], "autoscaling", true) ? [var.node_pools[count.index]] : []
Expand Down
10 changes: 6 additions & 4 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ resource "google_container_node_pool" "pools" {
"version",
local.node_version,
)
initial_node_count = lookup(

initial_node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? lookup(
var.node_pools[count.index],
"initial_node_count",
lookup(var.node_pools[count.index], "min_count", 1),
)
lookup(var.node_pools[count.index], "min_count", 1)
) : null


node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "min_count", 1)
node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "node_count", 1)

dynamic "autoscaling" {
for_each = lookup(var.node_pools[count.index], "autoscaling", true) ? [var.node_pools[count.index]] : []
Expand Down
10 changes: 6 additions & 4 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,16 @@ resource "google_container_node_pool" "pools" {
"version",
local.node_version,
)
initial_node_count = lookup(

initial_node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? lookup(
var.node_pools[count.index],
"initial_node_count",
lookup(var.node_pools[count.index], "min_count", 1),
)
lookup(var.node_pools[count.index], "min_count", 1)
) : null

max_pods_per_node = lookup(var.node_pools[count.index], "max_pods_per_node", null)

node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "min_count", 1)
node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "node_count", 1)

dynamic "autoscaling" {
for_each = lookup(var.node_pools[count.index], "autoscaling", true) ? [var.node_pools[count.index]] : []
Expand Down
10 changes: 6 additions & 4 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,16 @@ resource "google_container_node_pool" "pools" {
"version",
local.node_version,
)
initial_node_count = lookup(

initial_node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? lookup(
var.node_pools[count.index],
"initial_node_count",
lookup(var.node_pools[count.index], "min_count", 1),
)
lookup(var.node_pools[count.index], "min_count", 1)
) : null

max_pods_per_node = lookup(var.node_pools[count.index], "max_pods_per_node", null)

node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "min_count", 1)
node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "node_count", 1)

dynamic "autoscaling" {
for_each = lookup(var.node_pools[count.index], "autoscaling", true) ? [var.node_pools[count.index]] : []
Expand Down
10 changes: 6 additions & 4 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,16 @@ resource "google_container_node_pool" "pools" {
"version",
local.node_version,
)
initial_node_count = lookup(

initial_node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? lookup(
var.node_pools[count.index],
"initial_node_count",
lookup(var.node_pools[count.index], "min_count", 1),
)
lookup(var.node_pools[count.index], "min_count", 1)
) : null

max_pods_per_node = lookup(var.node_pools[count.index], "max_pods_per_node", null)

node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "min_count", 1)
node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "node_count", 1)

dynamic "autoscaling" {
for_each = lookup(var.node_pools[count.index], "autoscaling", true) ? [var.node_pools[count.index]] : []
Expand Down
10 changes: 6 additions & 4 deletions modules/private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,15 @@ resource "google_container_node_pool" "pools" {
"version",
local.node_version,
)
initial_node_count = lookup(

initial_node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? lookup(
var.node_pools[count.index],
"initial_node_count",
lookup(var.node_pools[count.index], "min_count", 1),
)
lookup(var.node_pools[count.index], "min_count", 1)
) : null


node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "min_count", 1)
node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "node_count", 1)

dynamic "autoscaling" {
for_each = lookup(var.node_pools[count.index], "autoscaling", true) ? [var.node_pools[count.index]] : []
Expand Down
10 changes: 6 additions & 4 deletions modules/private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@ resource "google_container_node_pool" "pools" {
"version",
local.node_version,
)
initial_node_count = lookup(

initial_node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? lookup(
var.node_pools[count.index],
"initial_node_count",
lookup(var.node_pools[count.index], "min_count", 1),
)
lookup(var.node_pools[count.index], "min_count", 1)
) : null


node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "min_count", 1)
node_count = lookup(var.node_pools[count.index], "autoscaling", true) ? null : lookup(var.node_pools[count.index], "node_count", 1)

dynamic "autoscaling" {
for_each = lookup(var.node_pools[count.index], "autoscaling", true) ? [var.node_pools[count.index]] : []
Expand Down

0 comments on commit eb2bb96

Please sign in to comment.