gke-cluster-standard : Support upgrade_settings for node auto provisioner (#1905)
* gke-cluster-standard : Support upgrade_settings for node auto provisionner * implement suggestions * tfdoc --------- Co-authored-by: Ludo <ludomagno@google.com>
This commit is contained in:
parent
ef4095f000
commit
201ff284f6
|
@ -310,27 +310,27 @@ module "cluster-1" {
|
|||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [location](variables.tf#L179) | Cluster zone or region. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L290) | Cluster name. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L326) | Cluster project id. | <code>string</code> | ✓ | |
|
||||
| [vpc_config](variables.tf#L337) | VPC-level configuration. | <code title="object({ network = string subnetwork = string master_ipv4_cidr_block = optional(string) secondary_range_blocks = optional(object({ pods = string services = string })) secondary_range_names = optional(object({ pods = optional(string, "pods") services = optional(string, "services") })) master_authorized_ranges = optional(map(string)) stack_type = optional(string) })">object({…})</code> | ✓ | |
|
||||
| [location](variables.tf#L211) | Cluster zone or region. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L322) | Cluster name. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L358) | Cluster project id. | <code>string</code> | ✓ | |
|
||||
| [vpc_config](variables.tf#L369) | VPC-level configuration. | <code title="object({ network = string subnetwork = string master_ipv4_cidr_block = optional(string) secondary_range_blocks = optional(object({ pods = string services = string })) secondary_range_names = optional(object({ pods = optional(string, "pods") services = optional(string, "services") })) master_authorized_ranges = optional(map(string)) stack_type = optional(string) })">object({…})</code> | ✓ | |
|
||||
| [backup_configs](variables.tf#L17) | Configuration for Backup for GKE. | <code title="object({ enable_backup_agent = optional(bool, false) backup_plans = optional(map(object({ region = string applications = optional(map(list(string))) encryption_key = optional(string) include_secrets = optional(bool, true) include_volume_data = optional(bool, true) namespaces = optional(list(string)) schedule = optional(string) retention_policy_days = optional(number) retention_policy_lock = optional(bool, false) retention_policy_delete_lock_days = optional(number) })), {}) })">object({…})</code> | | <code>{}</code> |
|
||||
| [cluster_autoscaling](variables.tf#L38) | Enable and configure limits for Node Auto-Provisioning with Cluster Autoscaler. | <code title="object({ autoscaling_profile = optional(string, "BALANCED") auto_provisioning_defaults = optional(object({ boot_disk_kms_key = optional(string) disk_size = optional(number) disk_type = optional(string, "pd-standard") image_type = optional(string) oauth_scopes = optional(list(string)) service_account = optional(string) management = optional(object({ auto_repair = optional(bool, true) auto_upgrade = optional(bool, true) })) shielded_instance_config = optional(object({ integrity_monitoring = optional(bool, true) secure_boot = optional(bool, false) })) })) cpu_limits = optional(object({ min = number max = number })) mem_limits = optional(object({ min = number max = number })) gpu_resources = optional(list(object({ resource_type = string min = number max = number }))) })">object({…})</code> | | <code>null</code> |
|
||||
| [deletion_protection](variables.tf#L83) | Whether or not to allow Terraform to destroy the cluster. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the cluster will fail. | <code>bool</code> | | <code>true</code> |
|
||||
| [description](variables.tf#L90) | Cluster description. | <code>string</code> | | <code>null</code> |
|
||||
| [enable_addons](variables.tf#L96) | Addons enabled in the cluster (true means enabled). | <code title="object({ cloudrun = optional(bool, false) config_connector = optional(bool, false) dns_cache = optional(bool, false) gce_persistent_disk_csi_driver = optional(bool, false) gcp_filestore_csi_driver = optional(bool, false) gcs_fuse_csi_driver = optional(bool, false) horizontal_pod_autoscaling = optional(bool, false) http_load_balancing = optional(bool, false) istio = optional(object({ enable_tls = bool })) kalm = optional(bool, false) network_policy = optional(bool, false) })">object({…})</code> | | <code title="{ horizontal_pod_autoscaling = true http_load_balancing = true }">{…}</code> |
|
||||
| [enable_features](variables.tf#L120) | Enable cluster-level features. Certain features allow configuration. | <code title="object({ binary_authorization = optional(bool, false) cost_management = optional(bool, false) dns = optional(object({ provider = optional(string) scope = optional(string) domain = optional(string) })) database_encryption = optional(object({ state = string key_name = string })) dataplane_v2 = optional(bool, false) fqdn_network_policy = optional(bool, false) gateway_api = optional(bool, false) groups_for_rbac = optional(string) image_streaming = optional(bool, false) intranode_visibility = optional(bool, false) l4_ilb_subsetting = optional(bool, false) mesh_certificates = optional(bool) pod_security_policy = optional(bool, false) resource_usage_export = optional(object({ dataset = string enable_network_egress_metering = optional(bool) enable_resource_consumption_metering = optional(bool) })) shielded_nodes = optional(bool, false) tpu = optional(bool, false) upgrade_notifications = optional(object({ topic_id = optional(string) })) vertical_pod_autoscaling = optional(bool, false) workload_identity = optional(bool, true) })">object({…})</code> | | <code title="{ workload_identity = true }">{…}</code> |
|
||||
| [issue_client_certificate](variables.tf#L167) | Enable issuing client certificate. | <code>bool</code> | | <code>false</code> |
|
||||
| [labels](variables.tf#L173) | Cluster resource labels. | <code>map(string)</code> | | <code>null</code> |
|
||||
| [logging_config](variables.tf#L184) | Logging configuration. | <code title="object({ enable_system_logs = optional(bool, true) enable_workloads_logs = optional(bool, false) enable_api_server_logs = optional(bool, false) enable_scheduler_logs = optional(bool, false) enable_controller_manager_logs = optional(bool, false) })">object({…})</code> | | <code>{}</code> |
|
||||
| [maintenance_config](variables.tf#L205) | Maintenance window configuration. | <code title="object({ daily_window_start_time = optional(string) recurring_window = optional(object({ start_time = string end_time = string recurrence = string })) maintenance_exclusions = optional(list(object({ name = string start_time = string end_time = string scope = optional(string) }))) })">object({…})</code> | | <code title="{ daily_window_start_time = "03:00" recurring_window = null maintenance_exclusion = [] }">{…}</code> |
|
||||
| [max_pods_per_node](variables.tf#L228) | Maximum number of pods per node in this cluster. | <code>number</code> | | <code>110</code> |
|
||||
| [min_master_version](variables.tf#L234) | Minimum version of the master, defaults to the version of the most recent official release. | <code>string</code> | | <code>null</code> |
|
||||
| [monitoring_config](variables.tf#L240) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | <code title="object({ enable_system_metrics = optional(bool, true) enable_api_server_metrics = optional(bool, false) enable_controller_manager_metrics = optional(bool, false) enable_scheduler_metrics = optional(bool, false) enable_daemonset_metrics = optional(bool, false) enable_deployment_metrics = optional(bool, false) enable_hpa_metrics = optional(bool, false) enable_pod_metrics = optional(bool, false) enable_statefulset_metrics = optional(bool, false) enable_storage_metrics = optional(bool, false) enable_managed_prometheus = optional(bool, true) })">object({…})</code> | | <code>{}</code> |
|
||||
| [node_config](variables.tf#L295) | Node-level configuration. | <code title="object({ boot_disk_kms_key = optional(string) service_account = optional(string) tags = optional(list(string)) })">object({…})</code> | | <code>{}</code> |
|
||||
| [node_locations](variables.tf#L305) | Zones in which the cluster's nodes are located. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [private_cluster_config](variables.tf#L312) | Private cluster configuration. | <code title="object({ enable_private_endpoint = optional(bool) master_global_access = optional(bool) peering_config = optional(object({ export_routes = optional(bool) import_routes = optional(bool) project_id = optional(string) })) })">object({…})</code> | | <code>null</code> |
|
||||
| [release_channel](variables.tf#L331) | Release channel for GKE upgrades. | <code>string</code> | | <code>null</code> |
|
||||
| [cluster_autoscaling](variables.tf#L38) | Enable and configure limits for Node Auto-Provisioning with Cluster Autoscaler. | <code title="object({ autoscaling_profile = optional(string, "BALANCED") auto_provisioning_defaults = optional(object({ boot_disk_kms_key = optional(string) disk_size = optional(number) disk_type = optional(string, "pd-standard") image_type = optional(string) oauth_scopes = optional(list(string)) service_account = optional(string) management = optional(object({ auto_repair = optional(bool, true) auto_upgrade = optional(bool, true) })) shielded_instance_config = optional(object({ integrity_monitoring = optional(bool, true) secure_boot = optional(bool, false) })) upgrade_settings = optional(object({ blue_green = optional(object({ node_pool_soak_duration = optional(string) standard_rollout_policy = optional(object({ batch_percentage = optional(number) batch_node_count = optional(number) batch_soak_duration = optional(string) })) })) surge = optional(object({ max = optional(number) unavailable = optional(number) })) })) })) cpu_limits = optional(object({ min = number max = number })) mem_limits = optional(object({ min = number max = number })) gpu_resources = optional(list(object({ resource_type = string min = number max = number }))) })">object({…})</code> | | <code>null</code> |
|
||||
| [deletion_protection](variables.tf#L115) | Whether or not to allow Terraform to destroy the cluster. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the cluster will fail. | <code>bool</code> | | <code>true</code> |
|
||||
| [description](variables.tf#L122) | Cluster description. | <code>string</code> | | <code>null</code> |
|
||||
| [enable_addons](variables.tf#L128) | Addons enabled in the cluster (true means enabled). | <code title="object({ cloudrun = optional(bool, false) config_connector = optional(bool, false) dns_cache = optional(bool, false) gce_persistent_disk_csi_driver = optional(bool, false) gcp_filestore_csi_driver = optional(bool, false) gcs_fuse_csi_driver = optional(bool, false) horizontal_pod_autoscaling = optional(bool, false) http_load_balancing = optional(bool, false) istio = optional(object({ enable_tls = bool })) kalm = optional(bool, false) network_policy = optional(bool, false) })">object({…})</code> | | <code title="{ horizontal_pod_autoscaling = true http_load_balancing = true }">{…}</code> |
|
||||
| [enable_features](variables.tf#L152) | Enable cluster-level features. Certain features allow configuration. | <code title="object({ binary_authorization = optional(bool, false) cost_management = optional(bool, false) dns = optional(object({ provider = optional(string) scope = optional(string) domain = optional(string) })) database_encryption = optional(object({ state = string key_name = string })) dataplane_v2 = optional(bool, false) fqdn_network_policy = optional(bool, false) gateway_api = optional(bool, false) groups_for_rbac = optional(string) image_streaming = optional(bool, false) intranode_visibility = optional(bool, false) l4_ilb_subsetting = optional(bool, false) mesh_certificates = optional(bool) pod_security_policy = optional(bool, false) resource_usage_export = optional(object({ dataset = string enable_network_egress_metering = optional(bool) enable_resource_consumption_metering = optional(bool) })) shielded_nodes = optional(bool, false) tpu = optional(bool, false) upgrade_notifications = optional(object({ topic_id = optional(string) })) vertical_pod_autoscaling = optional(bool, false) workload_identity = optional(bool, true) })">object({…})</code> | | <code title="{ workload_identity = true }">{…}</code> |
|
||||
| [issue_client_certificate](variables.tf#L199) | Enable issuing client certificate. | <code>bool</code> | | <code>false</code> |
|
||||
| [labels](variables.tf#L205) | Cluster resource labels. | <code>map(string)</code> | | <code>null</code> |
|
||||
| [logging_config](variables.tf#L216) | Logging configuration. | <code title="object({ enable_system_logs = optional(bool, true) enable_workloads_logs = optional(bool, false) enable_api_server_logs = optional(bool, false) enable_scheduler_logs = optional(bool, false) enable_controller_manager_logs = optional(bool, false) })">object({…})</code> | | <code>{}</code> |
|
||||
| [maintenance_config](variables.tf#L237) | Maintenance window configuration. | <code title="object({ daily_window_start_time = optional(string) recurring_window = optional(object({ start_time = string end_time = string recurrence = string })) maintenance_exclusions = optional(list(object({ name = string start_time = string end_time = string scope = optional(string) }))) })">object({…})</code> | | <code title="{ daily_window_start_time = "03:00" recurring_window = null maintenance_exclusion = [] }">{…}</code> |
|
||||
| [max_pods_per_node](variables.tf#L260) | Maximum number of pods per node in this cluster. | <code>number</code> | | <code>110</code> |
|
||||
| [min_master_version](variables.tf#L266) | Minimum version of the master, defaults to the version of the most recent official release. | <code>string</code> | | <code>null</code> |
|
||||
| [monitoring_config](variables.tf#L272) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | <code title="object({ enable_system_metrics = optional(bool, true) enable_api_server_metrics = optional(bool, false) enable_controller_manager_metrics = optional(bool, false) enable_scheduler_metrics = optional(bool, false) enable_daemonset_metrics = optional(bool, false) enable_deployment_metrics = optional(bool, false) enable_hpa_metrics = optional(bool, false) enable_pod_metrics = optional(bool, false) enable_statefulset_metrics = optional(bool, false) enable_storage_metrics = optional(bool, false) enable_managed_prometheus = optional(bool, true) })">object({…})</code> | | <code>{}</code> |
|
||||
| [node_config](variables.tf#L327) | Node-level configuration. | <code title="object({ boot_disk_kms_key = optional(string) service_account = optional(string) tags = optional(list(string)) })">object({…})</code> | | <code>{}</code> |
|
||||
| [node_locations](variables.tf#L337) | Zones in which the cluster's nodes are located. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [private_cluster_config](variables.tf#L344) | Private cluster configuration. | <code title="object({ enable_private_endpoint = optional(bool) master_global_access = optional(bool) peering_config = optional(object({ export_routes = optional(bool) import_routes = optional(bool) project_id = optional(string) })) })">object({…})</code> | | <code>null</code> |
|
||||
| [release_channel](variables.tf#L363) | Release channel for GKE upgrades. | <code>string</code> | | <code>null</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
|
@ -13,6 +13,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
locals {
|
||||
cas = var.cluster_autoscaling
|
||||
cas_apd = try(local.cas.auto_provisioning_defaults, null)
|
||||
cas_apd_us = try(local.cas_apd.upgrade_settings, null)
|
||||
}
|
||||
|
||||
resource "google_container_cluster" "cluster" {
|
||||
provider = google-beta
|
||||
project = var.project_id
|
||||
|
@ -40,7 +47,6 @@ resource "google_container_cluster" "cluster" {
|
|||
? "ADVANCED_DATAPATH"
|
||||
: "DATAPATH_PROVIDER_UNSPECIFIED"
|
||||
)
|
||||
|
||||
# the default node pool is deleted here, use the gke-nodepool module instead.
|
||||
# shielded nodes are controlled by the cluster-level enable_features variable
|
||||
node_config {
|
||||
|
@ -55,7 +61,6 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
# gcfs_config deactivation need the block to be defined so it can't be dynamic
|
||||
node_pool_defaults {
|
||||
node_config_defaults {
|
||||
|
@ -64,7 +69,6 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
addons_config {
|
||||
dns_cache_config {
|
||||
enabled = var.enable_addons.dns_cache
|
||||
|
@ -106,81 +110,115 @@ resource "google_container_cluster" "cluster" {
|
|||
enabled = var.backup_configs.enable_backup_agent
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "authenticator_groups_config" {
|
||||
for_each = var.enable_features.groups_for_rbac != null ? [""] : []
|
||||
content {
|
||||
security_group = var.enable_features.groups_for_rbac
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "binary_authorization" {
|
||||
for_each = var.enable_features.binary_authorization ? [""] : []
|
||||
content {
|
||||
evaluation_mode = "PROJECT_SINGLETON_POLICY_ENFORCE"
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "cost_management_config" {
|
||||
for_each = var.enable_features.cost_management == true ? [""] : []
|
||||
content {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "cluster_autoscaling" {
|
||||
for_each = var.cluster_autoscaling == null ? [] : [""]
|
||||
for_each = local.cas == null ? [] : [""]
|
||||
content {
|
||||
enabled = true
|
||||
|
||||
enabled = true
|
||||
autoscaling_profile = var.cluster_autoscaling.autoscaling_profile
|
||||
|
||||
dynamic "auto_provisioning_defaults" {
|
||||
for_each = var.cluster_autoscaling.auto_provisioning_defaults != null ? [""] : []
|
||||
for_each = local.cas_apd != null ? [""] : []
|
||||
content {
|
||||
boot_disk_kms_key = var.cluster_autoscaling.auto_provisioning_defaults.boot_disk_kms_key
|
||||
disk_size = var.cluster_autoscaling.auto_provisioning_defaults.disk_size
|
||||
disk_type = var.cluster_autoscaling.auto_provisioning_defaults.disk_type
|
||||
image_type = var.cluster_autoscaling.auto_provisioning_defaults.image_type
|
||||
oauth_scopes = var.cluster_autoscaling.auto_provisioning_defaults.oauth_scopes
|
||||
service_account = var.cluster_autoscaling.auto_provisioning_defaults.service_account
|
||||
boot_disk_kms_key = local.cas_apd.boot_disk_kms_key
|
||||
disk_size = local.cas_apd.disk_size
|
||||
disk_type = local.cas_apd.disk_type
|
||||
image_type = local.cas_apd.image_type
|
||||
oauth_scopes = local.cas_apd.oauth_scopes
|
||||
service_account = local.cas_apd.service_account
|
||||
dynamic "management" {
|
||||
for_each = var.cluster_autoscaling.auto_provisioning_defaults.management != null ? [""] : []
|
||||
for_each = local.cas_apd.management != null ? [""] : []
|
||||
content {
|
||||
auto_repair = var.cluster_autoscaling.auto_provisioning_defaults.management.auto_repair
|
||||
auto_upgrade = var.cluster_autoscaling.auto_provisioning_defaults.management.auto_upgrade
|
||||
auto_repair = local.cas_apd.management.auto_repair
|
||||
auto_upgrade = local.cas_apd.management.auto_upgrade
|
||||
}
|
||||
}
|
||||
dynamic "shielded_instance_config" {
|
||||
for_each = var.cluster_autoscaling.auto_provisioning_defaults.shielded_instance_config != null ? [""] : []
|
||||
for_each = local.cas_apd.shielded_instance_config != null ? [""] : []
|
||||
content {
|
||||
enable_integrity_monitoring = var.cluster_autoscaling.auto_provisioning_defaults.shielded_instance_config.integrity_monitoring
|
||||
enable_secure_boot = var.cluster_autoscaling.auto_provisioning_defaults.shielded_instance_config.secure_boot
|
||||
enable_integrity_monitoring = (
|
||||
local.cas_apd.shielded_instance_config.integrity_monitoring
|
||||
)
|
||||
enable_secure_boot = (
|
||||
local.cas_apd.shielded_instance_config.secure_boot
|
||||
)
|
||||
}
|
||||
}
|
||||
dynamic "upgrade_settings" {
|
||||
for_each = local.cas_apd_us != null ? [""] : []
|
||||
content {
|
||||
strategy = (
|
||||
local.cas_apd_us.blue_green != null ? "BLUE_GREEN" : "SURGE"
|
||||
)
|
||||
max_surge = try(local.cas_apd_us.surge.max, null)
|
||||
max_unavailable = try(local.cas_apd_us.surge.unavailable, null)
|
||||
dynamic "blue_green_settings" {
|
||||
for_each = local.cas_apd_us.blue_green != null ? [""] : []
|
||||
content {
|
||||
node_pool_soak_duration = (
|
||||
local.cas_apd_us.blue_green.node_pool_soak_duration
|
||||
)
|
||||
dynamic "standard_rollout_policy" {
|
||||
for_each = (
|
||||
local.cas_apd_us.blue_green.standard_rollout_policy != null
|
||||
? [""]
|
||||
: []
|
||||
)
|
||||
content {
|
||||
batch_node_count = (
|
||||
local.cas_apd_us.blue_green.standard_rollout_policy.batch_node_count
|
||||
)
|
||||
batch_percentage = (
|
||||
local.cas_apd_us.blue_green.standard_rollout_policy.batch_percentage
|
||||
)
|
||||
batch_soak_duration = (
|
||||
local.cas_apd_us.blue_green.standard_rollout_policy.batch_soak_duration
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dynamic "resource_limits" {
|
||||
for_each = var.cluster_autoscaling.cpu_limits != null ? [""] : []
|
||||
for_each = local.cas.cpu_limits != null ? [""] : []
|
||||
content {
|
||||
resource_type = "cpu"
|
||||
minimum = var.cluster_autoscaling.cpu_limits.min
|
||||
maximum = var.cluster_autoscaling.cpu_limits.max
|
||||
minimum = local.cas.cpu_limits.min
|
||||
maximum = local.cas.cpu_limits.max
|
||||
}
|
||||
}
|
||||
dynamic "resource_limits" {
|
||||
for_each = var.cluster_autoscaling.mem_limits != null ? [""] : []
|
||||
for_each = local.cas.mem_limits != null ? [""] : []
|
||||
content {
|
||||
resource_type = "memory"
|
||||
minimum = var.cluster_autoscaling.mem_limits.min
|
||||
maximum = var.cluster_autoscaling.mem_limits.max
|
||||
minimum = local.cas.mem_limits.min
|
||||
maximum = local.cas.mem_limits.max
|
||||
}
|
||||
}
|
||||
dynamic "resource_limits" {
|
||||
for_each = (
|
||||
try(var.cluster_autoscaling.gpu_resources, null) == null
|
||||
try(local.cas.gpu_resources, null) == null
|
||||
? []
|
||||
: var.cluster_autoscaling.gpu_resources
|
||||
: local.cas.gpu_resources
|
||||
)
|
||||
iterator = gpu_resources
|
||||
content {
|
||||
|
@ -191,7 +229,6 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "database_encryption" {
|
||||
for_each = var.enable_features.database_encryption != null ? [""] : []
|
||||
content {
|
||||
|
@ -199,7 +236,6 @@ resource "google_container_cluster" "cluster" {
|
|||
key_name = var.enable_features.database_encryption.key_name
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "dns_config" {
|
||||
for_each = var.enable_features.dns != null ? [""] : []
|
||||
content {
|
||||
|
@ -208,31 +244,36 @@ resource "google_container_cluster" "cluster" {
|
|||
cluster_dns_domain = var.enable_features.dns.domain
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "gateway_api_config" {
|
||||
for_each = var.enable_features.gateway_api ? [""] : []
|
||||
content {
|
||||
channel = "CHANNEL_STANDARD"
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "ip_allocation_policy" {
|
||||
for_each = var.vpc_config.secondary_range_blocks != null ? [""] : []
|
||||
content {
|
||||
cluster_ipv4_cidr_block = var.vpc_config.secondary_range_blocks.pods
|
||||
services_ipv4_cidr_block = var.vpc_config.secondary_range_blocks.services
|
||||
stack_type = var.vpc_config.stack_type
|
||||
cluster_ipv4_cidr_block = (
|
||||
var.vpc_config.secondary_range_blocks.pods
|
||||
)
|
||||
services_ipv4_cidr_block = (
|
||||
var.vpc_config.secondary_range_blocks.services
|
||||
)
|
||||
stack_type = var.vpc_config.stack_type
|
||||
}
|
||||
}
|
||||
dynamic "ip_allocation_policy" {
|
||||
for_each = var.vpc_config.secondary_range_names != null ? [""] : []
|
||||
content {
|
||||
cluster_secondary_range_name = var.vpc_config.secondary_range_names.pods
|
||||
services_secondary_range_name = var.vpc_config.secondary_range_names.services
|
||||
stack_type = var.vpc_config.stack_type
|
||||
cluster_secondary_range_name = (
|
||||
var.vpc_config.secondary_range_names.pods
|
||||
)
|
||||
services_secondary_range_name = (
|
||||
var.vpc_config.secondary_range_names.services
|
||||
)
|
||||
stack_type = var.vpc_config.stack_type
|
||||
}
|
||||
}
|
||||
|
||||
# Send GKE cluster logs from chosen sources to Cloud Logging.
|
||||
# System logs must be enabled if any other source is enabled.
|
||||
# This is validated by input variable validation rules.
|
||||
|
@ -256,7 +297,6 @@ resource "google_container_cluster" "cluster" {
|
|||
enable_components = []
|
||||
}
|
||||
}
|
||||
|
||||
maintenance_policy {
|
||||
dynamic "daily_maintenance_window" {
|
||||
for_each = (
|
||||
|
@ -294,13 +334,11 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
master_auth {
|
||||
client_certificate_config {
|
||||
issue_client_certificate = var.issue_client_certificate
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "master_authorized_networks_config" {
|
||||
for_each = var.vpc_config.master_authorized_ranges != null ? [""] : []
|
||||
content {
|
||||
|
@ -314,14 +352,12 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "mesh_certificates" {
|
||||
for_each = var.enable_features.mesh_certificates != null ? [""] : []
|
||||
content {
|
||||
enable_certificates = var.enable_features.mesh_certificates
|
||||
}
|
||||
}
|
||||
|
||||
monitoring_config {
|
||||
enable_components = toset(compact([
|
||||
# System metrics is the minimum requirement if any other metrics are enabled. This is checked by input var validation.
|
||||
|
@ -342,7 +378,6 @@ resource "google_container_cluster" "cluster" {
|
|||
enabled = var.monitoring_config.enable_managed_prometheus
|
||||
}
|
||||
}
|
||||
|
||||
# Dataplane V2 has built-in network policies
|
||||
dynamic "network_policy" {
|
||||
for_each = (
|
||||
|
@ -355,7 +390,6 @@ resource "google_container_cluster" "cluster" {
|
|||
provider = "CALICO"
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "notification_config" {
|
||||
for_each = var.enable_features.upgrade_notifications != null ? [""] : []
|
||||
content {
|
||||
|
@ -369,7 +403,6 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "private_cluster_config" {
|
||||
for_each = (
|
||||
var.private_cluster_config != null ? [""] : []
|
||||
|
@ -383,21 +416,18 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "pod_security_policy_config" {
|
||||
for_each = var.enable_features.pod_security_policy ? [""] : []
|
||||
content {
|
||||
enabled = var.enable_features.pod_security_policy
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "release_channel" {
|
||||
for_each = var.release_channel != null ? [""] : []
|
||||
content {
|
||||
channel = var.release_channel
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "resource_usage_export_config" {
|
||||
for_each = (
|
||||
try(var.enable_features.resource_usage_export.dataset, null) != null
|
||||
|
@ -416,14 +446,12 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "vertical_pod_autoscaling" {
|
||||
for_each = var.enable_features.vertical_pod_autoscaling ? [""] : []
|
||||
content {
|
||||
enabled = var.enable_features.vertical_pod_autoscaling
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "workload_identity_config" {
|
||||
for_each = var.enable_features.workload_identity ? [""] : []
|
||||
content {
|
||||
|
@ -436,7 +464,11 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
|
||||
resource "google_gke_backup_backup_plan" "backup_plan" {
|
||||
for_each = var.backup_configs.enable_backup_agent ? var.backup_configs.backup_plans : {}
|
||||
for_each = (
|
||||
var.backup_configs.enable_backup_agent
|
||||
? var.backup_configs.backup_plans
|
||||
: {}
|
||||
)
|
||||
name = each.key
|
||||
cluster = google_container_cluster.cluster.id
|
||||
location = each.value.region
|
||||
|
@ -449,19 +481,20 @@ resource "google_gke_backup_backup_plan" "backup_plan" {
|
|||
backup_schedule {
|
||||
cron_schedule = each.value.schedule
|
||||
}
|
||||
|
||||
backup_config {
|
||||
include_volume_data = each.value.include_volume_data
|
||||
include_secrets = each.value.include_secrets
|
||||
|
||||
dynamic "encryption_key" {
|
||||
for_each = each.value.encryption_key != null ? [""] : []
|
||||
content {
|
||||
gcp_kms_encryption_key = each.value.encryption_key
|
||||
}
|
||||
}
|
||||
|
||||
all_namespaces = lookup(each.value, "namespaces", null) != null || lookup(each.value, "applications", null) != null ? null : true
|
||||
all_namespaces = (
|
||||
lookup(each.value, "namespaces", null) != null
|
||||
||
|
||||
lookup(each.value, "applications", null) != null ? null : true
|
||||
)
|
||||
dynamic "selected_namespaces" {
|
||||
for_each = each.value.namespaces != null ? [""] : []
|
||||
content {
|
||||
|
|
|
@ -54,6 +54,21 @@ variable "cluster_autoscaling" {
|
|||
integrity_monitoring = optional(bool, true)
|
||||
secure_boot = optional(bool, false)
|
||||
}))
|
||||
upgrade_settings = optional(object({
|
||||
blue_green = optional(object({
|
||||
node_pool_soak_duration = optional(string)
|
||||
standard_rollout_policy = optional(object({
|
||||
batch_percentage = optional(number)
|
||||
batch_node_count = optional(number)
|
||||
batch_soak_duration = optional(string)
|
||||
}))
|
||||
}))
|
||||
surge = optional(object({
|
||||
max = optional(number)
|
||||
unavailable = optional(number)
|
||||
}))
|
||||
}))
|
||||
# add validation rule to ensure only one is present if upgrade settings is defined
|
||||
}))
|
||||
cpu_limits = optional(object({
|
||||
min = number
|
||||
|
@ -71,13 +86,30 @@ variable "cluster_autoscaling" {
|
|||
})
|
||||
default = null
|
||||
validation {
|
||||
condition = (var.cluster_autoscaling == null ? true : contains(["BALANCED", "OPTIMIZE_UTILIZATION"], var.cluster_autoscaling.autoscaling_profile))
|
||||
condition = (var.cluster_autoscaling == null ? true : contains(
|
||||
["BALANCED", "OPTIMIZE_UTILIZATION"],
|
||||
var.cluster_autoscaling.autoscaling_profile
|
||||
))
|
||||
error_message = "Invalid autoscaling_profile."
|
||||
}
|
||||
validation {
|
||||
condition = (var.cluster_autoscaling == null ? true : contains(["pd-standard", "pd-ssd", "pd-balanced"], var.cluster_autoscaling.auto_provisioning_defaults.disk_type))
|
||||
condition = (
|
||||
var.cluster_autoscaling == null ? true : contains(
|
||||
["pd-standard", "pd-ssd", "pd-balanced"],
|
||||
var.cluster_autoscaling.auto_provisioning_defaults.disk_type)
|
||||
)
|
||||
error_message = "Invalid disk_type."
|
||||
}
|
||||
validation {
|
||||
condition = (
|
||||
try(var.cluster_autoscaling.upgrade_settings, null) == null || (
|
||||
try(var.cluster_autoscaling.upgrade_settings.blue_green, null) == null ? 0 : 1
|
||||
+
|
||||
try(var.cluster_autoscaling.upgrade_settings.surge, null) == null ? 0 : 1
|
||||
) == 1
|
||||
)
|
||||
error_message = "Upgrade settings can only use blue/green or surge."
|
||||
}
|
||||
}
|
||||
|
||||
variable "deletion_protection" {
|
||||
|
|
Loading…
Reference in New Issue