Skip to content

Commit

Permalink
feat!: promote gke_backup_agent_config to ga (terraform-google-module…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolsee authored and naveen230 committed Jan 15, 2023
1 parent d7f71f6 commit eeb3f4f
Show file tree
Hide file tree
Showing 45 changed files with 254 additions and 96 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Then perform the following commands on the root folder:
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format gke-security-groups@yourdomain.com | `string` | `null` | no |
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> })</pre> | <pre>{<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
| cluster\_dns\_scope | The scope of access to cluster DNS records. DNS\_SCOPE\_UNSPECIFIED (default) or CLUSTER\_SCOPE or VPC\_SCOPE. | `string` | `"DNS_SCOPE_UNSPECIFIED"` | no |
Expand All @@ -158,6 +158,7 @@ Then perform the following commands on the root folder:
| firewall\_priority | Priority rule for firewall rules | `number` | `1000` | no |
| gateway\_api\_channel | The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`. | `string` | `null` | no |
| gce\_pd\_csi\_driver | Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | `bool` | `true` | no |
| gke\_backup\_agent\_config | Whether Backup for GKE agent is enabled for this cluster. | `bool` | `false` | no |
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer and artifactregistry.reader roles. | `bool` | `false` | no |
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
Expand Down
24 changes: 16 additions & 8 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ resource "google_container_cluster" "primary" {
maximum = lookup(resource_limits.value, "maximum")
}
}
dynamic "management" {
for_each = var.cluster_autoscaling.enabled ? [1] : []

content {
auto_repair = var.cluster_autoscaling.auto_repair
auto_upgrade = var.cluster_autoscaling.auto_upgrade
}
}
}
{% endif %}
{% if autopilot_cluster == true %}
Expand Down Expand Up @@ -259,6 +267,14 @@ resource "google_container_cluster" "primary" {
enabled = gce_persistent_disk_csi_driver_config.value.enabled
}
}

dynamic "gke_backup_agent_config" {
for_each = local.gke_backup_agent_config

content {
enabled = gke_backup_agent_config.value.enabled
}
}
{% endif %}
{% if beta_cluster and autopilot_cluster != true %}

Expand All @@ -282,14 +298,6 @@ resource "google_container_cluster" "primary" {
config_connector_config {
enabled = var.config_connector
}

dynamic "gke_backup_agent_config" {
for_each = local.gke_backup_agent_config

content {
enabled = gke_backup_agent_config.value.enabled
}
}
{% endif %}
}

Expand Down
4 changes: 2 additions & 2 deletions autogen/main/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ locals {
resource_type = "memory"
minimum = var.cluster_autoscaling.min_memory_gb
maximum = var.cluster_autoscaling.max_memory_gb
}], var.cluster_autoscaling.gpu_resources) : []
}], var.cluster_autoscaling.gpu_resources) : []
{% endif %}


Expand Down Expand Up @@ -103,6 +103,7 @@ locals {
}]
cluster_gce_pd_csi_config = var.gce_pd_csi_driver ? [{ enabled = true }] : [{ enabled = false }]
logmon_config_is_set = length(var.logging_enabled_components) > 0 || length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus
gke_backup_agent_config = var.gke_backup_agent_config ? [{ enabled = true }] : [{ enabled = false }]
{% endif %}
{% if beta_cluster and autopilot_cluster != true %}
cluster_cloudrun_config_load_balancer_config = (var.cloudrun && var.cloudrun_load_balancer_type != "") ? {
Expand All @@ -117,7 +118,6 @@ locals {
)
] : []
cluster_cloudrun_enabled = var.cloudrun
gke_backup_agent_config = var.gke_backup_agent_config ? [{ enabled = true }] : [{ enabled = false }]
{% endif %}

cluster_authenticator_security_group = var.authenticator_security_group == null ? [] : [{
Expand Down
16 changes: 10 additions & 6 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ variable "cluster_autoscaling" {
min_memory_gb = number
max_memory_gb = number
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
auto_repair = bool
auto_upgrade = bool
})
default = {
enabled = false
Expand All @@ -252,6 +254,8 @@ variable "cluster_autoscaling" {
max_memory_gb = 0
min_memory_gb = 0
gpu_resources = []
auto_repair = true
auto_upgrade = true
}
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
}
Expand Down Expand Up @@ -641,6 +645,12 @@ variable "gce_pd_csi_driver" {
default = true
}

variable "gke_backup_agent_config" {
type = bool
description = "Whether Backup for GKE agent is enabled for this cluster."
default = false
}

{% endif %}
variable "timeouts" {
type = map(string)
Expand Down Expand Up @@ -703,12 +713,6 @@ variable "config_connector" {
default = false
}

variable "gke_backup_agent_config" {
type = bool
description = "(Beta) Whether Backup for GKE agent is enabled for this cluster."
default = false
}

variable "cloudrun" {
description = "(Beta) Enable CloudRun addon"
default = false
Expand Down
2 changes: 1 addition & 1 deletion 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.46.0, < 5.0"
version = ">= 4.47.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
4 changes: 4 additions & 0 deletions autogen/safer-cluster/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ variable "cluster_autoscaling" {
min_memory_gb = number
max_memory_gb = number
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
auto_repair = bool
auto_upgrade = bool
})
default = {
enabled = false
Expand All @@ -236,6 +238,8 @@ variable "cluster_autoscaling" {
max_memory_gb = 0
min_memory_gb = 0
gpu_resources = []
auto_repair = true
auto_upgrade = true
}
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
}
Expand Down
16 changes: 16 additions & 0 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ resource "google_container_cluster" "primary" {
maximum = lookup(resource_limits.value, "maximum")
}
}
dynamic "management" {
for_each = var.cluster_autoscaling.enabled ? [1] : []

content {
auto_repair = var.cluster_autoscaling.auto_repair
auto_upgrade = var.cluster_autoscaling.auto_upgrade
}
}
}
vertical_pod_autoscaling {
enabled = var.enable_vertical_pod_autoscaling
Expand Down Expand Up @@ -184,6 +192,14 @@ resource "google_container_cluster" "primary" {
enabled = gce_persistent_disk_csi_driver_config.value.enabled
}
}

dynamic "gke_backup_agent_config" {
for_each = local.gke_backup_agent_config

content {
enabled = gke_backup_agent_config.value.enabled
}
}
}

datapath_provider = var.datapath_provider
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ locals {
}]
cluster_gce_pd_csi_config = var.gce_pd_csi_driver ? [{ enabled = true }] : [{ enabled = false }]
logmon_config_is_set = length(var.logging_enabled_components) > 0 || length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus
gke_backup_agent_config = var.gke_backup_agent_config ? [{ enabled = true }] : [{ enabled = false }]

cluster_authenticator_security_group = var.authenticator_security_group == null ? [] : [{
security_group = var.authenticator_security_group
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.46.0, < 5.0"
version = ">= 4.47.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.46.0, < 5.0"
version = ">= 4.47.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
4 changes: 2 additions & 2 deletions modules/beta-private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Then perform the following commands on the root folder:
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format gke-security-groups@yourdomain.com | `string` | `null` | no |
| cloudrun | (Beta) Enable CloudRun addon | `bool` | `false` | no |
| cloudrun\_load\_balancer\_type | (Beta) Configure the Cloud Run load balancer type. External by default. Set to `LOAD_BALANCER_TYPE_INTERNAL` to configure as an internal load balancer. | `string` | `""` | no |
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> })</pre> | <pre>{<br> "autoscaling_profile": "BALANCED",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
| cluster\_dns\_scope | The scope of access to cluster DNS records. DNS\_SCOPE\_UNSPECIFIED (default) or CLUSTER\_SCOPE or VPC\_SCOPE. | `string` | `"DNS_SCOPE_UNSPECIFIED"` | no |
Expand Down Expand Up @@ -203,7 +203,7 @@ Then perform the following commands on the root folder:
| firewall\_priority | Priority rule for firewall rules | `number` | `1000` | no |
| gateway\_api\_channel | The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`. | `string` | `null` | no |
| gce\_pd\_csi\_driver | Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | `bool` | `true` | no |
| gke\_backup\_agent\_config | (Beta) Whether Backup for GKE agent is enabled for this cluster. | `bool` | `false` | no |
| gke\_backup\_agent\_config | Whether Backup for GKE agent is enabled for this cluster. | `bool` | `false` | no |
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer and artifactregistry.reader roles. | `bool` | `false` | no |
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
Expand Down
24 changes: 16 additions & 8 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ resource "google_container_cluster" "primary" {
maximum = lookup(resource_limits.value, "maximum")
}
}
dynamic "management" {
for_each = var.cluster_autoscaling.enabled ? [1] : []

content {
auto_repair = var.cluster_autoscaling.auto_repair
auto_upgrade = var.cluster_autoscaling.auto_upgrade
}
}
}
vertical_pod_autoscaling {
enabled = var.enable_vertical_pod_autoscaling
Expand Down Expand Up @@ -217,6 +225,14 @@ resource "google_container_cluster" "primary" {
}
}

dynamic "gke_backup_agent_config" {
for_each = local.gke_backup_agent_config

content {
enabled = gke_backup_agent_config.value.enabled
}
}

istio_config {
disabled = !var.istio
auth = var.istio_auth
Expand All @@ -237,14 +253,6 @@ resource "google_container_cluster" "primary" {
config_connector_config {
enabled = var.config_connector
}

dynamic "gke_backup_agent_config" {
for_each = local.gke_backup_agent_config

content {
enabled = gke_backup_agent_config.value.enabled
}
}
}

datapath_provider = var.datapath_provider
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ locals {
}]
cluster_gce_pd_csi_config = var.gce_pd_csi_driver ? [{ enabled = true }] : [{ enabled = false }]
logmon_config_is_set = length(var.logging_enabled_components) > 0 || length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus
gke_backup_agent_config = var.gke_backup_agent_config ? [{ enabled = true }] : [{ enabled = false }]
cluster_cloudrun_config_load_balancer_config = (var.cloudrun && var.cloudrun_load_balancer_type != "") ? {
load_balancer_type = var.cloudrun_load_balancer_type
} : {}
Expand All @@ -98,7 +99,6 @@ locals {
)
] : []
cluster_cloudrun_enabled = var.cloudrun
gke_backup_agent_config = var.gke_backup_agent_config ? [{ enabled = true }] : [{ enabled = false }]

cluster_authenticator_security_group = var.authenticator_security_group == null ? [] : [{
security_group = var.authenticator_security_group
Expand Down
16 changes: 10 additions & 6 deletions modules/beta-private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ variable "cluster_autoscaling" {
min_memory_gb = number
max_memory_gb = number
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
auto_repair = bool
auto_upgrade = bool
})
default = {
enabled = false
Expand All @@ -243,6 +245,8 @@ variable "cluster_autoscaling" {
max_memory_gb = 0
min_memory_gb = 0
gpu_resources = []
auto_repair = true
auto_upgrade = true
}
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
}
Expand Down Expand Up @@ -614,6 +618,12 @@ variable "gce_pd_csi_driver" {
default = true
}

variable "gke_backup_agent_config" {
type = bool
description = "Whether Backup for GKE agent is enabled for this cluster."
default = false
}

variable "timeouts" {
type = map(string)
description = "Timeout for cluster operations."
Expand Down Expand Up @@ -671,12 +681,6 @@ variable "config_connector" {
default = false
}

variable "gke_backup_agent_config" {
type = bool
description = "(Beta) Whether Backup for GKE agent is enabled for this cluster."
default = false
}

variable "cloudrun" {
description = "(Beta) Enable CloudRun addon"
default = false
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.46.0, < 5.0"
version = ">= 4.47.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
Loading

0 comments on commit eeb3f4f

Please sign in to comment.