Skip to content

Commit

Permalink
Merge pull request #210 from Dev25/gce-labels
Browse files Browse the repository at this point in the history
Add support for cluster resource_labels
  • Loading branch information
morgante committed Jul 22, 2019
2 parents a24f040 + 278e52f commit 3bb39cd
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 41 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Extending the adopted spec, each change should have a link to its corresponding pull request appended.

## [Unreleased]
### Added

* Support for GCE cluster resource_labels. [#210]

## [4.0.0] 2019-07-12

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
| 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 |
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string | `""` | no |
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) | `<map>` | no |
| 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 |
| description | The description of the cluster | string | `""` | no |
| 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 |
Expand Down
9 changes: 5 additions & 4 deletions autogen/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ resource "google_container_cluster" "primary" {
provider = google
{% endif %}

count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

region = var.region
node_locations = coalescelist(
Expand Down
9 changes: 5 additions & 4 deletions autogen/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ resource "google_container_cluster" "zonal_primary" {
provider = google
{% endif %}

count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

zone = var.zones[0]
node_locations = slice(var.zones, 1, length(var.zones))
Expand Down
2 changes: 1 addition & 1 deletion autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ locals {
custom_kube_dns_config = length(keys(var.stub_domains)) > 0
upstream_nameservers_config = length(var.upstream_nameservers) > 0
network_project_id = var.network_project_id != "" ? var.network_project_id : var.project_id
zone_count = length(var.zones)
zone_count = length(var.zones)

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

Expand Down
6 changes: 6 additions & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ variable "cluster_ipv4_cidr" {
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
}

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

{% if private_cluster %}

variable "deploy_using_private_endpoint" {
Expand Down
9 changes: 5 additions & 4 deletions cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
resource "google_container_cluster" "primary" {
provider = google

count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

region = var.region
node_locations = coalescelist(
Expand Down
9 changes: 5 additions & 4 deletions cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
resource "google_container_cluster" "zonal_primary" {
provider = google

count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

zone = var.zones[0]
node_locations = slice(var.zones, 1, length(var.zones))
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 @@ -137,6 +137,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| 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 |
| cloudrun | (Beta) Enable CloudRun addon | string | `"false"` | no |
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string | `""` | no |
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) | `<map>` | no |
| 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 |
| 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 |
| 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 |
Expand Down
9 changes: 5 additions & 4 deletions modules/beta-private-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
resource "google_container_cluster" "primary" {
provider = google-beta

count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

region = var.region
node_locations = coalescelist(
Expand Down
9 changes: 5 additions & 4 deletions modules/beta-private-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
resource "google_container_cluster" "zonal_primary" {
provider = google-beta

count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

zone = var.zones[0]
node_locations = slice(var.zones, 1, length(var.zones))
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ variable "cluster_ipv4_cidr" {
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
}

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


variable "deploy_using_private_endpoint" {
type = bool
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 @@ -132,6 +132,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| 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 |
| cloudrun | (Beta) Enable CloudRun addon | string | `"false"` | no |
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string | `""` | no |
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) | `<map>` | no |
| 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 |
| 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 |
| description | The description of the cluster | string | `""` | no |
Expand Down
9 changes: 5 additions & 4 deletions modules/beta-public-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
resource "google_container_cluster" "primary" {
provider = google-beta

count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

region = var.region
node_locations = coalescelist(
Expand Down
9 changes: 5 additions & 4 deletions modules/beta-public-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
resource "google_container_cluster" "zonal_primary" {
provider = google-beta

count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

zone = var.zones[0]
node_locations = slice(var.zones, 1, length(var.zones))
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ variable "cluster_ipv4_cidr" {
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
}

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


variable "istio" {
description = "(Beta) Enable Istio addon"
Expand Down
1 change: 1 addition & 0 deletions modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
| 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 |
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string | `""` | no |
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) | `<map>` | no |
| 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 |
| 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 |
| description | The description of the cluster | string | `""` | no |
Expand Down
9 changes: 5 additions & 4 deletions modules/private-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
resource "google_container_cluster" "primary" {
provider = google-beta

count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

region = var.region
node_locations = coalescelist(
Expand Down
9 changes: 5 additions & 4 deletions modules/private-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
resource "google_container_cluster" "zonal_primary" {
provider = google-beta

count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
count = var.regional ? 0 : 1
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

zone = var.zones[0]
node_locations = slice(var.zones, 1, length(var.zones))
Expand Down
6 changes: 6 additions & 0 deletions modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ variable "cluster_ipv4_cidr" {
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
}

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


variable "deploy_using_private_endpoint" {
type = bool
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,9 @@ variable "cluster_ipv4_cidr" {
description = "The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR."
}

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

0 comments on commit 3bb39cd

Please sign in to comment.