Skip to content

feat!: add service_externalips option, and add default for autoscaling location_policy #1440

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

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
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 @@ -194,6 +194,7 @@ Then perform the following commands on the root folder:
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | `bool` | `false` | no |
| resource\_usage\_export\_dataset\_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | `string` | `""` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The create\_service\_account variable default value (true) will cause a cluster-specific service account to be created. | `string` | `""` | no |
| service\_externalips | Whether external ips specified by a service will be allowed in this cluster | `bool` | `false` | no |
| shadow\_firewall\_rules\_priority | The firewall priority of GKE shadow firewall rules. The priority should be less than default firewall, which is 1000. | `number` | `999` | no |
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks `stub_domains` and `upstream_nameservers` variables functionality. | `bool` | `false` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | `map(list(string))` | `{}` | no |
Expand Down
9 changes: 7 additions & 2 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ resource "google_container_cluster" "primary" {
}
}

service_external_ips_config {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a dynamic block if enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! let me include in the changes I'll make locally

enabled = var.service_externalips
}

addons_config {
http_load_balancing {
disabled = !var.http_load_balancing
Expand Down Expand Up @@ -616,8 +620,9 @@ resource "google_container_node_pool" "windows_pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an unrelated change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to external ips yes, but this was something I've seen happen in clusters as of 1.24 - they get this default value from the provider, but this module will remove it on the next plan + apply. I can separate into second PR (and make it a var) if you'd like!

}
}

Expand Down
6 changes: 6 additions & 0 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ variable "http_load_balancing" {
default = true
}

variable "service_externalips" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
variable "service_externalips" {
variable "service_external_ips" {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, sounds good - I will make some changes locally and update!

type = bool
description = "Whether external ips specified by a service will be allowed in this cluster"
default = false
}

variable "datapath_provider" {
type = string
description = "The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature."
Expand Down
14 changes: 10 additions & 4 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ resource "google_container_cluster" "primary" {
}
}

service_external_ips_config {
enabled = var.service_externalips
}

addons_config {
http_load_balancing {
disabled = !var.http_load_balancing
Expand Down Expand Up @@ -324,8 +328,9 @@ resource "google_container_node_pool" "pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

Expand Down Expand Up @@ -474,8 +479,9 @@ resource "google_container_node_pool" "windows_pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/beta-autopilot-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Then perform the following commands on the root folder:
| release\_channel | The release channel of this cluster. Accepted values are `UNSPECIFIED`, `RAPID`, `REGULAR` and `STABLE`. Defaults to `UNSPECIFIED`. | `string` | `null` | no |
| resource\_usage\_export\_dataset\_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | `string` | `""` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The create\_service\_account variable default value (true) will cause a cluster-specific service account to be created. | `string` | `""` | no |
| service\_externalips | Whether external ips specified by a service will be allowed in this cluster | `bool` | `false` | no |
| shadow\_firewall\_rules\_priority | The firewall priority of GKE shadow firewall rules. The priority should be less than default firewall, which is 1000. | `number` | `999` | no |
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks `stub_domains` and `upstream_nameservers` variables functionality. | `bool` | `false` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | `map(list(string))` | `{}` | no |
Expand Down
4 changes: 4 additions & 0 deletions modules/beta-autopilot-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ resource "google_container_cluster" "primary" {
}
}

service_external_ips_config {
enabled = var.service_externalips
}

addons_config {
http_load_balancing {
disabled = !var.http_load_balancing
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-autopilot-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ variable "http_load_balancing" {
default = true
}

variable "service_externalips" {
type = bool
description = "Whether external ips specified by a service will be allowed in this cluster"
default = false
}

variable "datapath_provider" {
type = string
description = "The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature."
Expand Down
1 change: 1 addition & 0 deletions modules/beta-autopilot-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Then perform the following commands on the root folder:
| release\_channel | The release channel of this cluster. Accepted values are `UNSPECIFIED`, `RAPID`, `REGULAR` and `STABLE`. Defaults to `UNSPECIFIED`. | `string` | `null` | no |
| resource\_usage\_export\_dataset\_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | `string` | `""` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The create\_service\_account variable default value (true) will cause a cluster-specific service account to be created. | `string` | `""` | no |
| service\_externalips | Whether external ips specified by a service will be allowed in this cluster | `bool` | `false` | no |
| shadow\_firewall\_rules\_priority | The firewall priority of GKE shadow firewall rules. The priority should be less than default firewall, which is 1000. | `number` | `999` | no |
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks `stub_domains` and `upstream_nameservers` variables functionality. | `bool` | `false` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | `map(list(string))` | `{}` | no |
Expand Down
4 changes: 4 additions & 0 deletions modules/beta-autopilot-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ resource "google_container_cluster" "primary" {
}
}

service_external_ips_config {
enabled = var.service_externalips
}

addons_config {
http_load_balancing {
disabled = !var.http_load_balancing
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-autopilot-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ variable "http_load_balancing" {
default = true
}

variable "service_externalips" {
type = bool
description = "Whether external ips specified by a service will be allowed in this cluster"
default = false
}

variable "datapath_provider" {
type = string
description = "The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature."
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 @@ -252,6 +252,7 @@ Then perform the following commands on the root folder:
| resource\_usage\_export\_dataset\_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | `string` | `""` | no |
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it). | `bool` | `false` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The create\_service\_account variable default value (true) will cause a cluster-specific service account to be created. | `string` | `""` | no |
| service\_externalips | Whether external ips specified by a service will be allowed in this cluster | `bool` | `false` | no |
| shadow\_firewall\_rules\_priority | The firewall priority of GKE shadow firewall rules. The priority should be less than default firewall, which is 1000. | `number` | `999` | no |
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks `stub_domains` and `upstream_nameservers` variables functionality. | `bool` | `false` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | `map(list(string))` | `{}` | no |
Expand Down
14 changes: 10 additions & 4 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ resource "google_container_cluster" "primary" {
}
}

service_external_ips_config {
enabled = var.service_externalips
}

addons_config {
http_load_balancing {
disabled = !var.http_load_balancing
Expand Down Expand Up @@ -536,8 +540,9 @@ resource "google_container_node_pool" "pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

Expand Down Expand Up @@ -741,8 +746,9 @@ resource "google_container_node_pool" "windows_pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

Expand Down
6 changes: 6 additions & 0 deletions modules/beta-private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ variable "http_load_balancing" {
default = true
}

variable "service_externalips" {
type = bool
description = "Whether external ips specified by a service will be allowed in this cluster"
default = false
}

variable "datapath_provider" {
type = string
description = "The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature."
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 @@ -230,6 +230,7 @@ Then perform the following commands on the root folder:
| resource\_usage\_export\_dataset\_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | `string` | `""` | no |
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it). | `bool` | `false` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The create\_service\_account variable default value (true) will cause a cluster-specific service account to be created. | `string` | `""` | no |
| service\_externalips | Whether external ips specified by a service will be allowed in this cluster | `bool` | `false` | no |
| shadow\_firewall\_rules\_priority | The firewall priority of GKE shadow firewall rules. The priority should be less than default firewall, which is 1000. | `number` | `999` | no |
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks `stub_domains` and `upstream_nameservers` variables functionality. | `bool` | `false` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | `map(list(string))` | `{}` | no |
Expand Down
14 changes: 10 additions & 4 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ resource "google_container_cluster" "primary" {
}
}

service_external_ips_config {
enabled = var.service_externalips
}

addons_config {
http_load_balancing {
disabled = !var.http_load_balancing
Expand Down Expand Up @@ -445,8 +449,9 @@ resource "google_container_node_pool" "pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

Expand Down Expand Up @@ -649,8 +654,9 @@ resource "google_container_node_pool" "windows_pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

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 @@ -96,6 +96,12 @@ variable "http_load_balancing" {
default = true
}

variable "service_externalips" {
type = bool
description = "Whether external ips specified by a service will be allowed in this cluster"
default = false
}

variable "datapath_provider" {
type = string
description = "The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature."
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 @@ -241,6 +241,7 @@ Then perform the following commands on the root folder:
| resource\_usage\_export\_dataset\_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | `string` | `""` | no |
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it). | `bool` | `false` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The create\_service\_account variable default value (true) will cause a cluster-specific service account to be created. | `string` | `""` | no |
| service\_externalips | Whether external ips specified by a service will be allowed in this cluster | `bool` | `false` | no |
| shadow\_firewall\_rules\_priority | The firewall priority of GKE shadow firewall rules. The priority should be less than default firewall, which is 1000. | `number` | `999` | no |
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks `stub_domains` and `upstream_nameservers` variables functionality. | `bool` | `false` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | `map(list(string))` | `{}` | no |
Expand Down
14 changes: 10 additions & 4 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ resource "google_container_cluster" "primary" {
}
}

service_external_ips_config {
enabled = var.service_externalips
}

addons_config {
http_load_balancing {
disabled = !var.http_load_balancing
Expand Down Expand Up @@ -517,8 +521,9 @@ resource "google_container_node_pool" "pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

Expand Down Expand Up @@ -722,8 +727,9 @@ resource "google_container_node_pool" "windows_pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

Expand Down
6 changes: 6 additions & 0 deletions modules/beta-public-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ variable "http_load_balancing" {
default = true
}

variable "service_externalips" {
type = bool
description = "Whether external ips specified by a service will be allowed in this cluster"
default = false
}

variable "datapath_provider" {
type = string
description = "The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature."
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 @@ -219,6 +219,7 @@ Then perform the following commands on the root folder:
| resource\_usage\_export\_dataset\_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | `string` | `""` | no |
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it). | `bool` | `false` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The create\_service\_account variable default value (true) will cause a cluster-specific service account to be created. | `string` | `""` | no |
| service\_externalips | Whether external ips specified by a service will be allowed in this cluster | `bool` | `false` | no |
| shadow\_firewall\_rules\_priority | The firewall priority of GKE shadow firewall rules. The priority should be less than default firewall, which is 1000. | `number` | `999` | no |
| skip\_provisioners | Flag to skip all local-exec provisioners. It breaks `stub_domains` and `upstream_nameservers` variables functionality. | `bool` | `false` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | `map(list(string))` | `{}` | no |
Expand Down
14 changes: 10 additions & 4 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ resource "google_container_cluster" "primary" {
}
}

service_external_ips_config {
enabled = var.service_externalips
}

addons_config {
http_load_balancing {
disabled = !var.http_load_balancing
Expand Down Expand Up @@ -426,8 +430,9 @@ resource "google_container_node_pool" "pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

Expand Down Expand Up @@ -630,8 +635,9 @@ resource "google_container_node_pool" "windows_pools" {
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
min_node_count = lookup(autoscaling.value, "min_count", 1)
max_node_count = lookup(autoscaling.value, "max_count", 100)
location_policy = "BALANCED"
}
}

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 @@ -96,6 +96,12 @@ variable "http_load_balancing" {
default = true
}

variable "service_externalips" {
type = bool
description = "Whether external ips specified by a service will be allowed in this cluster"
default = false
}

variable "datapath_provider" {
type = string
description = "The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature."
Expand Down
Loading