Skip to content

Commit 3bb39cd

Browse files
authored
Merge pull request terraform-google-modules#210 from Dev25/gce-labels
Add support for cluster resource_labels
2 parents a24f040 + 278e52f commit 3bb39cd

21 files changed

+88
-41
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
Extending the adopted spec, each change should have a link to its corresponding pull request appended.
88

99
## [Unreleased]
10+
### Added
11+
12+
* Support for GCE cluster resource_labels. [#210]
1013

1114
## [4.0.0] 2019-07-12
1215

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
129129
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
130130
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | string | `""` | no |
131131
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string | `""` | no |
132+
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) | `<map>` | no |
132133
| configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | string | `"false"` | no |
133134
| description | The description of the cluster | string | `""` | no |
134135
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | bool | `"true"` | no |

autogen/cluster_regional.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ resource "google_container_cluster" "primary" {
2626
provider = google
2727
{% endif %}
2828

29-
count = var.regional ? 1 : 0
30-
name = var.name
31-
description = var.description
32-
project = var.project_id
29+
count = var.regional ? 1 : 0
30+
name = var.name
31+
description = var.description
32+
project = var.project_id
33+
resource_labels = var.cluster_resource_labels
3334

3435
region = var.region
3536
node_locations = coalescelist(

autogen/cluster_zonal.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ resource "google_container_cluster" "zonal_primary" {
2626
provider = google
2727
{% endif %}
2828

29-
count = var.regional ? 0 : 1
30-
name = var.name
31-
description = var.description
32-
project = var.project_id
29+
count = var.regional ? 0 : 1
30+
name = var.name
31+
description = var.description
32+
project = var.project_id
33+
resource_labels = var.cluster_resource_labels
3334

3435
zone = var.zones[0]
3536
node_locations = slice(var.zones, 1, length(var.zones))

autogen/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ locals {
4343
custom_kube_dns_config = length(keys(var.stub_domains)) > 0
4444
upstream_nameservers_config = length(var.upstream_nameservers) > 0
4545
network_project_id = var.network_project_id != "" ? var.network_project_id : var.project_id
46-
zone_count = length(var.zones)
46+
zone_count = length(var.zones)
4747

4848
cluster_type = var.regional ? "regional" : "zonal"
4949

autogen/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ variable "cluster_ipv4_cidr" {
284284
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
285285
}
286286

287+
variable "cluster_resource_labels" {
288+
type = map(string)
289+
description = "The GCE resource labels (a map of key/value pairs) to be applied to the cluster"
290+
default = {}
291+
}
292+
287293
{% if private_cluster %}
288294

289295
variable "deploy_using_private_endpoint" {

cluster_regional.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
resource "google_container_cluster" "primary" {
2323
provider = google
2424

25-
count = var.regional ? 1 : 0
26-
name = var.name
27-
description = var.description
28-
project = var.project_id
25+
count = var.regional ? 1 : 0
26+
name = var.name
27+
description = var.description
28+
project = var.project_id
29+
resource_labels = var.cluster_resource_labels
2930

3031
region = var.region
3132
node_locations = coalescelist(

cluster_zonal.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
resource "google_container_cluster" "zonal_primary" {
2323
provider = google
2424

25-
count = var.regional ? 0 : 1
26-
name = var.name
27-
description = var.description
28-
project = var.project_id
25+
count = var.regional ? 0 : 1
26+
name = var.name
27+
description = var.description
28+
project = var.project_id
29+
resource_labels = var.cluster_resource_labels
2930

3031
zone = var.zones[0]
3132
node_locations = slice(var.zones, 1, length(var.zones))

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
137137
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | string | `""` | no |
138138
| cloudrun | (Beta) Enable CloudRun addon | string | `"false"` | no |
139139
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string | `""` | no |
140+
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) | `<map>` | no |
140141
| configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | string | `"false"` | no |
141142
| database\_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | object | `<list>` | no |
142143
| deploy\_using\_private\_endpoint | (Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | bool | `"false"` | no |

modules/beta-private-cluster/cluster_regional.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
resource "google_container_cluster" "primary" {
2323
provider = google-beta
2424

25-
count = var.regional ? 1 : 0
26-
name = var.name
27-
description = var.description
28-
project = var.project_id
25+
count = var.regional ? 1 : 0
26+
name = var.name
27+
description = var.description
28+
project = var.project_id
29+
resource_labels = var.cluster_resource_labels
2930

3031
region = var.region
3132
node_locations = coalescelist(

modules/beta-private-cluster/cluster_zonal.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
resource "google_container_cluster" "zonal_primary" {
2323
provider = google-beta
2424

25-
count = var.regional ? 0 : 1
26-
name = var.name
27-
description = var.description
28-
project = var.project_id
25+
count = var.regional ? 0 : 1
26+
name = var.name
27+
description = var.description
28+
project = var.project_id
29+
resource_labels = var.cluster_resource_labels
2930

3031
zone = var.zones[0]
3132
node_locations = slice(var.zones, 1, length(var.zones))

modules/beta-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ variable "cluster_ipv4_cidr" {
284284
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
285285
}
286286

287+
variable "cluster_resource_labels" {
288+
type = map(string)
289+
description = "The GCE resource labels (a map of key/value pairs) to be applied to the cluster"
290+
default = {}
291+
}
292+
287293

288294
variable "deploy_using_private_endpoint" {
289295
type = bool

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
132132
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | string | `""` | no |
133133
| cloudrun | (Beta) Enable CloudRun addon | string | `"false"` | no |
134134
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string | `""` | no |
135+
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) | `<map>` | no |
135136
| configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | string | `"false"` | no |
136137
| database\_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | object | `<list>` | no |
137138
| description | The description of the cluster | string | `""` | no |

modules/beta-public-cluster/cluster_regional.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
resource "google_container_cluster" "primary" {
2323
provider = google-beta
2424

25-
count = var.regional ? 1 : 0
26-
name = var.name
27-
description = var.description
28-
project = var.project_id
25+
count = var.regional ? 1 : 0
26+
name = var.name
27+
description = var.description
28+
project = var.project_id
29+
resource_labels = var.cluster_resource_labels
2930

3031
region = var.region
3132
node_locations = coalescelist(

modules/beta-public-cluster/cluster_zonal.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
resource "google_container_cluster" "zonal_primary" {
2323
provider = google-beta
2424

25-
count = var.regional ? 0 : 1
26-
name = var.name
27-
description = var.description
28-
project = var.project_id
25+
count = var.regional ? 0 : 1
26+
name = var.name
27+
description = var.description
28+
project = var.project_id
29+
resource_labels = var.cluster_resource_labels
2930

3031
zone = var.zones[0]
3132
node_locations = slice(var.zones, 1, length(var.zones))

modules/beta-public-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ variable "cluster_ipv4_cidr" {
284284
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
285285
}
286286

287+
variable "cluster_resource_labels" {
288+
type = map(string)
289+
description = "The GCE resource labels (a map of key/value pairs) to be applied to the cluster"
290+
default = {}
291+
}
292+
287293

288294
variable "istio" {
289295
description = "(Beta) Enable Istio addon"

modules/private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
134134
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
135135
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | string | `""` | no |
136136
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string | `""` | no |
137+
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) | `<map>` | no |
137138
| configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | string | `"false"` | no |
138139
| deploy\_using\_private\_endpoint | (Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | bool | `"false"` | no |
139140
| description | The description of the cluster | string | `""` | no |

modules/private-cluster/cluster_regional.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
resource "google_container_cluster" "primary" {
2323
provider = google-beta
2424

25-
count = var.regional ? 1 : 0
26-
name = var.name
27-
description = var.description
28-
project = var.project_id
25+
count = var.regional ? 1 : 0
26+
name = var.name
27+
description = var.description
28+
project = var.project_id
29+
resource_labels = var.cluster_resource_labels
2930

3031
region = var.region
3132
node_locations = coalescelist(

modules/private-cluster/cluster_zonal.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
resource "google_container_cluster" "zonal_primary" {
2323
provider = google-beta
2424

25-
count = var.regional ? 0 : 1
26-
name = var.name
27-
description = var.description
28-
project = var.project_id
25+
count = var.regional ? 0 : 1
26+
name = var.name
27+
description = var.description
28+
project = var.project_id
29+
resource_labels = var.cluster_resource_labels
2930

3031
zone = var.zones[0]
3132
node_locations = slice(var.zones, 1, length(var.zones))

modules/private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ variable "cluster_ipv4_cidr" {
284284
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
285285
}
286286

287+
variable "cluster_resource_labels" {
288+
type = map(string)
289+
description = "The GCE resource labels (a map of key/value pairs) to be applied to the cluster"
290+
default = {}
291+
}
292+
287293

288294
variable "deploy_using_private_endpoint" {
289295
type = bool

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,9 @@ variable "cluster_ipv4_cidr" {
284284
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
285285
}
286286

287+
variable "cluster_resource_labels" {
288+
type = map(string)
289+
description = "The GCE resource labels (a map of key/value pairs) to be applied to the cluster"
290+
default = {}
291+
}
292+

0 commit comments

Comments
 (0)