# GKE cluster Autopilot module This module allows simplified creation and management of GKE Autopilot clusters. Some sensible defaults are set initially, in order to allow less verbose usage for most use cases. ## Example ### GKE Cluster ```hcl module "cluster-1" { source = "./fabric/modules/gke-cluster-autopilot" project_id = "myproject" name = "cluster-1" location = "europe-west1" vpc_config = { network = var.vpc.self_link subnetwork = var.subnet.self_link secondary_range_names = { pods = "pods" services = "services" } master_authorized_ranges = { internal-vms = "10.0.0.0/8" } master_ipv4_cidr_block = "192.168.0.0/28" } private_cluster_config = { enable_private_endpoint = true master_global_access = false } labels = { environment = "dev" } } # tftest modules=1 resources=1 inventory=basic.yaml ``` ### Cloud DNS This example shows how to [use Cloud DNS as a Kubernetes DNS provider](https://cloud.google.com/kubernetes-engine/docs/how-to/cloud-dns) for GKE Standard clusters. ```hcl module "cluster-1" { source = "./fabric/modules/gke-cluster-autopilot" project_id = var.project_id name = "cluster-1" location = "europe-west1" vpc_config = { network = var.vpc.self_link subnetwork = var.subnet.self_link secondary_range_names = { pods = "pods", services = "services" } } enable_features = { dns = { provider = "CLOUD_DNS" scope = "CLUSTER_SCOPE" domain = "gke.local" } } } # tftest modules=1 resources=1 inventory=dns.yaml ``` ### Logging configuration This example shows how to [collect logs for the Kubernetes control plane components](https://cloud.google.com/stackdriver/docs/solutions/gke/installing). The logs for these components are not collected by default. > **Note** > System and workload logs collection is pre-configured for Autopilot clusters and cannot be disabled. ```hcl module "cluster-1" { source = "./fabric/modules/gke-cluster-autopilot" project_id = var.project_id name = "cluster-1" location = "europe-west1" vpc_config = { network = var.vpc.self_link subnetwork = var.subnet.self_link } logging_config = { enable_api_server_logs = true enable_scheduler_logs = true enable_controller_manager_logs = true } } # tftest modules=1 resources=1 inventory=logging-config.yaml ``` ### Monitoring configuration This example shows how to [configure collection of Kubernetes control plane metrics](https://cloud.google.com/stackdriver/docs/solutions/gke/managing-metrics#enable-control-plane-metrics). The metrics for these components are not collected by default. > **Note** > System metrics collection is pre-configured for Autopilot clusters and cannot be disabled. > **Warning** > GKE **workload metrics** is deprecated and removed in GKE 1.24 and later. Workload metrics is replaced by [Google Cloud Managed Service for Prometheus](https://cloud.google.com/stackdriver/docs/managed-prometheus), which is Google's recommended way to monitor Kubernetes applications by using Cloud Monitoring. ```hcl module "cluster-1" { source = "./fabric/modules/gke-cluster-autopilot" project_id = var.project_id name = "cluster-1" location = "europe-west1" vpc_config = { network = var.vpc.self_link subnetwork = var.subnet.self_link } monitoring_config = { enable_api_server_metrics = true enable_controller_manager_metrics = true enable_scheduler_metrics = true } } # tftest modules=1 resources=1 inventory=monitoring-config-control-plane.yaml ``` ### Backup for GKE This example shows how to [enable the Backup for GKE agent and configure a Backup Plan](https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/concepts/backup-for-gke) for GKE Standard clusters. ```hcl module "cluster-1" { source = "./fabric/modules/gke-cluster-autopilot" project_id = var.project_id name = "cluster-1" location = "europe-west1" vpc_config = { network = var.vpc.self_link subnetwork = var.subnet.self_link secondary_range_names = { pods = "pods", services = "services" } } backup_configs = { enable_backup_agent = true backup_plans = { "backup-1" = { region = "europe-west-2" schedule = "0 9 * * 1" } } } } # tftest modules=1 resources=2 inventory=backup.yaml ``` ## Variables | name | description | type | required | default | |---|---|:---:|:---:|:---:| | [location](variables.tf#L110) | Autopilot cluster are always regional. | string | ✓ | | | [name](variables.tf#L170) | Cluster name. | string | ✓ | | | [project_id](variables.tf#L196) | Cluster project id. | string | ✓ | | | [vpc_config](variables.tf#L224) | VPC-level configuration. | object({…}) | ✓ | | | [backup_configs](variables.tf#L17) | Configuration for Backup for GKE. | object({…}) | | {} | | [description](variables.tf#L37) | Cluster description. | string | | null | | [enable_addons](variables.tf#L43) | Addons enabled in the cluster (true means enabled). | object({…}) | | {…} | | [enable_features](variables.tf#L64) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {} | | [issue_client_certificate](variables.tf#L98) | Enable issuing client certificate. | bool | | false | | [labels](variables.tf#L104) | Cluster resource labels. | map(string) | | null | | [logging_config](variables.tf#L115) | Logging configuration. | object({…}) | | {} | | [maintenance_config](variables.tf#L126) | Maintenance window configuration. | object({…}) | | {…} | | [min_master_version](variables.tf#L149) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | | [monitoring_config](variables.tf#L155) | Monitoring configuration. System metrics collection cannot be disabled for Autopilot clusters. Control plane metrics are optional. Google Cloud Managed Service for Prometheus is enabled by default. | object({…}) | | {} | | [node_locations](variables.tf#L175) | Zones in which the cluster's nodes are located. | list(string) | | [] | | [private_cluster_config](variables.tf#L182) | Private cluster configuration. | object({…}) | | null | | [release_channel](variables.tf#L201) | Release channel for GKE upgrades. Clusters created in the Autopilot mode must use a release channel. Choose between \"RAPID\", \"REGULAR\", and \"STABLE\". | string | | "REGULAR" | | [service_account](variables.tf#L212) | The Google Cloud Platform Service Account to be used by the node VMs created by GKE Autopilot. | string | | null | | [tags](variables.tf#L218) | Network tags applied to nodes. | list(string) | | null | ## Outputs | name | description | sensitive | |---|---|:---:| | [ca_certificate](outputs.tf#L17) | Public certificate of the cluster (base64-encoded). | ✓ | | [cluster](outputs.tf#L23) | Cluster resource. | ✓ | | [endpoint](outputs.tf#L29) | Cluster endpoint. | | | [id](outputs.tf#L34) | Fully qualified cluster id. | | | [location](outputs.tf#L39) | Cluster location. | | | [master_version](outputs.tf#L44) | Master version. | | | [name](outputs.tf#L49) | Cluster name. | | | [notifications](outputs.tf#L54) | GKE Pub/Sub notifications topic. | | | [self_link](outputs.tf#L59) | Cluster self link. | ✓ | | [workload_identity_pool](outputs.tf#L65) | Workload identity pool. | |