Support boot disk KMS key in GKE cluster modules (#1881)
* gke cluster standard * tfdoc * gke cluster autopilot * fix autopilot tags test
This commit is contained in:
parent
7baa1f98d4
commit
637926fb68
|
@ -208,8 +208,8 @@ module "cluster-1" {
|
|||
|---|---|:---:|:---:|:---:|
|
||||
| [location](variables.tf#L110) | Autopilot clusters are always regional. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L187) | Cluster name. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L213) | Cluster project ID. | <code>string</code> | ✓ | |
|
||||
| [vpc_config](variables.tf#L242) | 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> | ✓ | |
|
||||
| [project_id](variables.tf#L223) | Cluster project ID. | <code>string</code> | ✓ | |
|
||||
| [vpc_config](variables.tf#L239) | 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({ encryption_key = optional(string) include_secrets = optional(bool, true) include_volume_data = optional(bool, true) namespaces = optional(list(string)) region = string schedule = string retention_policy_days = optional(string) retention_policy_lock = optional(bool, false) retention_policy_delete_lock_days = optional(string) })), {}) })">object({…})</code> | | <code>{}</code> |
|
||||
| [deletion_protection](variables.tf#L37) | 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#L44) | Cluster description. | <code>string</code> | | <code>null</code> |
|
||||
|
@ -221,11 +221,10 @@ module "cluster-1" {
|
|||
| [maintenance_config](variables.tf#L126) | 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> |
|
||||
| [min_master_version](variables.tf#L149) | 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#L155) | Monitoring configuration. System metrics collection cannot be disabled. Control plane metrics are optional. Kube state metrics are optional. Google Cloud Managed Service for Prometheus is enabled by default. | <code title="object({ 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_locations](variables.tf#L192) | Zones in which the cluster's nodes are located. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [private_cluster_config](variables.tf#L199) | 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#L218) | Release channel for GKE upgrades. Clusters created in the Autopilot mode must use a release channel. Choose between \"RAPID\", \"REGULAR\", and \"STABLE\". | <code>string</code> | | <code>"REGULAR"</code> |
|
||||
| [service_account](variables.tf#L229) | The Google Cloud Platform Service Account to be used by the node VMs created by GKE Autopilot. | <code>string</code> | | <code>null</code> |
|
||||
| [tags](variables.tf#L235) | Network tags applied to nodes. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [node_config](variables.tf#L192) | Configuration for nodes and nodepools. | <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#L202) | Zones in which the cluster's nodes are located. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [private_cluster_config](variables.tf#L209) | 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#L228) | Release channel for GKE upgrades. Clusters created in the Autopilot mode must use a release channel. Choose between \"RAPID\", \"REGULAR\", and \"STABLE\". | <code>string</code> | | <code>"REGULAR"</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
|
@ -80,11 +80,9 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
|
||||
cluster_autoscaling {
|
||||
dynamic "auto_provisioning_defaults" {
|
||||
for_each = var.service_account != null ? [""] : []
|
||||
content {
|
||||
service_account = var.service_account
|
||||
}
|
||||
auto_provisioning_defaults {
|
||||
boot_disk_kms_key = var.node_config.boot_disk_kms_key
|
||||
service_account = var.node_config.service_account
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,10 +239,10 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
|
||||
dynamic "node_pool_auto_config" {
|
||||
for_each = length(var.tags) > 0 ? [""] : []
|
||||
for_each = var.node_config.tags != null ? [""] : []
|
||||
content {
|
||||
network_tags {
|
||||
tags = toset(var.tags)
|
||||
tags = toset(var.node_config.tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,6 +189,16 @@ variable "name" {
|
|||
type = string
|
||||
}
|
||||
|
||||
variable "node_config" {
|
||||
description = "Configuration for nodes and nodepools."
|
||||
type = object({
|
||||
boot_disk_kms_key = optional(string)
|
||||
service_account = optional(string)
|
||||
tags = optional(list(string))
|
||||
})
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "node_locations" {
|
||||
description = "Zones in which the cluster's nodes are located."
|
||||
type = list(string)
|
||||
|
@ -226,19 +236,6 @@ variable "release_channel" {
|
|||
}
|
||||
}
|
||||
|
||||
variable "service_account" {
|
||||
description = "The Google Cloud Platform Service Account to be used by the node VMs created by GKE Autopilot."
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
description = "Network tags applied to nodes."
|
||||
type = list(string)
|
||||
default = []
|
||||
nullable = false
|
||||
}
|
||||
|
||||
variable "vpc_config" {
|
||||
description = "VPC-level configuration."
|
||||
type = object({
|
||||
|
|
|
@ -312,8 +312,8 @@ module "cluster-1" {
|
|||
|---|---|:---:|:---:|:---:|
|
||||
| [location](variables.tf#L178) | Cluster zone or region. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L289) | Cluster name. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L315) | Cluster project id. | <code>string</code> | ✓ | |
|
||||
| [vpc_config](variables.tf#L338) | 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> | ✓ | |
|
||||
| [project_id](variables.tf#L325) | Cluster project id. | <code>string</code> | ✓ | |
|
||||
| [vpc_config](variables.tf#L336) | 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 = 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> |
|
||||
|
@ -327,11 +327,10 @@ module "cluster-1" {
|
|||
| [max_pods_per_node](variables.tf#L227) | Maximum number of pods per node in this cluster. | <code>number</code> | | <code>110</code> |
|
||||
| [min_master_version](variables.tf#L233) | 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#L239) | 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_locations](variables.tf#L294) | Zones in which the cluster's nodes are located. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [private_cluster_config](variables.tf#L301) | 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#L320) | Release channel for GKE upgrades. | <code>string</code> | | <code>null</code> |
|
||||
| [service_account](variables.tf#L326) | Service account used for the default node pool, only useful if the default GCE service account has been disabled. | <code>string</code> | | <code>null</code> |
|
||||
| [tags](variables.tf#L332) | Network tags applied to nodes. | <code>list(string)</code> | | <code>null</code> |
|
||||
| [node_config](variables.tf#L294) | 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#L304) | Zones in which the cluster's nodes are located. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [private_cluster_config](variables.tf#L311) | 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#L330) | Release channel for GKE upgrades. | <code>string</code> | | <code>null</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
|
@ -42,9 +42,11 @@ resource "google_container_cluster" "cluster" {
|
|||
)
|
||||
|
||||
# the default node pool is deleted here, use the gke-nodepool module instead.
|
||||
# the default node pool configuration is based on a shielded_nodes variable.
|
||||
# shielded nodes are controlled by the cluster-level enable_features variable
|
||||
node_config {
|
||||
service_account = var.service_account
|
||||
boot_disk_kms_key = var.node_config.boot_disk_kms_key
|
||||
service_account = var.node_config.service_account
|
||||
tags = var.node_config.tags
|
||||
dynamic "shielded_instance_config" {
|
||||
for_each = var.enable_features.shielded_nodes ? [""] : []
|
||||
content {
|
||||
|
@ -52,7 +54,6 @@ resource "google_container_cluster" "cluster" {
|
|||
enable_integrity_monitoring = true
|
||||
}
|
||||
}
|
||||
tags = var.tags
|
||||
}
|
||||
|
||||
addons_config {
|
||||
|
|
|
@ -291,6 +291,16 @@ variable "name" {
|
|||
type = string
|
||||
}
|
||||
|
||||
variable "node_config" {
|
||||
description = "Node-level configuration."
|
||||
type = object({
|
||||
boot_disk_kms_key = optional(string)
|
||||
service_account = optional(string)
|
||||
tags = optional(list(string))
|
||||
})
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "node_locations" {
|
||||
description = "Zones in which the cluster's nodes are located."
|
||||
type = list(string)
|
||||
|
@ -323,18 +333,6 @@ variable "release_channel" {
|
|||
default = null
|
||||
}
|
||||
|
||||
variable "service_account" {
|
||||
description = "Service account used for the default node pool, only useful if the default GCE service account has been disabled."
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
description = "Network tags applied to nodes."
|
||||
type = list(string)
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "vpc_config" {
|
||||
description = "VPC-level configuration."
|
||||
type = object({
|
||||
|
|
|
@ -5,10 +5,12 @@ vpc_config = {
|
|||
network = "default"
|
||||
subnetwork = "default"
|
||||
}
|
||||
tags = [
|
||||
"deep-dark-wood",
|
||||
"hello-gruffalo",
|
||||
"my--precious---nodes",
|
||||
"cluster-1-nodes",
|
||||
"nodes-cluster-1",
|
||||
]
|
||||
node_config = {
|
||||
tags = [
|
||||
"deep-dark-wood",
|
||||
"hello-gruffalo",
|
||||
"my--precious---nodes",
|
||||
"cluster-1-nodes",
|
||||
"nodes-cluster-1",
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue