Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Add option to pass resource_labels to NP #1508

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ Then perform the following commands on the root folder:
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | `map(list(string))` | <pre>{<br> "all": [<br> "https://www.googleapis.com/auth/cloud-platform"<br> ],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_resource\_labels | Map of maps containing resource labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
Expand Down
4 changes: 4 additions & 0 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,10 @@ resource "google_container_node_pool" "windows_pools" {
local.node_pools_labels["all"],
local.node_pools_labels[each.value["name"]],
)
resource_labels = merge(
local.node_pools_resource_labels["all"],
local.node_pools_resource_labels[each.value["name"]],
)
metadata = merge(
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
Expand Down
10 changes: 10 additions & 0 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ variable "node_pools_labels" {
}
}

variable "node_pools_resource_labels" {
type = map(map(string))
description = "Map of maps containing resource labels by node-pool name"

default = {
all = {}
default-node-pool = {}
}
}

variable "node_pools_metadata" {
type = map(map(string))
description = "Map of maps containing node metadata by node-pool name"
Expand Down
14 changes: 14 additions & 0 deletions autogen/main/variables_defaults.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ locals {
var.node_pools_labels
)

node_pools_resource_labels = merge(
{ all = {} },
{ default-node-pool = {} },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : {}]
),
zipmap(
[for node_pool in var.windows_node_pools : node_pool["name"]],
[for node_pool in var.windows_node_pools : {}]
),
var.node_pools_resource_labels
)

node_pools_metadata = merge(
{ all = {} },
{ default-node-pool = {} },
Expand Down
4 changes: 2 additions & 2 deletions autogen/main/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.44.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand All @@ -38,7 +38,7 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.44.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
13 changes: 7 additions & 6 deletions autogen/safer-cluster/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ module "gke" {
// If removing the default node pool, initial_node_count should be at least 1.
initial_node_count = (var.initial_node_count == 0) ? 1 : var.initial_node_count

node_pools = var.node_pools
windows_node_pools = var.windows_node_pools
node_pools_labels = var.node_pools_labels
node_pools_metadata = var.node_pools_metadata
node_pools_taints = var.node_pools_taints
node_pools_tags = var.node_pools_tags
node_pools = var.node_pools
windows_node_pools = var.windows_node_pools
node_pools_labels = var.node_pools_labels
node_pools_resource_labels = var.node_pools_resource_labels
node_pools_metadata = var.node_pools_metadata
node_pools_taints = var.node_pools_taints
node_pools_tags = var.node_pools_tags

node_pools_oauth_scopes = var.node_pools_oauth_scopes

Expand Down
10 changes: 10 additions & 0 deletions autogen/safer-cluster/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ variable "node_pools_labels" {
}
}

variable "node_pools_resource_labels" {
type = map(map(string))
description = "Map of maps containing resource labels by node-pool name"

default = {
all = {}
default-node-pool = {}
}
}

variable "node_pools_metadata" {
type = map(map(string))
description = "Map of maps containing node metadata by node-pool name"
Expand Down
8 changes: 8 additions & 0 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ resource "google_container_node_pool" "pools" {
local.node_pools_labels["all"],
local.node_pools_labels[each.value["name"]],
)
resource_labels = merge(
local.node_pools_resource_labels["all"],
local.node_pools_resource_labels[each.value["name"]],
)
metadata = merge(
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
Expand Down Expand Up @@ -531,6 +535,10 @@ resource "google_container_node_pool" "windows_pools" {
local.node_pools_labels["all"],
local.node_pools_labels[each.value["name"]],
)
resource_labels = merge(
local.node_pools_resource_labels["all"],
local.node_pools_resource_labels[each.value["name"]],
)
metadata = merge(
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-autopilot-private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.44.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-autopilot-public-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.44.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
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 @@ -240,6 +240,7 @@ Then perform the following commands on the root folder:
| node\_pools\_linux\_node\_configs\_sysctls | Map of maps containing linux node config sysctls by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | `map(list(string))` | <pre>{<br> "all": [<br> "https://www.googleapis.com/auth/cloud-platform"<br> ],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_resource\_labels | Map of maps containing resource labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
Expand Down
8 changes: 8 additions & 0 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ resource "google_container_node_pool" "pools" {
local.node_pools_labels["all"],
local.node_pools_labels[each.value["name"]],
)
resource_labels = merge(
local.node_pools_resource_labels["all"],
local.node_pools_resource_labels[each.value["name"]],
)
metadata = merge(
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
Expand Down Expand Up @@ -812,6 +816,10 @@ resource "google_container_node_pool" "windows_pools" {
local.node_pools_labels["all"],
local.node_pools_labels[each.value["name"]],
)
resource_labels = merge(
local.node_pools_resource_labels["all"],
local.node_pools_resource_labels[each.value["name"]],
)
metadata = merge(
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
Expand Down
10 changes: 10 additions & 0 deletions modules/beta-private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ variable "node_pools_labels" {
}
}

variable "node_pools_resource_labels" {
type = map(map(string))
description = "Map of maps containing resource labels by node-pool name"

default = {
all = {}
default-node-pool = {}
}
}

variable "node_pools_metadata" {
type = map(map(string))
description = "Map of maps containing node metadata by node-pool name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ locals {
var.node_pools_labels
)

node_pools_resource_labels = merge(
{ all = {} },
{ default-node-pool = {} },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : {}]
),
zipmap(
[for node_pool in var.windows_node_pools : node_pool["name"]],
[for node_pool in var.windows_node_pools : {}]
),
var.node_pools_resource_labels
)

node_pools_metadata = merge(
{ all = {} },
{ default-node-pool = {} },
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.44.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
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 @@ -218,6 +218,7 @@ Then perform the following commands on the root folder:
| node\_pools\_linux\_node\_configs\_sysctls | Map of maps containing linux node config sysctls by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | `map(list(string))` | <pre>{<br> "all": [<br> "https://www.googleapis.com/auth/cloud-platform"<br> ],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_resource\_labels | Map of maps containing resource labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
Expand Down
8 changes: 8 additions & 0 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,10 @@ resource "google_container_node_pool" "pools" {
local.node_pools_labels["all"],
local.node_pools_labels[each.value["name"]],
)
resource_labels = merge(
local.node_pools_resource_labels["all"],
local.node_pools_resource_labels[each.value["name"]],
)
metadata = merge(
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
Expand Down Expand Up @@ -717,6 +721,10 @@ resource "google_container_node_pool" "windows_pools" {
local.node_pools_labels["all"],
local.node_pools_labels[each.value["name"]],
)
resource_labels = merge(
local.node_pools_resource_labels["all"],
local.node_pools_resource_labels[each.value["name"]],
)
metadata = merge(
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
Expand Down
10 changes: 10 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ variable "node_pools_labels" {
}
}

variable "node_pools_resource_labels" {
type = map(map(string))
description = "Map of maps containing resource labels by node-pool name"

default = {
all = {}
default-node-pool = {}
}
}

variable "node_pools_metadata" {
type = map(map(string))
description = "Map of maps containing node metadata by node-pool name"
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-private-cluster/variables_defaults.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ locals {
var.node_pools_labels
)

node_pools_resource_labels = merge(
{ all = {} },
{ default-node-pool = {} },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : {}]
),
zipmap(
[for node_pool in var.windows_node_pools : node_pool["name"]],
[for node_pool in var.windows_node_pools : {}]
),
var.node_pools_resource_labels
)

node_pools_metadata = merge(
{ all = {} },
{ default-node-pool = {} },
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.44.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ Then perform the following commands on the root folder:
| node\_pools\_linux\_node\_configs\_sysctls | Map of maps containing linux node config sysctls by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | `map(list(string))` | <pre>{<br> "all": [<br> "https://www.googleapis.com/auth/cloud-platform"<br> ],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_resource\_labels | Map of maps containing resource labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
Expand Down
8 changes: 8 additions & 0 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@ resource "google_container_node_pool" "pools" {
local.node_pools_labels["all"],
local.node_pools_labels[each.value["name"]],
)
resource_labels = merge(
local.node_pools_resource_labels["all"],
local.node_pools_resource_labels[each.value["name"]],
)
metadata = merge(
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
Expand Down Expand Up @@ -793,6 +797,10 @@ resource "google_container_node_pool" "windows_pools" {
local.node_pools_labels["all"],
local.node_pools_labels[each.value["name"]],
)
resource_labels = merge(
local.node_pools_resource_labels["all"],
local.node_pools_resource_labels[each.value["name"]],
)
metadata = merge(
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
Expand Down
10 changes: 10 additions & 0 deletions modules/beta-public-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ variable "node_pools_labels" {
}
}

variable "node_pools_resource_labels" {
type = map(map(string))
description = "Map of maps containing resource labels by node-pool name"

default = {
all = {}
default-node-pool = {}
}
}

variable "node_pools_metadata" {
type = map(map(string))
description = "Map of maps containing node metadata by node-pool name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ locals {
var.node_pools_labels
)

node_pools_resource_labels = merge(
{ all = {} },
{ default-node-pool = {} },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : {}]
),
zipmap(
[for node_pool in var.windows_node_pools : node_pool["name"]],
[for node_pool in var.windows_node_pools : {}]
),
var.node_pools_resource_labels
)

node_pools_metadata = merge(
{ all = {} },
{ default-node-pool = {} },
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.44.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
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 @@ -207,6 +207,7 @@ Then perform the following commands on the root folder:
| node\_pools\_linux\_node\_configs\_sysctls | Map of maps containing linux node config sysctls by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | `map(list(string))` | <pre>{<br> "all": [<br> "https://www.googleapis.com/auth/cloud-platform"<br> ],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_resource\_labels | Map of maps containing resource labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
Expand Down
Loading