Technical Documentation: terraform-google-modules/terraform-google-kubernetes-engine
ℹ️ Provenance: Multi-Tier Ingestion · CodeWiki Reference
Overview (`README.md`)
Terraform Kubernetes Engine Module
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, IP MASQ, Network Policy, etc.
The resources/services/activations/deletions that this module will create/trigger are:
- Create a GKE cluster with the provided addons
- Create GKE Node Pool(s) with provided configuration and attach to cluster
- Replace the default kube-dns configmap if
stub_domainsare provided - Activate network policy if
network_policyis true - Add
ip-masq-agentconfigmap with providednon_masquerade_cidrsifconfigure_ip_masqis true
Sub modules are provided for creating private clusters, beta private clusters, and beta public clusters as well. Beta sub modules allow for the use of various GKE beta features. See the modules directory for the various sub modules.
Compatibility
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.14+.
If you find incompatibilities using Terraform >=1.3, please open an issue.
If you haven't upgraded to 1.3 and need a Terraform
0.13.x-compatible version of this module, the last released version
intended for Terraform 0.13.x is 27.0.0.
If you haven't upgraded to 0.13 and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is 12.3.0.
Usage
There are multiple examples included in the examples folder but simple usage is as follows:
/* Detailed source-code truncated for AI context efficiency. */Then perform the following commands on the root folder:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| add_cluster_firewall_rules | Create additional firewall rules | bool |
false |
no |
| 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 |
| additional_ip_range_pods | List of names of the additional secondary subnet ip ranges to use for pods | list(string) |
[] |
no |
| additional_ip_ranges_config | the configuration for individual additional subnetworks attached to the cluster | list(object({ subnetwork = string, pod_ipv4_range_names = list(string) })) |
[] |
no |
| additive_vpc_scope_dns_domain | This will enable Cloud DNS additive VPC scope. Must provide a domain name that is unique within the VPC. For this to work cluster_dns = CLOUD_DNS and cluster_dns_scope = CLUSTER_SCOPE must both be set as well. |
string |
"" |
no |
| agent_sandbox_enabled | The status of the Agent Sandbox addon, which isolates untrusted code execution (requires GKE version 1.35.2-gke.1269000 or later and a gVisor-enabled node pool) | bool |
null |
no |
| anonymous_authentication_config_mode | Allows users to restrict or enable anonymous access to the cluster. Valid values are ENABLED and LIMITED. |
string |
null |
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 [email protected] | string |
null |
no |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool, if not overridden in node_pools. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. For more information about protecting resources with Cloud KMS Keys please see: https://cloud.google.com/compute/docs/disks/customer-managed-encryption |
string |
null |
no |
| cluster_autoscaling | Cluster autoscaling configuration. See more details | object({ enabled = bool autoscaling_profile = string min_cpu_cores = optional(number) max_cpu_cores = optional(number) min_memory_gb = optional(number) max_memory_gb = optional(number) gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number })) auto_repair = bool auto_upgrade = bool disk_size = optional(number) disk_type = optional(string) image_type = optional(string) strategy = optional(string) max_surge = optional(number) max_unavailable = optional(number) node_pool_soak_duration = optional(string) batch_soak_duration = optional(string) batch_percentage = optional(number) batch_node_count = optional(number) enable_secure_boot = optional(bool, false) enable_integrity_monitoring = optional(bool, true) enable_default_compute_class = optional(bool, false) }) | { "auto_repair": true, "auto_upgrade": true, "autoscaling_profile": "BALANCED", "disk_size": 100, "disk_type": "pd-standard", "enable_default_compute_class": false, "enable_integrity_monitoring": true, "enable_secure_boot": false, "enabled": false, "gpu_resources": [], "image_type": "COS_CONTAINERD", "max_cpu_cores": 0, "max_memory_gb": 0, "min_cpu_cores": 0, "min_memory_gb": 0} | 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 |
| cluster_ipv4_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string |
null |
no |
| cluster_resource_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) |
{} |
no |
| config_connector | Whether ConfigConnector is enabled for this cluster. | bool |
false |
no |
| configure_ip_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | bool |
false |
no |
| create_service_account | Defines if service account specified to run nodes should be created. | bool |
true |
no |
| database_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | list(object({ state = string, key_name = string })) |
[ { "key_name": "", "state": "DECRYPTED" }] | no |
| datapath_provider | 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. |
string |
"DATAPATH_PROVIDER_UNSPECIFIED" |
no |
| default_max_pods_per_node | The maximum number of pods to schedule per node | number |
110 |
no |
| deletion_protection | Whether or not to allow Terraform to destroy the cluster. | bool |
true |
no |
| description | The description of the cluster | string |
"" |
no |
| disable_default_snat | Whether to disable the default SNAT to support the private use of public IP addresses | bool |
false |
no |
| disable_l4_lb_firewall_reconciliation | Disable L4 Load Balancer firewall reconciliation | bool |
null |
no |
| disable_legacy_metadata_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | bool |
true |
no |
| dns_allow_external_traffic | (Optional) Controls whether external traffic is allowed over the dns endpoint. | bool |
null |
no |
| dns_cache | The status of the NodeLocal DNSCache addon. | bool |
false |
no |
| dns_enable_k8s_tokens_via_dns | (Optional) Controls whether Kubernetes ServiceAccount token authentication is allowed via the DNS endpoint. | bool |
null |
no |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| enable_cilium_clusterwide_network_policy | Enable Cilium Cluster Wide Network Policies on the cluster | bool |
false |
no |
| enable_confidential_nodes | An optional flag to enable confidential node config. | bool |
false |
no |
| enable_cost_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | bool |
false |
no |
| enable_default_node_pools_metadata | Whether to enable the default node pools metadata key-value pairs such as cluster_name and node_pool |
bool |
true |
no |
| enable_fqdn_network_policy | Enable FQDN Network Policies on the cluster | bool |
null |
no |
| enable_gcfs | Enable image streaming on cluster level. | bool |
false |
no |
| enable_identity_service | (Optional) Enable the Identity Service component, which allows customers to use external identity providers with the K8S API. NOTE: Starting on July 1, 2025, new Google Cloud organizations that you create won't support Identity Service for GKE. | bool |
false |
no |
| enable_intranode_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | bool |
false |
no |
| enable_k8s_beta_apis | (Optional) - List of Kubernetes Beta APIs to enable in cluster. | list(string) |
[] |
no |
| enable_kubernetes_alpha | Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days. | bool |
false |
no |
| enable_l4_ilb_subsetting | Enable L4 ILB Subsetting on the cluster | bool |
false |
no |
| enable_legacy_lustre_port | Set it to true for GKE cluster runs a version earlier than 1.33.2-gke.4780000. Allows the Lustre CSI driver to initialize LNet (the virtual network layer for Lustre kernel module) using port 6988. This flag is required to workaround a port conflict with the gke-metadata-server on GKE nodes | bool |
false |
no |
| enable_mesh_certificates | Controls the issuance of workload mTLS certificates. When enabled the GKE Workload Identity Certificates controller and node agent will be deployed in the cluster. Requires Workload Identity. | bool |
false |
no |
| enable_multi_networking | Whether multi-networking is enabled for this cluster | bool |
null |
no |
| enable_network_egress_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | bool |
false |
no |
| enable_resource_consumption_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | bool |
true |
no |
| enable_secret_manager_addon | Enable the Secret Manager add-on for this cluster | bool |
false |
no |
| enable_shielded_nodes | Enable Shielded Nodes features on all nodes in this cluster | bool |
true |
no |
| enable_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| enable_vertical_pod_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool |
false |
no |
| enterprise_config | (Optional) Enable or disable GKE enterprise. Valid values are STANDARD and ENTERPRISE. | string |
null |
no |
| filestore_csi_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | bool |
false |
no |
| firewall_inbound_ports | List of TCP ports for admission/webhook controllers. Either flag add_master_webhook_firewall_rules or add_cluster_firewall_rules (also adds egress rules) must be set to true for inbound-ports firewall rules to be applied. |
list(string) |
[ "8443", "9443", "15017"] | no |
| firewall_priority | Priority rule for firewall rules | number |
1000 |
no |
| fleet_project | (Optional) Register the cluster with the fleet in this project. | string |
null |
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 |
| gcp_public_cidrs_access_enabled | Allow access through Google Cloud public IP addresses | bool |
null |
no |
| gcs_fuse_csi_driver | Whether GCE FUSE CSI driver is enabled for this cluster. | bool |
false |
no |
| gke_auto_upgrade_config_patch_mode | The selected auto-upgrade patch type. Accepted values are: ACCELERATED: Upgrades to the latest available patch version in a given minor and release channel. |
string |
null |
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 |
| hpa_profile | Enable the Horizontal Pod Autoscaling profile for this cluster. Values are "NONE" and "PERFORMANCE". | string |
"" |
no |
| http_load_balancing | Enable httpload balancer addon | bool |
true |
no |
| identity_namespace | The workload pool to attach all Kubernetes service accounts to. (Default value of enabled automatically sets project-based pool [project_id].svc.id.goog) |
string |
"enabled" |
no |
| in_transit_encryption_config | Defines the config of in-transit encryption. Valid values are IN_TRANSIT_ENCRYPTION_DISABLED and IN_TRANSIT_ENCRYPTION_INTER_NODE_TRANSPARENT. |
string |
null |
no |
| initial_node_count | The number of nodes to create in this cluster's default node pool. | number |
0 |
no |
| insecure_kubelet_readonly_port_enabled | Whether or not to set insecure_kubelet_readonly_port_enabled for node pool defaults and autopilot clusters. Note: this can be set at the node pool level separately within node_pools. |
bool |
null |
no |
| ip_endpoints_enabled | (Optional) Controls whether to allow direct IP access. Defaults to true. |
bool |
null |
no |
| ip_masq_link_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | bool |
false |
no |
| ip_masq_resync_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string |
"60s" |
no |
| ip_range_pods | The name of the secondary subnet ip range to use for pods | string |
n/a | yes |
| ip_range_services | The name of the secondary subnet range to use for services. If not provided, the default 34.118.224.0/20 range will be used. |
string |
null |
no |
| issue_client_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| kubernetes_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string |
"latest" |
no |
| logging_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, KCP_CONNECTION, KCP_SSHD, KCP_HPA, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration. | list(string) |
[] |
no |
| logging_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string |
"logging.googleapis.com/kubernetes" |
no |
| logging_variant | (Optional) The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | string |
null |
no |
| lustre_csi_driver | The status of the Lustre CSI driver addon, which allows the usage of a Lustre instances as volumes | bool |
null |
no |
| maintenance_end_time | Time window specified for recurring maintenance operations in RFC3339 format | string |
"" |
no |
| maintenance_exclusions | List of maintenance exclusions. A cluster can have up to three | list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string })) |
[] |
no |
| maintenance_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string |
"" |
no |
| maintenance_start_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string |
"05:00" |
no |
| master_authorized_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | list(object({ cidr_block = string, display_name = string })) |
[] |
no |
| monitoring_auto_monitoring_config_scope | Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE | string |
"NONE" |
no |
| monitoring_enable_managed_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | bool |
null |
no |
| monitoring_enable_observability_metrics | Whether or not the advanced datapath metrics are enabled. | bool |
false |
no |
| monitoring_enable_observability_relay | Whether or not the advanced datapath relay is enabled. | bool |
false |
no |
| monitoring_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR, DCGM, and JOBSET. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. JOBSET is only supported in GKE 1.32.1-gke.1357001 and above. Empty list is default GKE configuration. | list(string) |
[] |
no |
| monitoring_metric_writer_role | The monitoring metrics writer role to assign to the GKE node service account | string |
"roles/monitoring.metricWriter" |
no |
| monitoring_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string |
"monitoring.googleapis.com/kubernetes" |
no |
| name | The name of the cluster (required) | string |
n/a | yes |
| network | The VPC network to host the cluster in (required) | string |
n/a | yes |
| network_policy | Enable network policy addon | bool |
false |
no |
| network_policy_provider | The network policy provider. | string |
"CALICO" |
no |
| network_project_id | The project ID of the shared VPC's host (for shared vpc support) | string |
"" |
no |
| network_tags | (Optional) - List of network tags applied to autopilot and auto-provisioned node pools. | list(string) |
[] |
no |
| network_tier_config | Network tier configuration for the cluster | string |
null |
no |
| node_metadata | Specifies how node metadata is exposed to the workload running on the node | string |
"GKE_METADATA" |
no |
| node_pools | List of maps containing node pools | list(map(any)) |
[ { "name": "default-node-pool" }] | no |
| node_pools_cgroup_mode | Map of strings containing cgroup node config by node-pool name. Note: GKE is removing cgroup v1 support in 1.35. | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_1g | Map of strings containing hugepage size 1g config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_2m | Map of strings containing hugepage size 2m node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_labels | Map of maps containing node labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_linux_node_configs_sysctls | Map of maps containing linux node config sysctls by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_oauth_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) |
{ "all": [ "https://www.googleapis.com/auth/cloud-platform" ], "default-node-pool": []} | no |
| node_pools_resource_labels | Map of maps containing resource labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_resource_manager_tags | Map of maps containing resource manager tags by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_tags | Map of lists containing node network tags by node-pool name | map(list(string)) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_taints | Map of lists containing node taints by node-pool name | map(list(object({ key = string, value = string, effect = string }))) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_transparent_hugepage_defrag | Map of strings containing transparent hugepage defrag node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_transparent_hugepage_enabled | Map of strings containing transparent hugepage enabled node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| non_masquerade_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) |
[ "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"] | no |
| notification_config_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | string |
"" |
no |
| notification_filter_event_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT. | list(string) |
[] |
no |
| parallelstore_csi_driver | Whether the Parallelstore CSI driver Addon is enabled for this cluster. | bool |
null |
no |
| project_id | The project ID to host the cluster in (required) | string |
n/a | yes |
| ray_operator_config | The Ray Operator Addon configuration for this cluster. | object({ enabled = bool logging_enabled = optional(bool, false) monitoring_enabled = optional(bool, false) }) | { "enabled": false, "logging_enabled": false, "monitoring_enabled": false} | no |
| rbac_binding_config | RBACBindingConfig allows user to restrict ClusterRoleBindings an RoleBindings that can be created. | object({ enable_insecure_binding_system_unauthenticated = optional(bool, null) enable_insecure_binding_system_authenticated = optional(bool, null) }) | { "enable_insecure_binding_system_authenticated": null, "enable_insecure_binding_system_unauthenticated": null} | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string |
null |
no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool |
true |
no |
| registry_project_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the grant_registry_access variable is set to true, the storage.objectViewer and artifactregsitry.reader roles are assigned on these projects. |
list(string) |
[] |
no |
| release_channel | The release channel of this cluster. Accepted values are UNSPECIFIED, RAPID, REGULAR and STABLE. Defaults to REGULAR. |
string |
"REGULAR" |
no |
| remove_default_node_pool | Remove default node pool while setting up the cluster | bool |
false |
no |
| resource_manager_tags | (Optional) - List of resource manager tags applied to autopilot and auto-provisioned node pools. A maximum of 5 tags can be specified. Tags must be in one of these formats: "tagKeys/{tag_key_id}"="tagValues/{tag_value_id}", "{org_id}/{tag_key_name}"="{tag_value_name}", "{project_id}/{tag_key_name}"="{tag_value_name}". | map(string) |
{} |
no |
| resource_usage_export_dataset_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | string |
"" |
no |
| security_posture_mode | Security posture mode. Accepted values are DISABLED and BASIC. Defaults to DISABLED. |
string |
"DISABLED" |
no |
| security_posture_vulnerability_mode | Security posture vulnerability mode. Accepted values are VULNERABILITY_DISABLED, VULNERABILITY_BASIC, and VULNERABILITY_ENTERPRISE. Defaults to VULNERABILITY_DISABLED. |
string |
"VULNERABILITY_DISABLED" |
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. This service account should already exists and it will be used by the node pools. If you wish to only override the service account name, you can use service_account_name variable. |
string |
"" |
no |
| service_account_name | The name of the service account that will be created if create_service_account is true. If you wish to use an existing service account, use service_account variable. | string |
"" |
no |
| service_external_ips | Whether external ips specified by a service will be allowed in this cluster | bool |
false |
no |
| shadow_firewall_rules_log_config | The log_config for shadow firewall rules. You can set this variable to null to disable logging. |
object({ metadata = string }) | { "metadata": "INCLUDE_ALL_METADATA"} | 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 |
| stack_type | The stack type to use for this cluster. Either IPV4 or IPV4_IPV6. Defaults to IPV4. |
string |
"IPV4" |
no |
| stateful_ha | Whether the Stateful HA Addon is enabled for this cluster. | 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 |
| subnetwork | The subnetwork to host the cluster in (required) | string |
n/a | yes |
| timeouts | Timeout for cluster operations. | map(string) |
{} |
no |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier for NodePools in the cluster. Valid values are TIER_UNSPECIFIED and TIER_1. Defaults to TIER_UNSPECIFIED. |
string |
null |
no |
| upstream_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list(string) |
[] |
no |
| user_managed_keys_config | The User Managed Keys configuration for the cluster. | object({ aggregation_ca = optional(string) cluster_ca = optional(string) control_plane_disk_encryption_key = optional(string) etcd_api_ca = optional(string) etcd_peer_ca = optional(string) gkeops_etcd_backup_encryption_key = optional(string) service_account_signing_keys = optional(list(string)) service_account_verification_keys = optional(list(string)) }) | null |
no |
| windows_node_pools | List of maps containing Windows node pools | list(map(string)) |
[] |
no |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cluster_id | Cluster ID |
| dns_cache_enabled | Whether DNS Cache enabled |
| endpoint | Cluster endpoint |
| endpoint_dns | Cluster endpoint DNS |
| fleet_membership | Fleet membership (if registered) |
| gateway_api_channel | The gateway api channel of this cluster. |
| horizontal_pod_autoscaling_enabled | Whether horizontal pod autoscaling enabled |
| http_load_balancing_enabled | Whether http load balancing enabled |
| identity_namespace | Workload Identity pool |
| identity_service_enabled | Whether Identity Service is enabled |
| instance_group_urls | List of GKE generated instance groups |
| intranode_visibility_enabled | Whether intra-node visibility is enabled |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| logging_service | Logging service used |
| master_authorized_networks_config | Networks from which access to master is permitted |
| master_version | Current master kubernetes version |
| mesh_certificates_config | Mesh certificates configuration |
| min_master_version | Minimum master kubernetes version |
| monitoring_service | Monitoring service used |
| name | Cluster name |
| network_policy_enabled | Whether network policy enabled |
| node_pools_names | List of node pools names |
| node_pools_versions | Node pool versions by node pool name |
| region | Cluster region |
| release_channel | The release channel of this cluster |
| secret_manager_addon_enabled | Whether Secret Manager add-on is enabled |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| tpu_ipv4_cidr_block | The IP range in CIDR notation used for the TPUs |
| type | Cluster type (regional / zonal) |
| vertical_pod_autoscaling_enabled | Whether vertical pod autoscaling enabled |
| zones | List of zones in which the cluster resides |
node_pools variable
Use this variable for provisioning linux based node pools. For Windows based node pools use windows_node_pools
The node_pools variable takes the following parameters:
| Name | Description | Default | Requirement |
|---|---|---|---|
| accelerator_count | The number of the guest accelerator cards exposed to this instance | 0 | Optional |
| accelerator_type | The accelerator type resource to expose to the instance | " " | Optional |
| auto_repair | Whether the nodes will be automatically repaired | true | Optional |
| autoscaling | Configuration required by cluster autoscaler to adjust the size of the node pool to the current cluster usage | true | Optional |
| auto_upgrade | Whether the nodes will be automatically upgraded | true (if cluster is regional) | Optional |
| storage_pools | The list of Storage Pools where boot disks are provisioned. | Optional | |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. | " " | Optional |
| cpu_manager_policy | The CPU manager policy on the node. One of "none" or "static". | "static" | Optional |
| cpu_cfs_quota | Enforces the Pod's CPU limit. Setting this value to false means that the CPU limits for Pods are ignored | null | Optional |
| cpu_cfs_quota_period | The CPU CFS quota period value, which specifies the period of how often a cgroup's access to CPU resources should be reallocated | null | Optional |
| pod_pids_limit | Controls the maximum number of processes allowed to run in a pod. The value must be greater than or equal to 1024 and less than 4194304. | null | Optional |
| container_log_max_size | Defines the maximum size of the container log file before it is rotated. | null | Optional |
| container_log_max_files | Defines the maximum number of container log files that can be present for a container. | null | Optional |
| image_gc_low_threshold_percent | Defines the percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to. | null | Optional |
| image_gc_high_threshold_percent | Defines the percent of disk usage after which image garbage collection is always run. | null | Optional |
| image_minimum_gc_age | Defines the minimum age for an unused image before it is garbage collected. | null | Optional |
| image_maximum_gc_age | Defines the maximum age an image can be unused before it is garbage collected. | null | Optional |
| allowed_unsafe_sysctls | Defines a comma-separated allowlist of unsafe sysctls or sysctl patterns which can be set on the Pods. This should be passed as comma separated string. | null | Optional |
| enable_confidential_nodes | An optional flag to enable confidential node config. | false | Optional |
| disk_size_gb | Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB | 100 | Optional |
| disk_type | Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') | pd-standard | Optional |
| provisioned_iops | Indicates how many IOPS to provision for the disk. This sets the number of I/O operations per second that the disk can handle. For more details, see the Hyperdisk documentation. | null | Optional |
| provisioned_throughput | Indicates how much throughput to provision for the disk, in MB/s. This sets the amount of data that can be read or written to the disk per second. For more details, see the Hyperdisk documentation. | null | Optional |
| effect | Effect for the taint | Required | |
| enable_fast_socket | Enable the NCCL Fast Socket feature. enable_gvnic must also be enabled. |
null | Optional |
| enable_gcfs | Google Container File System (gcfs) has to be enabled for image streaming to be active. Needs image_type to be set to COS_CONTAINERD. | false | Optional |
| enable_gvnic | gVNIC (GVE) is an alternative to the virtIO-based ethernet driver. Needs a Container-Optimized OS node image. | false | Optional |
| enable_integrity_monitoring | Enables monitoring and attestation of the boot integrity of the instance. The attestation is performed against the integrity policy baseline. This baseline is initially derived from the implicitly trusted boot image when the instance is created. | true | Optional |
| enable_secure_boot | Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. | false | Optional |
| gpu_driver_version | Mode for how the GPU driver is installed | null | Optional |
| gpu_partition_size | Size of partitions to create on the GPU | null | Optional |
| image_type | The image type to use for this node. Note that changing the image type will delete and recreate all nodes in the node pool | COS_CONTAINERD | Optional |
| initial_node_count | The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. Changing this will force recreation of the resource. Defaults to the value of min_count | " " | Optional |
| insecure_kubelet_readonly_port_enabled | (boolean) Whether or not to enable the insecure Kubelet readonly port. | null | Optional |
| single_process_oom_kill | (boolean) On cgroupv2 nodes, defines whether processes in the container are OOM killed individually (true) or as a group (false, the kubelet default). Leave null to keep the kubelet default. | null | Optional |
| key | The key required for the taint | Required | |
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a hostpath volume or a local PersistentVolume. |
0 | Optional |
| local_ssd_ephemeral_storage_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| ephemeral_storage_local_ssd_data_cache_count | Number of raw-block local NVMe SSD disks to be attached to the node utilized for GKE Data Cache. | 0 | Optional |
| local_nvme_ssd_count | Number of raw-block local NVMe SSD disks to be attached to the node.Each local SSD is 375 GB in size. If zero, it means no raw-block local NVMe SSD disks to be attached to the node. | 0 | Optional |
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
| enable_confidential_storage | Enabling Confidential Storage will create boot disk with confidential mode. | false | Optional |
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
| strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: SURGE, BLUE_GREEN, or for flex-start and queued provisioning SHORT_LIVED |
"SURGE" | Optional |
| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional |
| enable_nested_virtualization | Whether the node should have nested virtualization | null | Optional |
| performance_monitoring_unit | Level of Performance Monitoring Unit (PMU) requested. If unset, no access to the PMU is assumed. Values values are: ARCHITECTURAL, STANDARD, and ENHANCED |
null | Optional |
| max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with SURGE strategy. |
1 | Optional |
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with SURGE strategy. |
0 | Optional |
| node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with BLUE_GREEN strategy. |
"3600s" | Optional |
| batch_soak_duration | Soak time after each batch gets drained, with the default being zero seconds. Only works with BLUE_GREEN strategy. |
"0s" | Optional |
| batch_node_count | Absolute number of nodes to drain in a batch. If it is set to zero, this phase will be skipped. Cannot be used together with batch_percentage. Only works with BLUE_GREEN strategy. |
1 | Optional |
| batch_percentage | Percentage of nodes to drain in a batch. Must be in the range of [0.0, 1.0]. If it is set to zero, this phase will be skipped. Cannot be used together with batch_node_count. Only works with BLUE_GREEN strategy. |
null | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
| name | The name of the node pool | Required | |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as COMPACT if desired | Optional | |
| policy_name | If set, refers to the name of a custom resource policy supplied by the user. The resource policy must be in the same project and region as the node pool. | Optional | |
| tpu_topology | TPU placement topology for pod slice node pool. For detail see documentation | Optional | |
| pod_range | The name of the secondary range for pod IPs. | Optional | |
| enable_private_nodes | Whether nodes have internal IP addresses only. | Optional | |
| node_affinity | The node affinty in the format "{\"key\": \"compute.googleapis.com/node-group-name\", \"operator\": \"IN\", \"values\": [\"node-group-name\"]}". |
Optional | |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | Required | |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
| node_metadata | Options to expose the node metadata to the workload running on the node | Optional | |
| preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional |
| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional |
| service_account | The service account to be used by the Node VMs | " " | Optional |
| tags | The list of instance tags applied to all nodes | Required | |
| value | The value for the taint | Required | |
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
| location_policy | Location policy specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see documentation. gcfs_config must be enabled=true for this feature to work. |
Optional | |
| secondary_boot_disk_mode | Mode for the secondary boot disk. Defaults to CONTAINER_IMAGE_CACHE (preloads container images, requires gcfs_config enabled). Set to null to omit the field for data preloading (mounts data onto nodes for use via hostPath). |
"CONTAINER_IMAGE_CACHE" |
Optional |
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | Optional | |
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | Optional | |
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | Optional | |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier. Valid values are: "TIER_1" and "TIER_UNSPECIFIED". | Optional | |
| pod_cidr_overprovision_disabled | Disables GKE's default doubling of the per-node pod IP range allocation when set to true. |
Optional | |
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | Optional | |
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | Optional | |
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | Optional | |
| local_ssd_encryption_mode | specifies the method used for encrypting the local SSDs attached to the node. Valid values are: "STANDARD_ENCRYPTION" and "EPHEMERAL_KEY_ENCRYPTION" | Optional | |
| max_run_duration | The runtime of each node in the node pool in seconds, terminated by 's'. Example: "3600s". | null | Optional |
| flex_start | Enables Flex Start provisioning model for the node pool | null | Optional |
| respect_pdb_during_node_pool_deletion | Whether to respect Pod Disruption Budgets during node pool deletion. | null | Optional |
windows_node_pools variable
The windows_node_pools variable takes the same parameters as node_pools but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a specific requirement for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.
| Name | Description | Default | Requirement |
|---|---|---|---|
| windows_node_config_os_version | The Windows OS version to use for the windows node pool. Valid values are OS_VERSION_UNSPECIFIED, OS_VERSION_LTSC2019 and OS_VERSION_LTSC2022. | null | Optional |
Requirements
Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:
- Terraform and kubectl are installed on the machine where Terraform is executed.
- The Service Account you execute the module with has the right permissions.
- The Compute Engine and Kubernetes Engine APIs are active on the project you will launch the cluster in.
- If you are using a Shared VPC, the APIs must also be activated on the Shared VPC host project and your service account needs the proper permissions there.
The project factory can be used to provision projects with the correct APIs active and the necessary Shared VPC connections.
Software Dependencies
Kubectl
- kubectl 1.9.x
Terraform and Plugins
- Terraform 1.3+
- Terraform Provider for GCP v7.39+
gcloud
Some submodules use the terraform-google-gcloud module. By default, this module assumes you already have gcloud installed in your $PATH.
See the module documentation for more information.
Configure a Service Account
In order to execute this module you must have a Service Account with the
following project roles:
- roles/compute.viewer
- roles/compute.securityAdmin (only required if
add_cluster_firewall_rulesis set totrue) - roles/container.clusterAdmin
- roles/container.developer
- roles/iam.serviceAccountAdmin
- roles/iam.serviceAccountUser
- roles/resourcemanager.projectIamAdmin (only required if
service_accountis set tocreate)
Additionally, if service_account is set to create and grant_registry_access is requested, the service account requires the following role on the registry_project_ids projects:
- roles/resourcemanager.projectIamAdmin
Enable APIs
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
- Compute Engine API - compute.googleapis.com
- Kubernetes Engine API - container.googleapis.com
Overview (`autogen/main/README.md`)
Terraform Kubernetes Engine Module
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, {% if autopilot_cluster != true%}IP MASQ, {% endif %}Network Policy, etc.{% if private_cluster %} This particular submodule creates a private cluster{% endif %}{% if beta_cluster %}Beta features are enabled in this submodule.{% endif %}
The resources/services/activations/deletions that this module will create/trigger are:
- Create a GKE cluster with the provided addons
- Create GKE Node Pool(s) with provided configuration and attach to cluster
- Replace the default kube-dns configmap if
stub_domainsare provided - Activate network policy if
network_policyis true
{% if autopilot_cluster != true%} - Add
ip-masq-agentconfigmap with providednon_masquerade_cidrsifconfigure_ip_masqis true
{% endif %}
Sub modules are provided for creating private clusters, beta private clusters, and beta public clusters as well. Beta sub modules allow for the use of various GKE beta features. See the modules directory for the various sub modules.
{% if private_cluster %}
Private Cluster Details
For details on configuring private clusters with this module, check the troubleshooting guide.
{% endif %}
{% if update_variant %}
Node Pool Update Variant
In [#256] update variants added support for node pools to be created before being destroyed.
Before, if a node pool has to be recreated for any number of reasons,
the node pool is deleted then, created. This can be a problem if it is the only node pool in the GKE
cluster and the new node pool cannot be provisioned. In this scenario, pods could not be scheduled.
[#256] allows a node pool to be created before it is deleted so that any issues with node pool creation
and/or provisioning are discovered before the node pool is removed. This feature is controlled by the
variable node_pools_create_before_destroy. In order to avoid node pool name collisions,
a 4 character alphanumeric is added as a suffix to the name.
The benefit is that you always have some node pools active.
We don't actually cordon/drain the traffic beyond what the GKE API itself will do,
but we do make sure the new node pool is created before the old one is destroyed.
The implications of this are that:
- We append a random ID on the node pool names (since you can't have two simultaneously active node pools)
- For a brief period, you'll have 2x as many resources/node pools
- You will indeed need sufficient IP space (and compute capacity) to create both node pools
{% endif %}
Compatibility
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.14+.
If you find incompatibilities using Terraform >=1.3, please open an issue.
If you haven't upgraded to 1.3 and need a Terraform
0.13.x-compatible version of this module, the last released version
intended for Terraform 0.13.x is 27.0.0.
If you haven't upgraded to 0.13 and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is 12.3.0.
Usage
There are multiple examples included in the examples folder but simple usage is as follows:
/* Detailed source-code truncated for AI context efficiency. */Then perform the following commands on the root folder:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
{% if autopilot_cluster != true %}
node_pools variable
Use this variable for provisioning linux based node pools. For Windows based node pools use windows_node_pools
The node_pools variable takes the following parameters:
| Name | Description | Default | Requirement |
|---|---|---|---|
| accelerator_count | The number of the guest accelerator cards exposed to this instance | 0 | Optional |
| accelerator_type | The accelerator type resource to expose to the instance | " " | Optional |
| auto_repair | Whether the nodes will be automatically repaired | true | Optional |
| autoscaling | Configuration required by cluster autoscaler to adjust the size of the node pool to the current cluster usage | true | Optional |
| auto_upgrade | Whether the nodes will be automatically upgraded | true (if cluster is regional) | Optional |
| storage_pools | The list of Storage Pools where boot disks are provisioned. | Optional | |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. | " " | Optional |
| cpu_manager_policy | The CPU manager policy on the node. One of "none" or "static". | "static" | Optional |
| cpu_cfs_quota | Enforces the Pod's CPU limit. Setting this value to false means that the CPU limits for Pods are ignored | null | Optional |
| cpu_cfs_quota_period | The CPU CFS quota period value, which specifies the period of how often a cgroup's access to CPU resources should be reallocated | null | Optional |
| pod_pids_limit | Controls the maximum number of processes allowed to run in a pod. The value must be greater than or equal to 1024 and less than 4194304. | null | Optional |
| container_log_max_size | Defines the maximum size of the container log file before it is rotated. | null | Optional |
| container_log_max_files | Defines the maximum number of container log files that can be present for a container. | null | Optional |
| image_gc_low_threshold_percent | Defines the percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to. | null | Optional |
| image_gc_high_threshold_percent | Defines the percent of disk usage after which image garbage collection is always run. | null | Optional |
| image_minimum_gc_age | Defines the minimum age for an unused image before it is garbage collected. | null | Optional |
| image_maximum_gc_age | Defines the maximum age an image can be unused before it is garbage collected. | null | Optional |
| allowed_unsafe_sysctls | Defines a comma-separated allowlist of unsafe sysctls or sysctl patterns which can be set on the Pods. This should be passed as comma separated string. | null | Optional |
| enable_confidential_nodes | An optional flag to enable confidential node config. | false | Optional |
| disk_size_gb | Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB | 100 | Optional |
| disk_type | Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') | pd-standard | Optional |
| provisioned_iops | Indicates how many IOPS to provision for the disk. This sets the number of I/O operations per second that the disk can handle. For more details, see the Hyperdisk documentation. | null | Optional |
| provisioned_throughput | Indicates how much throughput to provision for the disk, in MB/s. This sets the amount of data that can be read or written to the disk per second. For more details, see the Hyperdisk documentation. | null | Optional |
| effect | Effect for the taint | Required | |
| enable_fast_socket | Enable the NCCL Fast Socket feature. enable_gvnic must also be enabled. |
null | Optional |
| enable_gcfs | Google Container File System (gcfs) has to be enabled for image streaming to be active. Needs image_type to be set to COS_CONTAINERD. | false | Optional |
| enable_gvnic | gVNIC (GVE) is an alternative to the virtIO-based ethernet driver. Needs a Container-Optimized OS node image. | false | Optional |
| enable_integrity_monitoring | Enables monitoring and attestation of the boot integrity of the instance. The attestation is performed against the integrity policy baseline. This baseline is initially derived from the implicitly trusted boot image when the instance is created. | true | Optional |
| enable_secure_boot | Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. | false | Optional |
| gpu_driver_version | Mode for how the GPU driver is installed | null | Optional |
| gpu_partition_size | Size of partitions to create on the GPU | null | Optional |
| image_type | The image type to use for this node. Note that changing the image type will delete and recreate all nodes in the node pool | COS_CONTAINERD | Optional |
| initial_node_count | The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. Changing this will force recreation of the resource. Defaults to the value of min_count | " " | Optional |
| insecure_kubelet_readonly_port_enabled | (boolean) Whether or not to enable the insecure Kubelet readonly port. | null | Optional |
| single_process_oom_kill | (boolean) On cgroupv2 nodes, defines whether processes in the container are OOM killed individually (true) or as a group (false, the kubelet default). Leave null to keep the kubelet default. | null | Optional |
| key | The key required for the taint | Required | |
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a hostpath volume or a local PersistentVolume. |
0 | Optional |
| local_ssd_ephemeral_storage_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| ephemeral_storage_local_ssd_data_cache_count | Number of raw-block local NVMe SSD disks to be attached to the node utilized for GKE Data Cache. | 0 | Optional |
| {% if beta_cluster %} | |||
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| {% endif %} | |||
| local_nvme_ssd_count | Number of raw-block local NVMe SSD disks to be attached to the node.Each local SSD is 375 GB in size. If zero, it means no raw-block local NVMe SSD disks to be attached to the node. | 0 | Optional |
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
| enable_confidential_storage | Enabling Confidential Storage will create boot disk with confidential mode. | false | Optional |
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
| strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: SURGE, BLUE_GREEN, or for flex-start and queued provisioning SHORT_LIVED |
"SURGE" | Optional |
| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional |
| enable_nested_virtualization | Whether the node should have nested virtualization | null | Optional |
| performance_monitoring_unit | Level of Performance Monitoring Unit (PMU) requested. If unset, no access to the PMU is assumed. Values values are: ARCHITECTURAL, STANDARD, and ENHANCED |
null | Optional |
| max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with SURGE strategy. |
1 | Optional |
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with SURGE strategy. |
0 | Optional |
| node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with BLUE_GREEN strategy. |
"3600s" | Optional |
| batch_soak_duration | Soak time after each batch gets drained, with the default being zero seconds. Only works with BLUE_GREEN strategy. |
"0s" | Optional |
| batch_node_count | Absolute number of nodes to drain in a batch. If it is set to zero, this phase will be skipped. Cannot be used together with batch_percentage. Only works with BLUE_GREEN strategy. |
1 | Optional |
| batch_percentage | Percentage of nodes to drain in a batch. Must be in the range of [0.0, 1.0]. If it is set to zero, this phase will be skipped. Cannot be used together with batch_node_count. Only works with BLUE_GREEN strategy. |
null | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
| name | The name of the node pool | Required | |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as COMPACT if desired | Optional | |
| policy_name | If set, refers to the name of a custom resource policy supplied by the user. The resource policy must be in the same project and region as the node pool. | Optional | |
| tpu_topology | TPU placement topology for pod slice node pool. For detail see documentation | Optional | |
| pod_range | The name of the secondary range for pod IPs. | Optional | |
| {% if not private_cluster %} | |||
| enable_private_nodes | Whether nodes have internal IP addresses only. | Optional | |
| {% endif %} | |||
| node_affinity | The node affinty in the format "{\"key\": \"compute.googleapis.com/node-group-name\", \"operator\": \"IN\", \"values\": [\"node-group-name\"]}". |
Optional | |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | Required | |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
| node_metadata | Options to expose the node metadata to the workload running on the node | Optional | |
| preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional |
| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional |
| {% if beta_cluster %} | |||
| sandbox_type | Sandbox to use for pods in the node pool | Required | |
| {% endif %} | |||
| service_account | The service account to be used by the Node VMs | " " | Optional |
| tags | The list of instance tags applied to all nodes | Required | |
| value | The value for the taint | Required | |
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
| location_policy | Location policy specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see documentation. gcfs_config must be enabled=true for this feature to work. |
Optional | |
| secondary_boot_disk_mode | Mode for the secondary boot disk. Defaults to CONTAINER_IMAGE_CACHE (preloads container images, requires gcfs_config enabled). Set to null to omit the field for data preloading (mounts data onto nodes for use via hostPath). |
"CONTAINER_IMAGE_CACHE" |
Optional |
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | Optional | |
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | Optional | |
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | Optional | |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier. Valid values are: "TIER_1" and "TIER_UNSPECIFIED". | Optional | |
| pod_cidr_overprovision_disabled | Disables GKE's default doubling of the per-node pod IP range allocation when set to true. |
Optional | |
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | Optional | |
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | Optional | |
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | Optional | |
| local_ssd_encryption_mode | specifies the method used for encrypting the local SSDs attached to the node. Valid values are: "STANDARD_ENCRYPTION" and "EPHEMERAL_KEY_ENCRYPTION" | Optional | |
| max_run_duration | The runtime of each node in the node pool in seconds, terminated by 's'. Example: "3600s". | null | Optional |
| flex_start | Enables Flex Start provisioning model for the node pool | null | Optional |
| respect_pdb_during_node_pool_deletion | Whether to respect Pod Disruption Budgets during node pool deletion. | null | Optional |
windows_node_pools variable
The windows_node_pools variable takes the same parameters as node_pools but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a specific requirement for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.
| Name | Description | Default | Requirement |
|---|---|---|---|
| windows_node_config_os_version | The Windows OS version to use for the windows node pool. Valid values are OS_VERSION_UNSPECIFIED, OS_VERSION_LTSC2019 and OS_VERSION_LTSC2022. | null | Optional |
{% endif %}
Requirements
Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:
- Terraform and kubectl are installed on the machine where Terraform is executed.
- The Service Account you execute the module with has the right permissions.
- The Compute Engine and Kubernetes Engine APIs are active on the project you will launch the cluster in.
- If you are using a Shared VPC, the APIs must also be activated on the Shared VPC host project and your service account needs the proper permissions there.
The project factory can be used to provision projects with the correct APIs active and the necessary Shared VPC connections.
Software Dependencies
Kubectl
- kubectl 1.9.x
Terraform and Plugins
- Terraform 1.3+
{% if beta_cluster %} - Terraform Provider for GCP Beta v7.39+
{% else %} - Terraform Provider for GCP v7.39+
{% endif %}
gcloud
Some submodules use the terraform-google-gcloud module. By default, this module assumes you already have gcloud installed in your $PATH.
See the module documentation for more information.
Configure a Service Account
In order to execute this module you must have a Service Account with the
following project roles:
- roles/compute.viewer
- roles/compute.securityAdmin (only required if
add_cluster_firewall_rulesis set totrue) - roles/container.clusterAdmin
- roles/container.developer
- roles/iam.serviceAccountAdmin
- roles/iam.serviceAccountUser
- roles/resourcemanager.projectIamAdmin (only required if
service_accountis set tocreate)
Additionally, if service_account is set to create and grant_registry_access is requested, the service account requires the following role on the registry_project_ids projects:
- roles/resourcemanager.projectIamAdmin
Enable APIs
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
- Compute Engine API - compute.googleapis.com
- Kubernetes Engine API - container.googleapis.com
{% if beta_cluster %}
terraform-provider-google-beta: https://github.com/terraform-providers/terraform-provider-google-beta
{% else %}
terraform-provider-google: https://github.com/terraform-providers/terraform-provider-google
{% endif %}
27.0.0: https://registry.terraform.io/modules/terraform-google-modules/kubernetes-engine/google/27.0.0
12.3.0: https://registry.terraform.io/modules/terraform-google-modules/kubernetes-engine/google/12.3.0
terraform-0.13-upgrade: https://www.terraform.io/upgrade-guides/0-13.html
terraform-1.3-upgrade: https://developer.hashicorp.com/terraform/language/v1.3.x/upgrade-guides
Overview (`autogen/safer-cluster/README.md`)
Safer Cluster: How to setup a GKE Kubernetes cluster with reduced exposure
This module defines an opinionated setup of GKE
cluster. We outline project configurations, cluster settings, and basic K8s
objects that permit a safer-than-default configuration.
Module Usage
The module fixes a set of parameters to values suggested in the
GKE hardening guide,
the CIS framework, and other best practices.
The motivation for each setting, and its relation to hardening guides or other recommendations
is outlined in main.tf as comments over individual settings. When security-relevant settings
are available for configuration, recommendations on their settings are documented in the variables.tf file.
Project Setup and Cloud IAM policy for GKE
Applications and Clusters
Different applications that access data with different sensitivity and do
not need to communicate with each other (e.g., dev and prod instances of the
same application) should be placed in different clusters.- This approach will limit the blast radius of errors. A security problem
in dev shouldn't impact production data.
- This approach will limit the blast radius of errors. A security problem
If applications need to communicate (e.g., a frontend system calling
a backend), we suggest placing the two applications in the same cluster, in
different namespaces.- Placing them in the same cluster will provide fast network
communication, and the different namespaces will be configured to
provide some administrative isolation. Cloud Service Mesh can be used to
encrypt and control communication between applications.
- Placing them in the same cluster will provide fast network
We suggest to store user or business data persistently in managed storage
services that are inventoried and controlled by centralized teams.
(e.g., GCP storage services within a GCP organization).- Storing user or business data securely requires satisfying a large set of
requirements, such as data inventory, which might be harder to satisfy at
scale when data is stored opaquely within a cluster. Services like Cloud
Asset Inventory provide centralized teams ability to enumerate data stores.
- Storing user or business data securely requires satisfying a large set of
Project Setup
We suggest a GKE setup composed of multiple projects to separate responsibilities
between cluster operators, which need to administer the cluster; and product
developers, which mostly just want to deploy and debug applications.
Cluster Projects (
project_id): GKE clusters storing sensitive data should have their
own projects, so that they can be administered independently (e.g., dev cluster;
production clusters; staging clusters should go in different projects.)Shared GCR projects (
registry_project_ids): all clusters can share the same
GCR projects.- Easier to share images between environments. The same image could be
progressively rolled-out in dev, staging, and then production. - Easier to manage service account permissions: GCR requires authorizing
service accounts to access certain buckets, which are created only after
images are published. When the only service run by the project is GCR,
we can safely give project-wide read permissions to all buckets.
- Easier to share images between environments. The same image could be
(optional) Data Projects: When the same cluster is shared by different
applications managed by different teams, we suggest separating the data for
each application by placing storage resources for each team in different
projects (e.g., a Spanner instance for application A in one project, GCS
bucket for application B in a different project).- This permits to control administrative access to the data more tightly,
as Cloud IAM policies for accessing the data can be managed by each
application team, rather than the team managing the cluster
infrastructure.
- This permits to control administrative access to the data more tightly,
Exception to such a setup:
- When not using Shared VPCs, resources that require direct network connectivity
(e.g., a Cloud SQL instance), need to be placed in the same VPC (hence, project)
as the clusters from which connections are made.
Google Service Accounts
We use GKE Workload Identity (BETA) to associate a GCP identity to each workload,
and limit the permissions associated with the cluster nodes.
The Safer Cluster setup relies on several service accounts:
- The module generates a service account to run nodes. Such a service account
has only permissions of sending logging data, metrics, and downloading containers
from the given GCR project. The following settings in the module will create
a service account with the above properties:
create_service_account = true
registry_project_ids = [<the project id for your GCR project>]
grant_registry_access = true- A service account for each application running on the cluster (e.g.,
[email protected]). These service
accounts should be associated to the permissions required for running the
application, such as access to databases.
- email: myproduct
displayName: Google Service Account for containers running in the myproduct k8s namespace
policy:
# GKE workload identity authorization. This authorizes the Kubernetes Service Account
# myproduct/default from this project's identity namespace to impersonate the service account.
# https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity
bindings:
- members:
- serviceAccount:product-prod.svc.id.goog[myproduct/default]
role: roles/iam.workloadIdentityUserWe suggest running different applications in different namespaces within the cluster. Each namespace
should be assigned to its own GCP service account to better define the Cloud IAM permissions required
for the application.
If you are using more than 2 projects in your setup, you can consider creating
the service account in a different project to keep application and
infrastructure separate. For example, service accounts could be created in each team's project,
while the cluster runs in a centrally controlled project.
Separating the permissions associated with the infrastructure GKE nodes and the
application provides a simpler way to scale up the cluster: multiple applications
could be run in the same cluster, and each of them can run with tailored permissions
that limit the impact of compromises.
Such a separation of identities is enabled by a GKE feature called Workload
Identity. The feature provides additional advantages such as a better protection
of the node's metadata server against attackers.
Cloud IAM Permissions for the GKE Cluster
We suggest to mainly rely on Kubernetes RBAC to manage access control, and use
Cloud IAM to give users only the ability of configuring kubectl credentials.
Engineers operating applications on the cluster should only be assigned the
Cloud IAM permission roles/container.clusterViewer. This role allows them to
obtain credentials for the cluster, but provides no further access to the
cluster objects. All cluster objects are protected by RBAC configurations,
defined below.
Both Cloud IAM and RBAC can be used to control access to GKE clusters. Those two
systems are combined as a "OR": an action is authorized if the necessary
permissions are provided by either RBAC OR Cloud IAM
However, Cloud IAM permissions are defined for a project: user get assigned the
same permissions over all clusters and all namespaces within each cluster. Such
a setup makes it hard to separate responsibilities between teams in charge of
managing clusters, and teams in charge of products.
By relying on RBAC instead of Cloud IAM, we have a finer-grained control of the
permissions provided to engineers, and permits to restrict permissions to only
certain namespaces.
You can add the following binding to the myproduct-prod project.
- members:
role: roles/container.clusterViewer
- group:<product team group>
- group:<cluster team group>The permissions won't allow engineers to SSH into nodes as part of the regular
development workflow. Such permissions should be granted only to the cluster
team, and used only in case of emergency.
While RBAC permissions should be sufficient for most cases, we also suggest to
create an emergency superuser role that can be used, given a proper
justification, for resolving cases where regular permissions are insufficient.
For simplicity, we suggest using roles/container.admin androles/compute.admin, until more narrow roles can be defined given your usage.
- members:
role: roles/container.admin
- group:<oncall for cluster team>
- members:
role: roles/compute.admin
- group:<oncall for cluster team>To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/acm-terraform-blog-part1/README.md`)
Enable ACM features with Terraform - Part 1
This is Part1 of the tutorial to accompany a short series of blog articles explaining how to enable Anthos Config Management (ACM) with Terraform.
In this tutorial, we'll explain how to use Teraform to create a cluster and manage its config from git via Config Sync.
Next part will build on that to add guard rails for the cluster via Policy Controller. We will focus on enabling an ongoing audit of cluster resources using the Policy Controller's built in Policy Library and a bundle of constraints enforcings CIS Kubernetes Benchmark v.1.5.1.
Subsequent articles will discuss other aspects of ACM to manage your GCP infrastrcuture.
Enable Config Sync on the cluster with Terraform
Clone this repo
Set variables that will be used in multiple commands:
bashFOLDER_ID = [FOLDER] BILLING_ACCOUNT = [BILLING_ACCOUNT] PROJECT_ID = [PROJECT_ID]Create project:
bashgcloud auth login gcloud projects create $PROJECT_ID --name=$PROJECT_ID --folder=$FOLDER_ID gcloud alpha billing projects link $PROJECT_ID --billing-account $BILLING_ACCOUNT gcloud config set project $PROJECT_IDCreate cluster using terraform using defaults other than the project:
bash# obtain user access credentials to use for Terraform commands gcloud auth application-default login # continue in /terraform directory cd terraform export TF_VAR_project=$PROJECT_ID terraform init terraform plan terraform applyNOTE: if you get an error due to default network not being present, run
gcloud compute networks create default --subnet-mode=autoand retry the commands.To verify things have sync'ed, you can use
gcloudto check status:bashgcloud alpha container hub config-management status --project $PROJECT_IDIn the output, notice that the
Statuswill eventually show asSYNCEDand theLast_Synced_Tokenwill match the repo hash.To see wordpress itself, you can use the kubectl proxy to connect to the service:
bash# get values from cluster that was created export CLUSTER_ZONE=$(terraform output -raw cluster_location) export CLUSTER_NAME=$(terraform output -raw cluster_name) # then get creditials for it and proxy to the wordpress service to see it running gcloud container clusters get-credentials $CLUSTER_NAME --zone $CLUSTER_ZONE --project $PROJECT_ID kubectl proxy --port 8888 & # curl or use the browser curl http://127.0.0.1:8888/api/v1/namespaces/wp/services/wordpress/proxy/wp-admin/install.phpFinally, let's clean up. First, don't forget to foreground the proxy again to kill it. Also, apply
terraform destroyto remove the GCP resources that were deployed to the project.bashfg # ctrl-c terraform destroy -var=project=$PROJECT_ID
Overview (`examples/acm-terraform-blog-part2/README.md`)
Enable ACM features with Terraform - Part 2
This is Part2 of the tutorial to accompany a short series of blog articles explaining how to enable Anthos Config Management (ACM) with Terraform.
In the previous article, we'll explain how to use Terraform to create a cluster and manage its config from git via Config Sync.
This article will build on that to add guard rails for the cluster via Policy Controller. We will focus on enabling an ongoing audit of cluster resources using the Policy Controller's built in Policy Library and a bundle of constraints enforcing CIS Kubernetes Benchmark v.1.5.1.
Subsequent articles will discuss other aspects of ACM to manage your GCP infrastructure.
Enforce Cluster Guardrails with ACM Policy Controller
Set a variables for the project from part1. We will re-use that project but create a new cluster since we cleaned up at the end of the first section. If you are working in a different project, enable required GCP APIs, as described in part1/README.md.
bashPROJECT_ID = [PROJECT_ID]As before, cluster using terraform using defaults other than the project. The main difference in the terraform files is that we turn on PolicyController and also install the built-in Policy Library.
bash# obtain user access credentials to use for Terraform commands gcloud auth application-default login # continue in /terraform directory cd terraform export TF_VAR_project=$PROJECT_ID terraform init terraform plan terraform applyNOTE: if you get an error due to default network not being present, run
gcloud compute networks create default --subnet-mode=autoand retry the commands.To verify things have sync'ed and the policy controller is installed, you can again use
gcloudto check status:bashgcloud alpha container hub config-management status --project $PROJECT_IDAs things initialize, you may see a few transient
error: KNV1021: No CustomResourceDefinition is definedmessages. This occurs when constraints from the repo are sync'ed before Policy Controller has had a chance to load the appropriate template from the policy library. It will eventually reconcile.After a short time, in addition to the
Statusshowing asSYNCEDand theLast_Synced_Tokenmatching the repo, there should also be a value ofINSTALLEDforPolicy_Controller.One difference you may notice from part1 is that in the config-root/cis-k8s-1.5.1 directory. This is a bundle of Policy Controller constraints that were pulled into the repo from acm-policy-controller-library repo using
kpt pkg getcommand. Kpt is a helpful kubernetes config tool documented at kpt.dev. We'll use Kpt tool directly in part3 of this tutorial. The goal of this bundle is to audit and enforce CIS Benchmarks for Kubernetes. At the moment, they have been deployed indryrunmode so we can use them to audit the cluster.To see the audit status first we get credentials for
kubectlin the same way we did this in part1:bash# get values from cluster that was created export CLUSTER_ZONE=$(terraform output -raw cluster_location) export CLUSTER_NAME=$(terraform output -raw cluster_name) # then get creditials for it gcloud container clusters get-credentials $CLUSTER_NAME --zone $CLUSTER_ZONE --project $PROJECT_IDNow, let's look at the violations in the status of the constraints we have active. One handy way to do this is to dump the constraints in json so we can filter for violations using
jq.bashkubectl get constraint -o json | jq -C '.items[]| select(.status.violations)| .kind,.status.violations'Seems like there is a LOT to clean up!
Overview (`examples/acm-terraform-blog-part3/README.md`)
Enable ACM features with Terraform - Part 3
This is part three of the tutorial to accompany a short series of blog articles explaining how to enable Anthos Config Management (ACM) with Terraform.
In the first part, we explained how to use Terraform to create a cluster and manage its config from git via Config Sync.
In the second part we added guard rails for the cluster configuration via Policy Controller.
In this article we'll demonstrate how, using Config Connector, you can provision your GCP cloud resources following the same Kubernetes-native model.
Provision GCP resources
Set the variable for the project from part two. We will re-use that project but create a new cluster since we cleaned up at the end of the first section. If you are working in a different project, enable required GCP APIs, as described in part one.
bashPROJECT_ID = [PROJECT_ID]Note that wordpress-bundle.yaml was updated to use GCP MySQL database. Also we added configconnector.yaml to initialize the instance of Config Connector add-on on the cluster.
Use kpt to customize the
config-rootdirectory that will be configured as the source of the objects installed on the cluster.bashkpt fn eval --include-meta-resources --image gcr.io/kpt-fn/set-project-id:v0.1 ./config-root -- "project-id=$PROJECT_ID" kpt fn render ./config-rootSubmit the updated configuration into your branch.
Ensure that
sync_repoandsync_branchvariables are updated in terraform.tfvarsBefore running Terraform, notice the changes in gke.tf:
- We are using the
beta-public-clustermodule config_connectorvariable is set to true- We are using
workload-identitymodule to create a Google Service Account and connect it to a Kubernetes Service Account that is running in Config Connectorcnrm-systemnamespace, allowing Config Connector to create GCP resources.
- We are using the
As in the previous part, create the cluster using Terraform:
bash# obtain user access credentials to use for Terraform commands gcloud auth application-default login # continue in /terraform directory cd terraform export TF_VAR_project=$PROJECT_ID terraform init terraform plan terraform applyNOTE: if you get an error due to the default network not being present, run
gcloud compute networks create default --subnet-mode=autoand retry the commands.To verify things have synced and Policy Controller is installed, you can again use
gcloudto check status:bashgcloud alpha container hub config-management status --project $PROJECT_IDAs things initialize, you may see a few transient
error: KNV1021: No CustomResourceDefinition is definedmessages. This occurs when constraints from the repo are synced before Policy Controller has had a chance to load the appropriate template from the policy library. It will eventually reconcile.After a short time, in addition to the
Statusshowing asSYNCEDand theLast_Synced_Tokenmatching the repo, there should also be a value ofINSTALLEDforPolicy_Controller.Connect your kubectl instance to the newly created cluster:
bash# get values from cluster that was created export CLUSTER_ZONE=$(terraform output -raw cluster_location) export CLUSTER_NAME=$(terraform output -raw cluster_name) # then get credentials for it gcloud container clusters get-credentials $CLUSTER_NAME --zone $CLUSTER_ZONE --project $PROJECT_IDVerify that Config Connector addon is installed and configured:
bashkubectl wait -n cnrm-system --for=condition=Ready pod --allNote: The controller Pod can take several minutes to start. Once Config Connector is installed correctly, the output is similar to the following:
bashpod/cnrm-controller-manager-0 condition metIt will take a while for the SQL database to be created. You can check on the status:
bashkubectl describe sqlinstance -n wpFinally, validate that Wordpress powered Cloud SQL database was created:
bashcurl -L $( kubectl get service wordpress-external -n wp -o=json | \ jq -r '.status["loadBalancer"]["ingress"][0]["ip"]')
Overview (`examples/autopilot_private_firewalls/README.md`)
Private Regional Autopilot Cluster With Firewall Rules
This example creates a regional autopilot cluster with beta features
It will:
- Create a private autopilot cluster
- Variables
add_cluster_firewall_rules,add_master_webhook_firewall_rulesandadd_shadow_firewal_rulesare toggled on. In a environment with stringent firewall rules, these cluster firewall rules may be required to allow intra cluster communication - Adds an example network tag. This example network tag aligns with a firewall rule target tag from the terraform-example-foundation configuration to allow google api access
note: this example does not create a network with stringent firewall rules. This example shows what cluster configuration may be required for a networking configuration comparable to the terraform-example-foundation's base shared VPCs, or any VPC with firewall rules to deny 0.0.0.0/0 egress and an allow rule for private google api egress access which targets tags "allow-google-apis". By toggling on the firewall rules variables and adding network_tags to allow private google api access, a private cluster can come up healthy with no internet egress. This configuration shows how to ensure those firewalls that explicitly allow intra cluster ingress and egress are created and appropriate network tags are attached to the cluster.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region the cluster in | string |
"us-central1" |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | The cluster ca certificate (base64 encoded) |
| cluster_name | Cluster name |
| kubernetes_endpoint | The cluster endpoint |
| location | n/a |
| master_kubernetes_version | Kubernetes version of the master |
| network_name | The name of the VPC being created |
| project_id | The project ID the cluster is in |
| region | The region in which the cluster resides |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnet_names | The names of the subnet being created |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/confidential_autopilot_private/README.md`)
Confidential Autopilot Private Cluster
This example illustrates how to create an Autopilot cluster with beta features,
using Confidential GKE nodes and a Customer Managed Encryption Keys (CMEK).
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | string |
n/a | yes |
| region | The region to host the cluster in | string |
"us-central1" |
no |
Outputs
| Name | Description |
|---|---|
| cluster_name | Cluster name |
| kms_key | CMEK used for disk and database encryption |
| kubernetes_endpoint | The cluster endpoint |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| master_kubernetes_version | Kubernetes version of the master |
| network_name | The name of the VPC being created |
| region | The region in which the cluster resides |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnet_names | The names of the subnet being created |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/confidential_safer_cluster/README.md`)
Confidential Safer GKE Cluster
This example illustrates how to instantiate the Safer Cluster module
with confidential nodes enabled and database encrypted with KMS key.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in. | string |
n/a | yes |
| region | The region to host the cluster in. | string |
"us-central1" |
no |
| zones | The zones to host the cluster in. | list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | The cluster ca certificate (base64 encoded). |
| client_token | The bearer token for auth. |
| cluster_name | Cluster name. |
| keyring | The name of the keyring. |
| kms_key_name | KMS Key Name. |
| kubernetes_endpoint | The cluster endpoint. |
| location | n/a |
| master_kubernetes_version | Kubernetes version of the master. |
| network_name | The name of the VPC being created. |
| project_id | The project ID the cluster is in. |
| region | The region in which the cluster resides. |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnet_names | The names of the subnet being created. |
| zones | List of zones in which the cluster resides. |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/deploy_service/README.md`)
Deploy Service Cluster
This example illustrates how to deploy a service to the created cluster using the kubernetes provider.
It will:
- Create a cluster
- Configure authentication for the Kubernetes provider
- Create an Nginx Pod
- Create an Nginx Service
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/disable_client_cert/README.md`)
Disable Client Certificate
This example illustrates how to create a simple cluster and disable deprecated security features:
- basic auth
- client certificate
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| network_project_id | The GCP project housing the VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/gke_autopilot_cluster/README.md`)
GKE Autopilot Cluster
This example creates a GKE private Autopilot clusterwith beta features.
For a full example see simple_autopilot_private example.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| addons_config | The configuration for addons supported by GKE Autopilot. |
| ca_certificate | The cluster ca certificate (base64 encoded) |
| cluster_name | Cluster name |
| endpoint | The cluster endpoint |
| location | Cluster location |
| master_version | The master Kubernetes version |
| network_name | The name of the VPC being created |
| node_locations | Cluster node locations |
| project_id | The project ID the cluster is in |
| subnets_names | The names of the subnet being created |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/gke_standard_cluster/README.md`)
GKE Standard Cluster and Node Pool
This example creates a GKE private cluster and Node Pool with beta features. This example also adds an extra network to the Nodes configuration.
For a full example see simple_regional_private_beta example.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| dns_cache | Boolean to enable / disable NodeLocal DNSCache | bool |
false |
no |
| gce_pd_csi_driver | (Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | bool |
false |
no |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| addons_config | The configuration for addons supported by GKE Autopilot. |
| ca_certificate | The cluster ca certificate (base64 encoded) |
| cluster_name | Cluster name |
| endpoint | The cluster endpoint |
| location | Cluster location |
| master_version | The master Kubernetes version |
| node_locations | Cluster node locations |
| node_pool_name | The name of the node pool |
| project_id | The project ID the cluster is in |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/island_cluster_anywhere_in_gcp_design/README.md`)
GKE island cluster anywhere in GCP design
This example provisions a cluster in an island VPC allowing reuse of the IP address space for multiple clusters across different GCP organizations.
Deploy
- Create NCC hub.
- Update
ncc_hub_project_id,ncc_hub_name,network_nameand gke spokes interraform.tfvars. - Run
terraform apply.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| gke_spokes | n/a | any |
n/a | yes |
| ingress_ip_addrs_subnet_cidr | Subnet to use for reserving internal ip addresses for the ILBs. | string |
n/a | yes |
| master_authorized_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | list(object({ cidr_block = string, display_name = string })) |
n/a | yes |
| ncc_hub_name | n/a | string |
n/a | yes |
| ncc_hub_project_id | n/a | string |
n/a | yes |
| net_attachment_subnet_cidr | Subnet for the router PSC interface network attachment in island network. | string |
n/a | yes |
| node_locations | n/a | list(string) |
n/a | yes |
| primary_net_name | Primary VPC network name. | string |
n/a | yes |
| primary_subnet | Subnet to use in primary network to deploy the router. | string |
n/a | yes |
| proxy_subnet_cidr | CIDR for the regional managed proxy subnet. | string |
n/a | yes |
| region | n/a | string |
n/a | yes |
| router_machine_type | n/a | string |
n/a | yes |
| secondary_ranges | n/a | map(string) |
n/a | yes |
| subnet_cidr | Primary subnet CIDR used by the cluster. | string |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| cluster_ids | n/a |
Overview (`examples/island_cluster_with_vm_router/README.md`)
GKE island cluster using VM as router
This example provisions a cluster in an island VPC allowing reuse of the IP address space for multiple clusters in the same project.
- An appliance(VM as router) with multiple NICs is used to establish connectivity between the island VPC and the existing network.
- Outbound connections will go through the router.
- For inbound connections, use Private Service Connect.
Deploy
- Update
project_id,cluster_nameandprimary_subnetvalues interraform.tfvars, and update other variables as needed. - Run
terraform apply.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name | n/a | string |
n/a | yes |
| master_authorized_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | list(object({ cidr_block = string, display_name = string })) |
n/a | yes |
| node_locations | n/a | list(string) |
n/a | yes |
| primary_net_cidrs | n/a | list(string) |
n/a | yes |
| primary_subnet | n/a | string |
n/a | yes |
| project_id | n/a | string |
n/a | yes |
| proxy_subnet_cidr | n/a | string |
n/a | yes |
| psc_subnet_cidr | n/a | string |
n/a | yes |
| region | n/a | string |
n/a | yes |
| router_machine_type | n/a | string |
n/a | yes |
| secondary_ranges | n/a | map(string) |
n/a | yes |
| subnet_cidr | n/a | string |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| cluster_id | n/a |
Overview (`examples/node_pool/README.md`)
Node Pool Cluster
This example illustrates how to create a cluster with multiple custom node-pool configurations with node labels, taints, and network tags.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_autoscaling | Cluster autoscaling configuration. See more details | object({ enabled = bool autoscaling_profile = string min_cpu_cores = number max_cpu_cores = number 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 }) | { "auto_repair": true, "auto_upgrade": true, "autoscaling_profile": "BALANCED", "enabled": false, "gpu_resources": [], "max_cpu_cores": 0, "max_memory_gb": 0, "min_cpu_cores": 0, "min_memory_gb": 0} | no |
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
| zones | The zone to host the cluster in (required if is a zonal cluster) | list(string) |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/node_pool_update_variant/README.md`)
Node Pool Cluster
This example illustrates how to create a cluster with multiple custom node-pool configurations with node labels, taints, and network tags.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
| zones | The zone to host the cluster in (required if is a zonal cluster) | list(string) |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/node_pool_update_variant_beta/README.md`)
Node Pool Cluster
This example illustrates how to create a cluster with multiple custom node-pool configurations with node labels, taints, and network tags.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| credentials_path | The path to the GCP credentials JSON file | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
| zones | The zone to host the cluster in (required if is a zonal cluster) | list(string) |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/node_pool_update_variant_public_beta/README.md`)
Node Pool Cluster
This example illustrates how to create a cluster with multiple custom node-pool configurations with node labels, taints, and network tags.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| credentials_path | The path to the GCP credentials JSON file | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
| zones | The zone to host the cluster in (required if is a zonal cluster) | list(string) |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/regional_private_node_pool_oauth_scopes/README.md`)
Regional Private Cluster with node pool and oauth scopes
This example illustrates how to create a private cluster with node pool specifications, oauth scopes along with required network and subnet creation.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cluster_name | Cluster name |
| endpoint | Cluster endpoint |
| horizontal_pod_autoscaling_enabled | Whether horizontal pod autoscaling enabled |
| http_load_balancing_enabled | Whether http load balancing enabled |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| logging_service | Logging service used |
| master_authorized_networks_config | Networks from which access to master is permitted |
| master_version | Current master kubernetes version |
| min_master_version | Minimum master kubernetes version |
| monitoring_service | Monitoring service used |
| network_module | network module output |
| network_policy_enabled | Whether network policy enabled |
| node_pools_names | List of node pools names |
| node_pools_versions | Node pool versions by node pool name |
| region | Cluster region |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnets_ips | The IP and cidrs of the subnets being created |
| subnets_secondary_ranges | The secondary ranges associated with these subnets |
| type | Cluster type (regional / zonal) |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/safer_cluster/README.md`)
Safer GKE Cluster
This example illustrates how to instantiate the opinionated Safer Cluster module.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | string |
n/a | yes |
| region | The region to host the cluster in | string |
"us-central1" |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | The cluster ca certificate (base64 encoded) |
| client_token | The bearer token for auth |
| cluster_name | Cluster name |
| kubernetes_endpoint | The cluster endpoint |
| location | n/a |
| master_kubernetes_version | Kubernetes version of the master |
| network_name | The name of the VPC being created |
| project_id | The project ID the cluster is in |
| region | The region in which the cluster resides |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnet_names | The names of the subnet being created |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/safer_cluster_iap_bastion/README.md`)
Safer Cluster Access with IAP Bastion Host
This end to end example aims to showcase access patterns to a Safer Cluster, which is a hardened GKE Private Cluster, through a bastion host utilizing Identity Awareness Proxy without an external ip address. Access to this cluster's control plane is restricted to the bastion host's internal IP using authorized networks.
Additionally we deploy a tinyproxy daemon which allows kubectl commands to be piped through the bastion host allowing ease of development from a local machine with the security of GKE Private Clusters.
GKE Autopilot clusters are deployed with Application-layer Secrets Encryption that protects your secrets in etcd with a key you manage in Cloud KMS.
Setup
To deploy this example:
Run
terraform init.Create a
terraform.tfvarsto provide values forproject_id,bastion_members. Optionally override any variables if necessary.Run
terraform apply.After apply is complete, generate kubeconfig for the private cluster. The command with the right parameters will displayed as the Terraform output
get_credentials_command.shgcloud container clusters get-credentials --project $PROJECT_ID --zone $ZONE --internal-ip $CLUSTER_NAMESSH to the Bastion Host while port forwarding to the bastion host through an IAP tunnel. The command with the right parameters will displayed by running
terraform output bastion_ssh_command.shgcloud beta compute ssh $BASTION_VM_NAME --tunnel-through-iap --project $PROJECT_ID --zone $ZONE -- -L8888:127.0.0.1:8888You can now run
kubectlcommands though the proxy. An example command will displayed as the Terraform outputbastion_kubectl_command.shHTTPS_PROXY=localhost:8888 kubectl get pods --all-namespaces
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| bastion_members | List of users, groups, SAs who need access to the bastion host | list(string) |
[] |
no |
| cluster_name | The name of the cluster | string |
"safer-cluster-iap-bastion" |
no |
| ip_range_pods_name | The secondary ip range to use for pods | string |
"ip-range-pods" |
no |
| ip_range_services_name | The secondary ip range to use for pods | string |
"ip-range-svc" |
no |
| network_name | The name of the network being created to host the cluster in | string |
"safer-cluster-network" |
no |
| project_id | The project ID to host the cluster in | string |
n/a | yes |
| region | The region to host the cluster in | string |
"us-central1" |
no |
| subnet_ip | The cidr range of the subnet | string |
"10.10.10.0/24" |
no |
| subnet_name | The name of the subnet being created to host the cluster in | string |
"safer-cluster-subnet" |
no |
Outputs
| Name | Description |
|---|---|
| bastion_kubectl_command | kubectl command using the local proxy once the bastion_ssh command is running |
| bastion_name | Name of the bastion host |
| bastion_ssh_command | gcloud command to ssh and port forward to the bastion host command |
| bastion_zone | Location of bastion host |
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cluster_name | Cluster name |
| endpoint | Cluster endpoint |
| endpoint_dns | Cluster endpoint DNS |
| get_credentials_command | gcloud get-credentials command to generate kubeconfig for the private cluster |
| keyring | The name of the keyring. |
| keyring_resource | The location of the keyring. |
| keys | Map of key name => key self link. |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| master_authorized_networks_config | Networks from which access to master is permitted |
| network_name | The name of the VPC being created |
| region | Subnet/Router/Bastion Host region |
| router_name | Name of the router that was created |
| subnet_name | The name of the VPC subnet being created |
Overview (`examples/shared_vpc/README.md`)
Shared VPC Cluster
This example illustrates how to create a simple cluster where the host network is not necessarily in the same project as the cluster.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| network_project_id | The GCP project housing the VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_autopilot_private/README.md`)
Simple Regional Autopilot Cluster
This example illustrates how to create a simple autopilot cluster with beta features.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region the cluster in | string |
"us-central1" |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | The cluster ca certificate (base64 encoded) |
| cluster_name | Cluster name |
| kubernetes_endpoint | The cluster endpoint |
| location | n/a |
| master_kubernetes_version | Kubernetes version of the master |
| network_name | The name of the VPC being created |
| project_id | The project ID the cluster is in |
| region | The region in which the cluster resides |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnet_names | The names of the subnet being created |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_autopilot_private_cmek/README.md`)
Simple Regional Autopilot Cluster
This example illustrates how to create a simple autopilot cluster with beta features and
using a Customer Managed Encryption Keys (CMEK).
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| boot_disk_kms_key | CMEK used for disk encryption |
| cluster_name | Cluster name |
| kubernetes_endpoint | The cluster endpoint |
| location | n/a |
| master_kubernetes_version | Kubernetes version of the master |
| network_name | The name of the VPC being created |
| region | The region in which the cluster resides |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnet_names | The names of the subnet being created |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_autopilot_private_non_default_sa/README.md`)
Simple Regional Autopilot Cluster
This example illustrates how to create a simple autopilot cluster with beta features and
not using the default service account.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| cluster_name | Cluster name |
| kubernetes_endpoint | The cluster endpoint |
| location | n/a |
| master_kubernetes_version | Kubernetes version of the master |
| network_name | The name of the VPC being created |
| region | The region in which the cluster resides |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnet_names | The names of the subnet being created |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_autopilot_public/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple cluster with beta features.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region the cluster in | string |
"us-central1" |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | The cluster ca certificate (base64 encoded) |
| cluster_name | Cluster name |
| kubernetes_endpoint | The cluster endpoint |
| location | n/a |
| master_kubernetes_version | Kubernetes version of the master |
| network_name | The name of the VPC being created |
| project_id | The project ID the cluster is in |
| region | The region in which the cluster resides |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| subnet_names | The names of the subnet being created |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_fleet_app_operator_permissions/README.md`)
Simple App Operator Permissions Setup for a Fleet Scope
This example illustrates how to create a Fleet Scope for a team and set up permissions for an app operator in the team.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| fleet_project_id | The project to which the Fleet belongs. | string |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| fleet_project_id | The project to which the Fleet belongs. |
| wait | An output (Fleet Scope RBAC Role Binding IDs) to use when you want to depend on granting permissions finishing. |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple cluster.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_additional_ip_ranges/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple cluster.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| additional_ip_pod_range | The secondary ip range to use for pods in the additional range | any |
n/a | yes |
| additional_ip_pod_range_subnetwork | The subnetwork to host the additional pod range in | any |
n/a | yes |
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_beta/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple cluster with beta features.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| database_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | list(object({ state = string, key_name = string })) |
[ { "key_name": "", "state": "DECRYPTED" }] | no |
| dns_cache | (Beta) The status of the NodeLocal DNSCache addon. | bool |
false |
no |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| enable_pod_security_policy | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. | bool |
false |
no |
| gce_pd_csi_driver | (Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | bool |
false |
no |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| node_pools | List of maps containing node pools | list(map(string)) |
[ { "name": "default-node-pool" }] | no |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool |
true |
no |
| remove_default_node_pool | Remove default node pool while setting up the cluster | bool |
false |
no |
| sandbox_enabled | (Beta) Enable GKE Sandbox (Do not forget to set image_type = COS_CONTAINERD and node_version = 1.12.7-gke.17 or later to use it). |
bool |
false |
no |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| identity_namespace | n/a |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_cluster_autoscaling/README.md`)
Simple Regional Cluster with Node Autoscaling
This example illustrates how to create a simple private cluster with cluster
level node autoprovisioning.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
Overview (`examples/simple_regional_private/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple private cluster.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| enable_k8s_beta_apis | K8S beta apis to enable within the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_private_beta/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple private cluster with beta features.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| dns_cache | Boolean to enable / disable NodeLocal DNSCache | bool |
false |
no |
| gce_pd_csi_driver | (Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | bool |
false |
no |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_private_no_pool/README.md`)
Simple Regional Private Cluster with No Node Pools
This example illustrates how to create a regional private cluster while skipping the creation of node pools and enabling the default compute class.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| enable_k8s_beta_apis | K8S beta apis to enable within the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_private_with_cluster_version/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple private cluster with beta features.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| kubernetes_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string |
"latest" |
no |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_with_gateway_api/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple cluster.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| gateway_api_channel | The gateway api channel of this cluster. Accepted values are CHANNEL_STANDARD and CHANNEL_DISABLED. |
string |
null |
no |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_with_ipv6/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple cluster.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| stack_type | The stack type | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_with_kubeconfig/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple cluster and output a kubeconfig
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubeconfig_raw | n/a |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_regional_with_networking/README.md`)
Simple Regional Cluster with Networking
This example illustrates how to create a VPC and a simple cluster.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name | The name for the GKE cluster | string |
"gke-on-vpc-cluster" |
no |
| ip_range_pods_name | The secondary ip range to use for pods | string |
"ip-range-pods" |
no |
| ip_range_services_name | The secondary ip range to use for services | string |
"ip-range-svc" |
no |
| network | The VPC network created to host the cluster in | string |
"gke-network" |
no |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | string |
"us-central1" |
no |
| subnetwork | The subnetwork created to host the cluster in | string |
"gke-subnet" |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | The cluster ca certificate (base64 encoded) |
| client_token | The bearer token for auth |
| cluster_name | Cluster name |
| ip_range_pods_name | The secondary IP range used for pods |
| ip_range_services_name | The secondary IP range used for services |
| kubernetes_endpoint | The cluster endpoint |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| network_name | The name of the VPC being created |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnet_name | The name of the subnet being created |
| subnet_secondary_ranges | The secondary ranges associated with the subnet |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_windows_node_pool/README.md`)
Simple Regional Cluster
This example illustrates how to create a simple cluster with a windows node pool.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | string |
"us-central1" |
no |
| zone | The zone to host the cluster in | string |
"us-central1-a" |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| identity_namespace | n/a |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_zonal_private/README.md`)
Simple Zonal Cluster
This example illustrates how to create a simple private cluster in a single zone.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
| zones | The zone to host the cluster in (required if is a zonal cluster) | list(string) |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/simple_zonal_with_hub/README.md`)
Simple Zonal Cluster
This example illustrates how to create a simple cluster and register it with Anthos.
After registering the cluster, it uses that registration to install Config Sync.
It incorporates the standard cluster module, the registration module, and the ACM module.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | string |
"us-central1" |
no |
| zone | The zone to host the cluster in | string |
"us-central1-a" |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| hub_location | The location of the hub membership. |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | Standard test outputs |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Example:
terraform init
terraform apply \
-var project_id=${PROJECT} \
-var region="us-central1" \
-var zones='["us-central1-c"]'Overview (`examples/simple_zonal_with_hub_kubeconfig/README.md`)
Kind Cluster Registered using kubeconfig
This example illustrates how to register a non-GKE Kubernetes Cluster with Anthos a.k.a Attached cluster.
It creates a kind cluster, sets current kubecontext to the cluster and registers the cluster using the Hub registration module.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| project_id | The project ID to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| kubernetes_endpoint | Kube API endpoint for the kind cluster |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Example:
terraform init
terraform apply \
-var project_id=${PROJECT} \Overview (`examples/stub_domains/README.md`)
Stub Domains Cluster
This example illustrates how to create a cluster that adds custom stub domains to kube-dns.
It will:
- Create a cluster
- Remove the default kube-dns configmap
- Add a new kube-dns configmap with custom stub domains
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/stub_domains_private/README.md`)
Stub Domains Private Cluster
This example illustrates how to create a private cluster that adds
custom stub domains to kube-dns.
It will:
- Create a private cluster
- Remove the default kube-dns configmap
- Add a new kube-dns configmap with custom stub domains
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/stub_domains_upstream_nameservers/README.md`)
Stub Domains and Upstream Nameservers Cluster
This example illustrates how to create a cluster that adds custom stub domains and custom upstream nameservers to kube-dns.
It will:
- Create a cluster
- Remove the default kube-dns configmap
- Add a new kube-dns configmap with custom stub domains and upstream nameservers
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/upstream_nameservers/README.md`)
Upstream Nameservers Cluster
This example illustrates how to create a cluster that adds custom upstream nameservers to kube-dns.
It will:
- Create a cluster
- Remove the default kube-dns configmap
- Add a new kube-dns configmap with custom upstream nameservers
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| compute_engine_service_account | Service account to associate to the nodes in the cluster | any |
n/a | yes |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/workload_identity/README.md`)
Simple Zonal Cluster with Workload Identity
This example illustrates how to create a simple cluster, with a GCP service account bound as the identity running workloads on your GKE cluster.
Read more about workload identity in the docs.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for pods | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | string |
"us-central1" |
no |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| default_wi_email | GCP service account. |
| default_wi_ksa_name | K8S SA name |
| existing_gsa_email | GCP service account. |
| existing_gsa_name | K8S SA name |
| existing_ksa_email | GCP service account. |
| existing_ksa_name | K8S SA name |
| kubernetes_endpoint | n/a |
| location | Cluster location (zones) |
| project_id | Project id where GKE cluster is created. |
| region | Cluster region |
| service_account | The default service account used for running nodes. |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`examples/workload_metadata_config/README.md`)
Workload Metadata Config Cluster
This example illustrates how to use a cluster with workload_metadata_config defined.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name_suffix | A suffix to append to the default cluster name | string |
"" |
no |
| ip_range_pods | The secondary ip range to use for pods | any |
n/a | yes |
| ip_range_services | The secondary ip range to use for services | any |
n/a | yes |
| network | The VPC network to host the cluster in | any |
n/a | yes |
| project_id | The project ID to host the cluster in | any |
n/a | yes |
| region | The region to host the cluster in | any |
n/a | yes |
| registry_project_ids | Project names for GCR registries | list(string) |
n/a | yes |
| subnetwork | The subnetwork to host the cluster in | any |
n/a | yes |
| zones | The zone to host the cluster in (required if is a zonal cluster) | list(string) |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| ca_certificate | n/a |
| client_token | n/a |
| cluster_name | Cluster name |
| ip_range_pods | The secondary IP range used for pods |
| ip_range_services | The secondary IP range used for services |
| kubernetes_endpoint | n/a |
| location | n/a |
| master_kubernetes_version | The master Kubernetes version |
| network | n/a |
| project_id | n/a |
| region | n/a |
| service_account | The default service account used for running nodes. |
| subnetwork | n/a |
| zones | List of zones in which the cluster resides |
To provision this example, run the following from within this directory:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Overview (`modules/auth/README.md`)
Terraform Kubernetes Engine Auth Module
This module allows configuring authentication to a GKE cluster
using an OpenID Connect token
retrieved from GCP as a kubeconfig file or as outputs intended for use with
the kubernetes / helm providers.
This module retrieves a token for the account configured with the google
provider as the Terraform runner using the provider's credentials,access_token, or other means of authentication.
If you run a private cluster, you can set the use_private_endpoint property to return the GKE private_endpoint IP address.
Usage
module "gke_auth" {
source = "terraform-google-modules/kubernetes-engine/google//modules/auth"
project_id = "my-project-id"
cluster_name = "my-cluster-name"
location = module.gke.location
use_private_endpoint = true
}`kubeconfig` output
resource "local_file" "kubeconfig" {
content = module.gke_auth.kubeconfig_raw
filename = "${path.module}/kubeconfig"
}`kubernetes`/`helm` provider output
provider "kubernetes" {
cluster_ca_certificate = module.gke_auth.cluster_ca_certificate
host = module.gke_auth.host
token = module.gke_auth.token
}Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name | The name of the GKE cluster. | string |
n/a | yes |
| location | The location (region or zone) of the GKE cluster. | string |
n/a | yes |
| project_id | The GCP project of the GKE cluster. | string |
n/a | yes |
| use_private_endpoint | Connect on the private GKE cluster endpoint | bool |
false |
no |
Outputs
| Name | Description |
|---|---|
| cluster_ca_certificate | The cluster_ca_certificate value for use with the kubernetes provider. |
| host | The host value for use with the kubernetes provider. |
| kubeconfig_raw | A kubeconfig file configured to access the GKE cluster. |
| token | The token value for use with the kubernetes provider. |
Overview (`modules/beta-autopilot-private-cluster/README.md`)
Terraform Kubernetes Engine Module
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, Network Policy, etc. This particular submodule creates a private clusterBeta features are enabled in this submodule.
The resources/services/activations/deletions that this module will create/trigger are:
- Create a GKE cluster with the provided addons
- Create GKE Node Pool(s) with provided configuration and attach to cluster
- Replace the default kube-dns configmap if
stub_domainsare provided - Activate network policy if
network_policyis true
Sub modules are provided for creating private clusters, beta private clusters, and beta public clusters as well. Beta sub modules allow for the use of various GKE beta features. See the modules directory for the various sub modules.
Private Cluster Details
For details on configuring private clusters with this module, check the troubleshooting guide.
Compatibility
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.14+.
If you find incompatibilities using Terraform >=1.3, please open an issue.
If you haven't upgraded to 1.3 and need a Terraform
0.13.x-compatible version of this module, the last released version
intended for Terraform 0.13.x is 27.0.0.
If you haven't upgraded to 0.13 and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is 12.3.0.
Usage
There are multiple examples included in the examples folder but simple usage is as follows:
# google_client_config and kubernetes provider must be explicitly specified like the following.
data "google_client_config" "default" {}
provider "kubernetes" {
host = "https://${module.gke.endpoint}"
token = data.google_client_config.default.access_token
cluster_ca_certificate = base64decode(module.gke.ca_certificate)
}
module "gke" {
source = "terraform-google-modules/kubernetes-engine/google//modules/beta-autopilot-private-cluster"
project_id = "<PROJECT ID>"
name = "gke-test-1"
region = "us-central1"
zones = ["us-central1-a", "us-central1-b", "us-central1-f"]
network = "vpc-01"
subnetwork = "us-central1-01"
ip_range_pods = "us-central1-01-gke-01-pods"
ip_range_services = "us-central1-01-gke-01-services"
horizontal_pod_autoscaling = true
filestore_csi_driver = false
enable_private_endpoint = true
enable_private_nodes = true
dns_cache = false
}Then perform the following commands on the root folder:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| add_cluster_firewall_rules | Create additional firewall rules | bool |
false |
no |
| 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 |
| additional_ip_range_pods | List of names of the additional secondary subnet ip ranges to use for pods | list(string) |
[] |
no |
| additional_ip_ranges_config | the configuration for individual additional subnetworks attached to the cluster | list(object({ subnetwork = string, pod_ipv4_range_names = list(string) })) |
[] |
no |
| agent_sandbox_enabled | The status of the Agent Sandbox addon, which isolates untrusted code execution (requires GKE version 1.35.2-gke.1269000 or later) | bool |
null |
no |
| allow_net_admin | (Optional) Enable NET_ADMIN for the cluster. | bool |
null |
no |
| anonymous_authentication_config_mode | Allows users to restrict or enable anonymous access to the cluster. Valid values are ENABLED and LIMITED. |
string |
null |
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 [email protected] | string |
null |
no |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool, if not overridden in node_pools. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. For more information about protecting resources with Cloud KMS Keys please see: https://cloud.google.com/compute/docs/disks/customer-managed-encryption |
string |
null |
no |
| cluster_ipv4_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string |
null |
no |
| cluster_resource_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) |
{} |
no |
| create_service_account | Defines if service account specified to run nodes should be created. | bool |
true |
no |
| database_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | list(object({ state = string, key_name = string })) |
[ { "key_name": "", "state": "DECRYPTED" }] | no |
| default_compute_class_enabled | Enable default compute class for Node Auto-Provisioning | bool |
null |
no |
| deletion_protection | Whether or not to allow Terraform to destroy the cluster. | bool |
true |
no |
| deploy_using_private_endpoint | A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | bool |
false |
no |
| description | The description of the cluster | string |
"" |
no |
| disable_default_snat | Whether to disable the default SNAT to support the private use of public IP addresses | bool |
false |
no |
| disable_l4_lb_firewall_reconciliation | Disable L4 Load Balancer firewall reconciliation | bool |
null |
no |
| dns_allow_external_traffic | (Optional) Controls whether external traffic is allowed over the dns endpoint. | bool |
null |
no |
| dns_cache | The status of the NodeLocal DNSCache addon. | bool |
true |
no |
| dns_enable_k8s_tokens_via_dns | (Optional) Controls whether Kubernetes ServiceAccount token authentication is allowed via the DNS endpoint. | bool |
null |
no |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| enable_cilium_clusterwide_network_policy | Enable Cilium Cluster Wide Network Policies on the cluster | bool |
false |
no |
| enable_confidential_nodes | An optional flag to enable confidential node config. | bool |
false |
no |
| enable_cost_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | bool |
false |
no |
| enable_fqdn_network_policy | Enable FQDN Network Policies on the cluster | bool |
null |
no |
| enable_k8s_beta_apis | (Optional) - List of Kubernetes Beta APIs to enable in cluster. | list(string) |
[] |
no |
| enable_l4_ilb_subsetting | Enable L4 ILB Subsetting on the cluster | bool |
false |
no |
| enable_legacy_lustre_port | Set it to true for GKE cluster runs a version earlier than 1.33.2-gke.4780000. Allows the Lustre CSI driver to initialize LNet (the virtual network layer for Lustre kernel module) using port 6988. This flag is required to workaround a port conflict with the gke-metadata-server on GKE nodes | bool |
false |
no |
| enable_managed_machine_learning_diagnostics | (beta) Enable Managed Machine Learning Diagnostics on the cluster. | bool |
null |
no |
| enable_multi_networking | Whether multi-networking is enabled for this cluster | bool |
null |
no |
| enable_network_egress_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | bool |
false |
no |
| enable_private_endpoint | Whether the master's internal IP address is used as the cluster endpoint | bool |
false |
no |
| enable_private_nodes | Whether nodes have internal IP addresses only | bool |
true |
no |
| enable_resource_consumption_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | bool |
true |
no |
| enable_secret_manager_addon | Enable the Secret Manager add-on for this cluster | bool |
false |
no |
| enable_secret_sync | Enable the Secret Sync add-on for this cluster. | bool |
false |
no |
| enable_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| enable_vertical_pod_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool |
true |
no |
| enterprise_config | (Optional) Enable or disable GKE enterprise. Valid values are STANDARD and ENTERPRISE. | string |
null |
no |
| filestore_csi_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | bool |
false |
no |
| firewall_inbound_ports | List of TCP ports for admission/webhook controllers. Either flag add_master_webhook_firewall_rules or add_cluster_firewall_rules (also adds egress rules) must be set to true for inbound-ports firewall rules to be applied. |
list(string) |
[ "8443", "9443", "15017"] | no |
| firewall_priority | Priority rule for firewall rules | number |
1000 |
no |
| fleet_project | (Optional) Register the cluster with the fleet in this project. | string |
null |
no |
| fleet_project_grant_service_agent | (Optional) Grant the fleet project service identity the roles/gkehub.serviceAgent and roles/gkehub.crossProjectServiceAgent roles. |
bool |
false |
no |
| gateway_api_channel | The gateway api channel of this cluster. Accepted values are CHANNEL_STANDARD and CHANNEL_DISABLED. |
string |
null |
no |
| gcp_public_cidrs_access_enabled | Allow access through Google Cloud public IP addresses | bool |
null |
no |
| gke_auto_upgrade_config_patch_mode | The selected auto-upgrade patch type. Accepted values are: ACCELERATED: Upgrades to the latest available patch version in a given minor and release channel. |
string |
null |
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 |
| hpa_profile | Enable the Horizontal Pod Autoscaling profile for this cluster. Values are "NONE" and "PERFORMANCE". | string |
"" |
no |
| http_load_balancing | Enable httpload balancer addon | bool |
true |
no |
| identity_namespace | The workload pool to attach all Kubernetes service accounts to. (Default value of enabled automatically sets project-based pool [project_id].svc.id.goog) |
string |
"enabled" |
no |
| in_transit_encryption_config | Defines the config of in-transit encryption. Valid values are IN_TRANSIT_ENCRYPTION_DISABLED and IN_TRANSIT_ENCRYPTION_INTER_NODE_TRANSPARENT. |
string |
null |
no |
| insecure_kubelet_readonly_port_enabled | Whether or not to set insecure_kubelet_readonly_port_enabled for node pool defaults and autopilot clusters. |
bool |
null |
no |
| ip_endpoints_enabled | (Optional) Controls whether to allow direct IP access. Defaults to true. |
bool |
null |
no |
| ip_range_pods | The name of the secondary subnet ip range to use for pods | string |
n/a | yes |
| ip_range_services | The name of the secondary subnet range to use for services. If not provided, the default 34.118.224.0/20 range will be used. |
string |
null |
no |
| issue_client_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| kubernetes_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string |
"latest" |
no |
| logging_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, KCP_CONNECTION, KCP_SSHD, KCP_HPA, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration. | list(string) |
[] |
no |
| lustre_csi_driver | The status of the Lustre CSI driver addon, which allows the usage of a Lustre instances as volumes | bool |
null |
no |
| maintenance_end_time | Time window specified for recurring maintenance operations in RFC3339 format | string |
"" |
no |
| maintenance_exclusions | List of maintenance exclusions. A cluster can have up to three | list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string })) |
[] |
no |
| maintenance_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string |
"" |
no |
| maintenance_start_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string |
"05:00" |
no |
| master_authorized_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | list(object({ cidr_block = string, display_name = string })) |
[] |
no |
| master_global_access_enabled | Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint. | bool |
true |
no |
| master_ipv4_cidr_block | (Optional) The IP range in CIDR notation to use for the hosted master network. | string |
null |
no |
| monitoring_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR, DCGM, and JOBSET. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. JOBSET is only supported in GKE 1.32.1-gke.1357001 and above. Empty list is default GKE configuration. | list(string) |
[] |
no |
| monitoring_metric_writer_role | The monitoring metrics writer role to assign to the GKE node service account | string |
"roles/monitoring.metricWriter" |
no |
| name | The name of the cluster (required) | string |
n/a | yes |
| network | The VPC network to host the cluster in (required) | string |
n/a | yes |
| network_project_id | The project ID of the shared VPC's host (for shared vpc support) | string |
"" |
no |
| network_tags | (Optional) - List of network tags applied to autopilot and auto-provisioned node pools. | list(string) |
[] |
no |
| network_tier_config | Network tier configuration for the cluster | string |
null |
no |
| node_pools_cgroup_mode | Specifies the Linux cgroup mode for autopilot Kubernetes nodes in the cluster. Accepted values are CGROUP_MODE_UNSPECIFIED, CGROUP_MODE_V1, and CGROUP_MODE_V2, which determine the control group hierarchy used for resource management. Note: GKE is removing cgroup v1 support in 1.35. |
string |
null |
no |
| notification_config_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | string |
"" |
no |
| notification_filter_event_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT. | list(string) |
[] |
no |
| private_endpoint_subnetwork | The subnetwork to use for the hosted master network. | string |
null |
no |
| project_id | The project ID to host the cluster in (required) | string |
n/a | yes |
| ray_operator_config | The Ray Operator Addon configuration for this cluster. | object({ enabled = bool logging_enabled = optional(bool, false) monitoring_enabled = optional(bool, false) }) | { "enabled": false, "logging_enabled": false, "monitoring_enabled": false} | no |
| rbac_binding_config | RBACBindingConfig allows user to restrict ClusterRoleBindings an RoleBindings that can be created. | object({ enable_insecure_binding_system_unauthenticated = optional(bool, null) enable_insecure_binding_system_authenticated = optional(bool, null) }) | { "enable_insecure_binding_system_authenticated": null, "enable_insecure_binding_system_unauthenticated": null} | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string |
null |
no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool |
true |
no |
| registry_project_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the grant_registry_access variable is set to true, the storage.objectViewer and artifactregsitry.reader roles are assigned on these projects. |
list(string) |
[] |
no |
| release_channel | The release channel of this cluster. Accepted values are UNSPECIFIED, RAPID, REGULAR and STABLE. Defaults to REGULAR. |
string |
"REGULAR" |
no |
| resource_manager_tags | (Optional) - List of resource manager tags applied to autopilot and auto-provisioned node pools. A maximum of 5 tags can be specified. Tags must be in one of these formats: "tagKeys/{tag_key_id}"="tagValues/{tag_value_id}", "{org_id}/{tag_key_name}"="{tag_value_name}", "{project_id}/{tag_key_name}"="{tag_value_name}". | map(string) |
{} |
no |
| resource_usage_export_dataset_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | string |
"" |
no |
| security_posture_mode | Security posture mode. Accepted values are DISABLED and BASIC. Defaults to DISABLED. |
string |
"DISABLED" |
no |
| security_posture_vulnerability_mode | Security posture vulnerability mode. Accepted values are VULNERABILITY_DISABLED, VULNERABILITY_BASIC, and VULNERABILITY_ENTERPRISE. Defaults to VULNERABILITY_DISABLED. |
string |
"VULNERABILITY_DISABLED" |
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. This service account should already exists and it will be used by the node pools. If you wish to only override the service account name, you can use service_account_name variable. |
string |
"" |
no |
| service_account_name | The name of the service account that will be created if create_service_account is true. If you wish to use an existing service account, use service_account variable. | string |
"" |
no |
| service_external_ips | Whether external ips specified by a service will be allowed in this cluster | bool |
false |
no |
| shadow_firewall_rules_log_config | The log_config for shadow firewall rules. You can set this variable to null to disable logging. |
object({ metadata = string }) | { "metadata": "INCLUDE_ALL_METADATA"} | 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 |
| stack_type | The stack type to use for this cluster. Either IPV4 or IPV4_IPV6. Defaults to IPV4. |
string |
"IPV4" |
no |
| stateful_ha | Whether the Stateful HA Addon is enabled for this cluster. | bool |
false |
no |
| subnetwork | The subnetwork to host the cluster in (required) | string |
n/a | yes |
| timeouts | Timeout for cluster operations. | map(string) |
{} |
no |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier for NodePools in the cluster. Valid values are TIER_UNSPECIFIED and TIER_1. Defaults to TIER_UNSPECIFIED. |
string |
null |
no |
| user_managed_keys_config | The User Managed Keys configuration for the cluster. | object({ aggregation_ca = optional(string) cluster_ca = optional(string) control_plane_disk_encryption_key = optional(string) etcd_api_ca = optional(string) etcd_peer_ca = optional(string) gkeops_etcd_backup_encryption_key = optional(string) service_account_signing_keys = optional(list(string)) service_account_verification_keys = optional(list(string)) }) | null |
no |
| workload_config_audit_mode | (beta) Sets which mode of auditing should be used for the cluster's workloads. Accepted values are DISABLED, BASIC. | string |
"DISABLED" |
no |
| workload_vulnerability_mode | (beta) Sets which mode to use for Protect workload vulnerability scanning feature. Accepted values are DISABLED, BASIC. | string |
"" |
no |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cloudrun_enabled | Whether CloudRun enabled |
| cluster_id | Cluster ID |
| dns_cache_enabled | Whether DNS Cache enabled |
| endpoint | Cluster endpoint |
| endpoint_dns | Cluster endpoint DNS |
| fleet_membership | Fleet membership (if registered) |
| gateway_api_channel | The gateway api channel of this cluster. |
| horizontal_pod_autoscaling_enabled | Whether horizontal pod autoscaling enabled |
| http_load_balancing_enabled | Whether http load balancing enabled |
| identity_namespace | Workload Identity pool |
| identity_service_enabled | Whether Identity Service is enabled |
| intranode_visibility_enabled | Whether intra-node visibility is enabled |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| logging_service | Logging service used |
| master_authorized_networks_config | Networks from which access to master is permitted |
| master_ipv4_cidr_block | The IP range in CIDR notation used for the hosted master network |
| master_version | Current master kubernetes version |
| min_master_version | Minimum master kubernetes version |
| monitoring_service | Monitoring service used |
| name | Cluster name |
| peering_name | The name of the peering between this cluster and the Google owned VPC. |
| pod_security_policy_enabled | Whether pod security policy is enabled |
| region | Cluster region |
| release_channel | The release channel of this cluster |
| secret_manager_addon_enabled | Whether Secret Manager add-on is enabled |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| tpu_ipv4_cidr_block | The IP range in CIDR notation used for the TPUs |
| type | Cluster type (regional / zonal) |
| vertical_pod_autoscaling_enabled | Whether vertical pod autoscaling enabled |
| zones | List of zones in which the cluster resides |
Requirements
Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:
- Terraform and kubectl are installed on the machine where Terraform is executed.
- The Service Account you execute the module with has the right permissions.
- The Compute Engine and Kubernetes Engine APIs are active on the project you will launch the cluster in.
- If you are using a Shared VPC, the APIs must also be activated on the Shared VPC host project and your service account needs the proper permissions there.
The project factory can be used to provision projects with the correct APIs active and the necessary Shared VPC connections.
Software Dependencies
Kubectl
- kubectl 1.9.x
Terraform and Plugins
- Terraform 1.3+
- Terraform Provider for GCP Beta v7.39+
gcloud
Some submodules use the terraform-google-gcloud module. By default, this module assumes you already have gcloud installed in your $PATH.
See the module documentation for more information.
Configure a Service Account
In order to execute this module you must have a Service Account with the
following project roles:
- roles/compute.viewer
- roles/compute.securityAdmin (only required if
add_cluster_firewall_rulesis set totrue) - roles/container.clusterAdmin
- roles/container.developer
- roles/iam.serviceAccountAdmin
- roles/iam.serviceAccountUser
- roles/resourcemanager.projectIamAdmin (only required if
service_accountis set tocreate)
Additionally, if service_account is set to create and grant_registry_access is requested, the service account requires the following role on the registry_project_ids projects:
- roles/resourcemanager.projectIamAdmin
Enable APIs
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
- Compute Engine API - compute.googleapis.com
- Kubernetes Engine API - container.googleapis.com
Overview (`modules/beta-autopilot-public-cluster/README.md`)
Terraform Kubernetes Engine Module
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, Network Policy, etc.Beta features are enabled in this submodule.
The resources/services/activations/deletions that this module will create/trigger are:
- Create a GKE cluster with the provided addons
- Create GKE Node Pool(s) with provided configuration and attach to cluster
- Replace the default kube-dns configmap if
stub_domainsare provided - Activate network policy if
network_policyis true
Sub modules are provided for creating private clusters, beta private clusters, and beta public clusters as well. Beta sub modules allow for the use of various GKE beta features. See the modules directory for the various sub modules.
Compatibility
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.14+.
If you find incompatibilities using Terraform >=1.3, please open an issue.
If you haven't upgraded to 1.3 and need a Terraform
0.13.x-compatible version of this module, the last released version
intended for Terraform 0.13.x is 27.0.0.
If you haven't upgraded to 0.13 and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is 12.3.0.
Usage
There are multiple examples included in the examples folder but simple usage is as follows:
# google_client_config and kubernetes provider must be explicitly specified like the following.
data "google_client_config" "default" {}
provider "kubernetes" {
host = "https://${module.gke.endpoint}"
token = data.google_client_config.default.access_token
cluster_ca_certificate = base64decode(module.gke.ca_certificate)
}
module "gke" {
source = "terraform-google-modules/kubernetes-engine/google//modules/beta-autopilot-public-cluster"
project_id = "<PROJECT ID>"
name = "gke-test-1"
region = "us-central1"
zones = ["us-central1-a", "us-central1-b", "us-central1-f"]
network = "vpc-01"
subnetwork = "us-central1-01"
ip_range_pods = "us-central1-01-gke-01-pods"
ip_range_services = "us-central1-01-gke-01-services"
horizontal_pod_autoscaling = true
filestore_csi_driver = false
dns_cache = false
}Then perform the following commands on the root folder:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| add_cluster_firewall_rules | Create additional firewall rules | bool |
false |
no |
| 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 |
| additional_ip_range_pods | List of names of the additional secondary subnet ip ranges to use for pods | list(string) |
[] |
no |
| additional_ip_ranges_config | the configuration for individual additional subnetworks attached to the cluster | list(object({ subnetwork = string, pod_ipv4_range_names = list(string) })) |
[] |
no |
| agent_sandbox_enabled | The status of the Agent Sandbox addon, which isolates untrusted code execution (requires GKE version 1.35.2-gke.1269000 or later) | bool |
null |
no |
| allow_net_admin | (Optional) Enable NET_ADMIN for the cluster. | bool |
null |
no |
| anonymous_authentication_config_mode | Allows users to restrict or enable anonymous access to the cluster. Valid values are ENABLED and LIMITED. |
string |
null |
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 [email protected] | string |
null |
no |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool, if not overridden in node_pools. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. For more information about protecting resources with Cloud KMS Keys please see: https://cloud.google.com/compute/docs/disks/customer-managed-encryption |
string |
null |
no |
| cluster_ipv4_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string |
null |
no |
| cluster_resource_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) |
{} |
no |
| create_service_account | Defines if service account specified to run nodes should be created. | bool |
true |
no |
| database_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | list(object({ state = string, key_name = string })) |
[ { "key_name": "", "state": "DECRYPTED" }] | no |
| default_compute_class_enabled | Enable default compute class for Node Auto-Provisioning | bool |
null |
no |
| deletion_protection | Whether or not to allow Terraform to destroy the cluster. | bool |
true |
no |
| description | The description of the cluster | string |
"" |
no |
| disable_default_snat | Whether to disable the default SNAT to support the private use of public IP addresses | bool |
false |
no |
| disable_l4_lb_firewall_reconciliation | Disable L4 Load Balancer firewall reconciliation | bool |
null |
no |
| dns_allow_external_traffic | (Optional) Controls whether external traffic is allowed over the dns endpoint. | bool |
null |
no |
| dns_cache | The status of the NodeLocal DNSCache addon. | bool |
true |
no |
| dns_enable_k8s_tokens_via_dns | (Optional) Controls whether Kubernetes ServiceAccount token authentication is allowed via the DNS endpoint. | bool |
null |
no |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| enable_cilium_clusterwide_network_policy | Enable Cilium Cluster Wide Network Policies on the cluster | bool |
false |
no |
| enable_confidential_nodes | An optional flag to enable confidential node config. | bool |
false |
no |
| enable_cost_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | bool |
false |
no |
| enable_fqdn_network_policy | Enable FQDN Network Policies on the cluster | bool |
null |
no |
| enable_k8s_beta_apis | (Optional) - List of Kubernetes Beta APIs to enable in cluster. | list(string) |
[] |
no |
| enable_l4_ilb_subsetting | Enable L4 ILB Subsetting on the cluster | bool |
false |
no |
| enable_legacy_lustre_port | Set it to true for GKE cluster runs a version earlier than 1.33.2-gke.4780000. Allows the Lustre CSI driver to initialize LNet (the virtual network layer for Lustre kernel module) using port 6988. This flag is required to workaround a port conflict with the gke-metadata-server on GKE nodes | bool |
false |
no |
| enable_managed_machine_learning_diagnostics | (beta) Enable Managed Machine Learning Diagnostics on the cluster. | bool |
null |
no |
| enable_multi_networking | Whether multi-networking is enabled for this cluster | bool |
null |
no |
| enable_network_egress_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | bool |
false |
no |
| enable_resource_consumption_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | bool |
true |
no |
| enable_secret_manager_addon | Enable the Secret Manager add-on for this cluster | bool |
false |
no |
| enable_secret_sync | Enable the Secret Sync add-on for this cluster. | bool |
false |
no |
| enable_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| enable_vertical_pod_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool |
true |
no |
| enterprise_config | (Optional) Enable or disable GKE enterprise. Valid values are STANDARD and ENTERPRISE. | string |
null |
no |
| filestore_csi_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | bool |
false |
no |
| firewall_inbound_ports | List of TCP ports for admission/webhook controllers. Either flag add_master_webhook_firewall_rules or add_cluster_firewall_rules (also adds egress rules) must be set to true for inbound-ports firewall rules to be applied. |
list(string) |
[ "8443", "9443", "15017"] | no |
| firewall_priority | Priority rule for firewall rules | number |
1000 |
no |
| fleet_project | (Optional) Register the cluster with the fleet in this project. | string |
null |
no |
| fleet_project_grant_service_agent | (Optional) Grant the fleet project service identity the roles/gkehub.serviceAgent and roles/gkehub.crossProjectServiceAgent roles. |
bool |
false |
no |
| gateway_api_channel | The gateway api channel of this cluster. Accepted values are CHANNEL_STANDARD and CHANNEL_DISABLED. |
string |
null |
no |
| gcp_public_cidrs_access_enabled | Allow access through Google Cloud public IP addresses | bool |
null |
no |
| gke_auto_upgrade_config_patch_mode | The selected auto-upgrade patch type. Accepted values are: ACCELERATED: Upgrades to the latest available patch version in a given minor and release channel. |
string |
null |
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 |
| hpa_profile | Enable the Horizontal Pod Autoscaling profile for this cluster. Values are "NONE" and "PERFORMANCE". | string |
"" |
no |
| http_load_balancing | Enable httpload balancer addon | bool |
true |
no |
| identity_namespace | The workload pool to attach all Kubernetes service accounts to. (Default value of enabled automatically sets project-based pool [project_id].svc.id.goog) |
string |
"enabled" |
no |
| in_transit_encryption_config | Defines the config of in-transit encryption. Valid values are IN_TRANSIT_ENCRYPTION_DISABLED and IN_TRANSIT_ENCRYPTION_INTER_NODE_TRANSPARENT. |
string |
null |
no |
| insecure_kubelet_readonly_port_enabled | Whether or not to set insecure_kubelet_readonly_port_enabled for node pool defaults and autopilot clusters. |
bool |
null |
no |
| ip_endpoints_enabled | (Optional) Controls whether to allow direct IP access. Defaults to true. |
bool |
null |
no |
| ip_range_pods | The name of the secondary subnet ip range to use for pods | string |
n/a | yes |
| ip_range_services | The name of the secondary subnet range to use for services. If not provided, the default 34.118.224.0/20 range will be used. |
string |
null |
no |
| issue_client_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| kubernetes_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string |
"latest" |
no |
| logging_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, KCP_CONNECTION, KCP_SSHD, KCP_HPA, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration. | list(string) |
[] |
no |
| lustre_csi_driver | The status of the Lustre CSI driver addon, which allows the usage of a Lustre instances as volumes | bool |
null |
no |
| maintenance_end_time | Time window specified for recurring maintenance operations in RFC3339 format | string |
"" |
no |
| maintenance_exclusions | List of maintenance exclusions. A cluster can have up to three | list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string })) |
[] |
no |
| maintenance_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string |
"" |
no |
| maintenance_start_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string |
"05:00" |
no |
| master_authorized_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | list(object({ cidr_block = string, display_name = string })) |
[] |
no |
| monitoring_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR, DCGM, and JOBSET. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. JOBSET is only supported in GKE 1.32.1-gke.1357001 and above. Empty list is default GKE configuration. | list(string) |
[] |
no |
| monitoring_metric_writer_role | The monitoring metrics writer role to assign to the GKE node service account | string |
"roles/monitoring.metricWriter" |
no |
| name | The name of the cluster (required) | string |
n/a | yes |
| network | The VPC network to host the cluster in (required) | string |
n/a | yes |
| network_project_id | The project ID of the shared VPC's host (for shared vpc support) | string |
"" |
no |
| network_tags | (Optional) - List of network tags applied to autopilot and auto-provisioned node pools. | list(string) |
[] |
no |
| network_tier_config | Network tier configuration for the cluster | string |
null |
no |
| node_pools_cgroup_mode | Specifies the Linux cgroup mode for autopilot Kubernetes nodes in the cluster. Accepted values are CGROUP_MODE_UNSPECIFIED, CGROUP_MODE_V1, and CGROUP_MODE_V2, which determine the control group hierarchy used for resource management. Note: GKE is removing cgroup v1 support in 1.35. |
string |
null |
no |
| notification_config_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | string |
"" |
no |
| notification_filter_event_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT. | list(string) |
[] |
no |
| project_id | The project ID to host the cluster in (required) | string |
n/a | yes |
| ray_operator_config | The Ray Operator Addon configuration for this cluster. | object({ enabled = bool logging_enabled = optional(bool, false) monitoring_enabled = optional(bool, false) }) | { "enabled": false, "logging_enabled": false, "monitoring_enabled": false} | no |
| rbac_binding_config | RBACBindingConfig allows user to restrict ClusterRoleBindings an RoleBindings that can be created. | object({ enable_insecure_binding_system_unauthenticated = optional(bool, null) enable_insecure_binding_system_authenticated = optional(bool, null) }) | { "enable_insecure_binding_system_authenticated": null, "enable_insecure_binding_system_unauthenticated": null} | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string |
null |
no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool |
true |
no |
| registry_project_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the grant_registry_access variable is set to true, the storage.objectViewer and artifactregsitry.reader roles are assigned on these projects. |
list(string) |
[] |
no |
| release_channel | The release channel of this cluster. Accepted values are UNSPECIFIED, RAPID, REGULAR and STABLE. Defaults to REGULAR. |
string |
"REGULAR" |
no |
| resource_manager_tags | (Optional) - List of resource manager tags applied to autopilot and auto-provisioned node pools. A maximum of 5 tags can be specified. Tags must be in one of these formats: "tagKeys/{tag_key_id}"="tagValues/{tag_value_id}", "{org_id}/{tag_key_name}"="{tag_value_name}", "{project_id}/{tag_key_name}"="{tag_value_name}". | map(string) |
{} |
no |
| resource_usage_export_dataset_id | The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export. | string |
"" |
no |
| security_posture_mode | Security posture mode. Accepted values are DISABLED and BASIC. Defaults to DISABLED. |
string |
"DISABLED" |
no |
| security_posture_vulnerability_mode | Security posture vulnerability mode. Accepted values are VULNERABILITY_DISABLED, VULNERABILITY_BASIC, and VULNERABILITY_ENTERPRISE. Defaults to VULNERABILITY_DISABLED. |
string |
"VULNERABILITY_DISABLED" |
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. This service account should already exists and it will be used by the node pools. If you wish to only override the service account name, you can use service_account_name variable. |
string |
"" |
no |
| service_account_name | The name of the service account that will be created if create_service_account is true. If you wish to use an existing service account, use service_account variable. | string |
"" |
no |
| service_external_ips | Whether external ips specified by a service will be allowed in this cluster | bool |
false |
no |
| shadow_firewall_rules_log_config | The log_config for shadow firewall rules. You can set this variable to null to disable logging. |
object({ metadata = string }) | { "metadata": "INCLUDE_ALL_METADATA"} | 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 |
| stack_type | The stack type to use for this cluster. Either IPV4 or IPV4_IPV6. Defaults to IPV4. |
string |
"IPV4" |
no |
| stateful_ha | Whether the Stateful HA Addon is enabled for this cluster. | bool |
false |
no |
| subnetwork | The subnetwork to host the cluster in (required) | string |
n/a | yes |
| timeouts | Timeout for cluster operations. | map(string) |
{} |
no |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier for NodePools in the cluster. Valid values are TIER_UNSPECIFIED and TIER_1. Defaults to TIER_UNSPECIFIED. |
string |
null |
no |
| user_managed_keys_config | The User Managed Keys configuration for the cluster. | object({ aggregation_ca = optional(string) cluster_ca = optional(string) control_plane_disk_encryption_key = optional(string) etcd_api_ca = optional(string) etcd_peer_ca = optional(string) gkeops_etcd_backup_encryption_key = optional(string) service_account_signing_keys = optional(list(string)) service_account_verification_keys = optional(list(string)) }) | null |
no |
| workload_config_audit_mode | (beta) Sets which mode of auditing should be used for the cluster's workloads. Accepted values are DISABLED, BASIC. | string |
"DISABLED" |
no |
| workload_vulnerability_mode | (beta) Sets which mode to use for Protect workload vulnerability scanning feature. Accepted values are DISABLED, BASIC. | string |
"" |
no |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cloudrun_enabled | Whether CloudRun enabled |
| cluster_id | Cluster ID |
| dns_cache_enabled | Whether DNS Cache enabled |
| endpoint | Cluster endpoint |
| endpoint_dns | Cluster endpoint DNS |
| fleet_membership | Fleet membership (if registered) |
| gateway_api_channel | The gateway api channel of this cluster. |
| horizontal_pod_autoscaling_enabled | Whether horizontal pod autoscaling enabled |
| http_load_balancing_enabled | Whether http load balancing enabled |
| identity_namespace | Workload Identity pool |
| identity_service_enabled | Whether Identity Service is enabled |
| intranode_visibility_enabled | Whether intra-node visibility is enabled |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| logging_service | Logging service used |
| master_authorized_networks_config | Networks from which access to master is permitted |
| master_version | Current master kubernetes version |
| min_master_version | Minimum master kubernetes version |
| monitoring_service | Monitoring service used |
| name | Cluster name |
| pod_security_policy_enabled | Whether pod security policy is enabled |
| region | Cluster region |
| release_channel | The release channel of this cluster |
| secret_manager_addon_enabled | Whether Secret Manager add-on is enabled |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| tpu_ipv4_cidr_block | The IP range in CIDR notation used for the TPUs |
| type | Cluster type (regional / zonal) |
| vertical_pod_autoscaling_enabled | Whether vertical pod autoscaling enabled |
| zones | List of zones in which the cluster resides |
Requirements
Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:
- Terraform and kubectl are installed on the machine where Terraform is executed.
- The Service Account you execute the module with has the right permissions.
- The Compute Engine and Kubernetes Engine APIs are active on the project you will launch the cluster in.
- If you are using a Shared VPC, the APIs must also be activated on the Shared VPC host project and your service account needs the proper permissions there.
The project factory can be used to provision projects with the correct APIs active and the necessary Shared VPC connections.
Software Dependencies
Kubectl
- kubectl 1.9.x
Terraform and Plugins
- Terraform 1.3+
- Terraform Provider for GCP Beta v7.39+
gcloud
Some submodules use the terraform-google-gcloud module. By default, this module assumes you already have gcloud installed in your $PATH.
See the module documentation for more information.
Configure a Service Account
In order to execute this module you must have a Service Account with the
following project roles:
- roles/compute.viewer
- roles/compute.securityAdmin (only required if
add_cluster_firewall_rulesis set totrue) - roles/container.clusterAdmin
- roles/container.developer
- roles/iam.serviceAccountAdmin
- roles/iam.serviceAccountUser
- roles/resourcemanager.projectIamAdmin (only required if
service_accountis set tocreate)
Additionally, if service_account is set to create and grant_registry_access is requested, the service account requires the following role on the registry_project_ids projects:
- roles/resourcemanager.projectIamAdmin
Enable APIs
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
- Compute Engine API - compute.googleapis.com
- Kubernetes Engine API - container.googleapis.com
Overview (`modules/beta-private-cluster-update-variant/README.md`)
Terraform Kubernetes Engine Module
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, IP MASQ, Network Policy, etc. This particular submodule creates a private clusterBeta features are enabled in this submodule.
The resources/services/activations/deletions that this module will create/trigger are:
- Create a GKE cluster with the provided addons
- Create GKE Node Pool(s) with provided configuration and attach to cluster
- Replace the default kube-dns configmap if
stub_domainsare provided - Activate network policy if
network_policyis true - Add
ip-masq-agentconfigmap with providednon_masquerade_cidrsifconfigure_ip_masqis true
Sub modules are provided for creating private clusters, beta private clusters, and beta public clusters as well. Beta sub modules allow for the use of various GKE beta features. See the modules directory for the various sub modules.
Private Cluster Details
For details on configuring private clusters with this module, check the troubleshooting guide.
Node Pool Update Variant
In [#256] update variants added support for node pools to be created before being destroyed.
Before, if a node pool has to be recreated for any number of reasons,
the node pool is deleted then, created. This can be a problem if it is the only node pool in the GKE
cluster and the new node pool cannot be provisioned. In this scenario, pods could not be scheduled.
[#256] allows a node pool to be created before it is deleted so that any issues with node pool creation
and/or provisioning are discovered before the node pool is removed. This feature is controlled by the
variable node_pools_create_before_destroy. In order to avoid node pool name collisions,
a 4 character alphanumeric is added as a suffix to the name.
The benefit is that you always have some node pools active.
We don't actually cordon/drain the traffic beyond what the GKE API itself will do,
but we do make sure the new node pool is created before the old one is destroyed.
The implications of this are that:
- We append a random ID on the node pool names (since you can't have two simultaneously active node pools)
- For a brief period, you'll have 2x as many resources/node pools
- You will indeed need sufficient IP space (and compute capacity) to create both node pools
Compatibility
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.14+.
If you find incompatibilities using Terraform >=1.3, please open an issue.
If you haven't upgraded to 1.3 and need a Terraform
0.13.x-compatible version of this module, the last released version
intended for Terraform 0.13.x is 27.0.0.
If you haven't upgraded to 0.13 and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is 12.3.0.
Usage
There are multiple examples included in the examples folder but simple usage is as follows:
/* Detailed source-code truncated for AI context efficiency. */Then perform the following commands on the root folder:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| add_cluster_firewall_rules | Create additional firewall rules | bool |
false |
no |
| 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 |
| additional_ip_range_pods | List of names of the additional secondary subnet ip ranges to use for pods | list(string) |
[] |
no |
| additional_ip_ranges_config | the configuration for individual additional subnetworks attached to the cluster | list(object({ subnetwork = string, pod_ipv4_range_names = list(string) })) |
[] |
no |
| additive_vpc_scope_dns_domain | This will enable Cloud DNS additive VPC scope. Must provide a domain name that is unique within the VPC. For this to work cluster_dns = CLOUD_DNS and cluster_dns_scope = CLUSTER_SCOPE must both be set as well. |
string |
"" |
no |
| agent_sandbox_enabled | The status of the Agent Sandbox addon, which isolates untrusted code execution (requires GKE version 1.35.2-gke.1269000 or later and a gVisor-enabled node pool) | bool |
null |
no |
| anonymous_authentication_config_mode | Allows users to restrict or enable anonymous access to the cluster. Valid values are ENABLED and LIMITED. |
string |
null |
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 [email protected] | string |
null |
no |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool, if not overridden in node_pools. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. For more information about protecting resources with Cloud KMS Keys please see: https://cloud.google.com/compute/docs/disks/customer-managed-encryption |
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 | object({ enabled = bool autoscaling_profile = string min_cpu_cores = optional(number) max_cpu_cores = optional(number) min_memory_gb = optional(number) max_memory_gb = optional(number) gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number })) auto_repair = bool auto_upgrade = bool disk_size = optional(number) disk_type = optional(string) image_type = optional(string) strategy = optional(string) max_surge = optional(number) max_unavailable = optional(number) node_pool_soak_duration = optional(string) batch_soak_duration = optional(string) batch_percentage = optional(number) batch_node_count = optional(number) enable_secure_boot = optional(bool, false) enable_integrity_monitoring = optional(bool, true) enable_default_compute_class = optional(bool, false) }) | { "auto_repair": true, "auto_upgrade": true, "autoscaling_profile": "BALANCED", "disk_size": 100, "disk_type": "pd-standard", "enable_default_compute_class": false, "enable_integrity_monitoring": true, "enable_secure_boot": false, "enabled": false, "gpu_resources": [], "image_type": "COS_CONTAINERD", "max_cpu_cores": 0, "max_memory_gb": 0, "min_cpu_cores": 0, "min_memory_gb": 0} | 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 |
| cluster_ipv4_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string |
null |
no |
| cluster_resource_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) |
{} |
no |
| cluster_telemetry_type | Available options include ENABLED, DISABLED, and SYSTEM_ONLY | string |
null |
no |
| config_connector | Whether ConfigConnector is enabled for this cluster. | bool |
false |
no |
| configure_ip_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | bool |
false |
no |
| create_service_account | Defines if service account specified to run nodes should be created. | bool |
true |
no |
| database_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | list(object({ state = string, key_name = string })) |
[ { "key_name": "", "state": "DECRYPTED" }] | no |
| datapath_provider | 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. |
string |
"DATAPATH_PROVIDER_UNSPECIFIED" |
no |
| default_max_pods_per_node | The maximum number of pods to schedule per node | number |
110 |
no |
| deletion_protection | Whether or not to allow Terraform to destroy the cluster. | bool |
true |
no |
| deploy_using_private_endpoint | A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | bool |
false |
no |
| description | The description of the cluster | string |
"" |
no |
| disable_default_snat | Whether to disable the default SNAT to support the private use of public IP addresses | bool |
false |
no |
| disable_l4_lb_firewall_reconciliation | Disable L4 Load Balancer firewall reconciliation | bool |
null |
no |
| disable_legacy_metadata_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | bool |
true |
no |
| dns_allow_external_traffic | (Optional) Controls whether external traffic is allowed over the dns endpoint. | bool |
null |
no |
| dns_cache | The status of the NodeLocal DNSCache addon. | bool |
false |
no |
| dns_enable_k8s_tokens_via_dns | (Optional) Controls whether Kubernetes ServiceAccount token authentication is allowed via the DNS endpoint. | bool |
null |
no |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| enable_cilium_clusterwide_network_policy | Enable Cilium Cluster Wide Network Policies on the cluster | bool |
false |
no |
| enable_confidential_nodes | An optional flag to enable confidential node config. | bool |
false |
no |
| enable_cost_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | bool |
false |
no |
| enable_default_node_pools_metadata | Whether to enable the default node pools metadata key-value pairs such as cluster_name and node_pool |
bool |
true |
no |
| enable_fqdn_network_policy | Enable FQDN Network Policies on the cluster | bool |
null |
no |
| enable_gcfs | Enable image streaming on cluster level. | bool |
false |
no |
| enable_identity_service | (Optional) Enable the Identity Service component, which allows customers to use external identity providers with the K8S API. NOTE: Starting on July 1, 2025, new Google Cloud organizations that you create won't support Identity Service for GKE. | bool |
false |
no |
| enable_intranode_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | bool |
false |
no |
| enable_k8s_beta_apis | (Optional) - List of Kubernetes Beta APIs to enable in cluster. | list(string) |
[] |
no |
| enable_kubernetes_alpha | Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days. | bool |
false |
no |
| enable_l4_ilb_subsetting | Enable L4 ILB Subsetting on the cluster | bool |
false |
no |
| enable_legacy_lustre_port | Set it to true for GKE cluster runs a version earlier than 1.33.2-gke.4780000. Allows the Lustre CSI driver to initialize LNet (the virtual network layer for Lustre kernel module) using port 6988. This flag is required to workaround a port conflict with the gke-metadata-server on GKE nodes | bool |
false |
no |
| enable_managed_machine_learning_diagnostics | (beta) Enable Managed Machine Learning Diagnostics on the cluster. | bool |
null |
no |
| enable_mesh_certificates | Controls the issuance of workload mTLS certificates. When enabled the GKE Workload Identity Certificates controller and node agent will be deployed in the cluster. Requires Workload Identity. | bool |
false |
no |
| enable_multi_networking | Whether multi-networking is enabled for this cluster | bool |
null |
no |
| enable_network_egress_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | bool |
false |
no |
| enable_pod_security_policy | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. Pod Security Policy was removed from GKE clusters with version >= 1.25.0. | bool |
false |
no |
| enable_private_endpoint | Whether the master's internal IP address is used as the cluster endpoint | bool |
false |
no |
| enable_private_nodes | Whether nodes have internal IP addresses only | bool |
true |
no |
| enable_resource_consumption_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | bool |
true |
no |
| enable_secret_manager_addon | Enable the Secret Manager add-on for this cluster | bool |
false |
no |
| enable_secret_sync | Enable the Secret Sync add-on for this cluster. | bool |
false |
no |
| enable_shielded_nodes | Enable Shielded Nodes features on all nodes in this cluster | bool |
true |
no |
| enable_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| enable_vertical_pod_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool |
false |
no |
| enterprise_config | (Optional) Enable or disable GKE enterprise. Valid values are STANDARD and ENTERPRISE. | string |
null |
no |
| filestore_csi_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | bool |
false |
no |
| firewall_inbound_ports | List of TCP ports for admission/webhook controllers. Either flag add_master_webhook_firewall_rules or add_cluster_firewall_rules (also adds egress rules) must be set to true for inbound-ports firewall rules to be applied. |
list(string) |
[ "8443", "9443", "15017"] | no |
| firewall_priority | Priority rule for firewall rules | number |
1000 |
no |
| fleet_project | (Optional) Register the cluster with the fleet in this project. | string |
null |
no |
| fleet_project_grant_service_agent | (Optional) Grant the fleet project service identity the roles/gkehub.serviceAgent and roles/gkehub.crossProjectServiceAgent roles. |
bool |
false |
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 |
| gcp_public_cidrs_access_enabled | Allow access through Google Cloud public IP addresses | bool |
null |
no |
| gcs_fuse_csi_driver | Whether GCE FUSE CSI driver is enabled for this cluster. | bool |
false |
no |
| gke_auto_upgrade_config_patch_mode | The selected auto-upgrade patch type. Accepted values are: ACCELERATED: Upgrades to the latest available patch version in a given minor and release channel. |
string |
null |
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 |
| hpa_profile | Enable the Horizontal Pod Autoscaling profile for this cluster. Values are "NONE" and "PERFORMANCE". | string |
"" |
no |
| http_load_balancing | Enable httpload balancer addon | bool |
true |
no |
| identity_namespace | The workload pool to attach all Kubernetes service accounts to. (Default value of enabled automatically sets project-based pool [project_id].svc.id.goog) |
string |
"enabled" |
no |
| in_transit_encryption_config | Defines the config of in-transit encryption. Valid values are IN_TRANSIT_ENCRYPTION_DISABLED and IN_TRANSIT_ENCRYPTION_INTER_NODE_TRANSPARENT. |
string |
null |
no |
| initial_node_count | The number of nodes to create in this cluster's default node pool. | number |
0 |
no |
| insecure_kubelet_readonly_port_enabled | Whether or not to set insecure_kubelet_readonly_port_enabled for node pool defaults and autopilot clusters. Note: this can be set at the node pool level separately within node_pools. |
bool |
null |
no |
| ip_endpoints_enabled | (Optional) Controls whether to allow direct IP access. Defaults to true. |
bool |
null |
no |
| ip_masq_link_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | bool |
false |
no |
| ip_masq_resync_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string |
"60s" |
no |
| ip_range_pods | The name of the secondary subnet ip range to use for pods | string |
n/a | yes |
| ip_range_services | The name of the secondary subnet range to use for services. If not provided, the default 34.118.224.0/20 range will be used. |
string |
null |
no |
| issue_client_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| kubernetes_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string |
"latest" |
no |
| logging_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, KCP_CONNECTION, KCP_SSHD, KCP_HPA, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration. | list(string) |
[] |
no |
| logging_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string |
"logging.googleapis.com/kubernetes" |
no |
| logging_variant | (Optional) The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | string |
null |
no |
| lustre_csi_driver | The status of the Lustre CSI driver addon, which allows the usage of a Lustre instances as volumes | bool |
null |
no |
| maintenance_end_time | Time window specified for recurring maintenance operations in RFC3339 format | string |
"" |
no |
| maintenance_exclusions | List of maintenance exclusions. A cluster can have up to three | list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string })) |
[] |
no |
| maintenance_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string |
"" |
no |
| maintenance_start_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string |
"05:00" |
no |
| master_authorized_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | list(object({ cidr_block = string, display_name = string })) |
[] |
no |
| master_global_access_enabled | Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint. | bool |
true |
no |
| master_ipv4_cidr_block | (Optional) The IP range in CIDR notation to use for the hosted master network. | string |
null |
no |
| monitoring_auto_monitoring_config_scope | Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE | string |
"NONE" |
no |
| monitoring_enable_managed_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | bool |
null |
no |
| monitoring_enable_observability_metrics | Whether or not the advanced datapath metrics are enabled. | bool |
false |
no |
| monitoring_enable_observability_relay | Whether or not the advanced datapath relay is enabled. | bool |
false |
no |
| monitoring_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR, DCGM, and JOBSET. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. JOBSET is only supported in GKE 1.32.1-gke.1357001 and above. Empty list is default GKE configuration. | list(string) |
[] |
no |
| monitoring_metric_writer_role | The monitoring metrics writer role to assign to the GKE node service account | string |
"roles/monitoring.metricWriter" |
no |
| monitoring_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string |
"monitoring.googleapis.com/kubernetes" |
no |
| name | The name of the cluster (required) | string |
n/a | yes |
| network | The VPC network to host the cluster in (required) | string |
n/a | yes |
| network_policy | Enable network policy addon | bool |
false |
no |
| network_policy_provider | The network policy provider. | string |
"CALICO" |
no |
| network_project_id | The project ID of the shared VPC's host (for shared vpc support) | string |
"" |
no |
| network_tags | (Optional) - List of network tags applied to autopilot and auto-provisioned node pools. | list(string) |
[] |
no |
| network_tier_config | Network tier configuration for the cluster | string |
null |
no |
| node_metadata | Specifies how node metadata is exposed to the workload running on the node | string |
"GKE_METADATA" |
no |
| node_pools | List of maps containing node pools | list(map(any)) |
[ { "name": "default-node-pool" }] | no |
| node_pools_cgroup_mode | Map of strings containing cgroup node config by node-pool name. Note: GKE is removing cgroup v1 support in 1.35. | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_1g | Map of strings containing hugepage size 1g config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_2m | Map of strings containing hugepage size 2m node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_labels | Map of maps containing node labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_linux_node_configs_sysctls | Map of maps containing linux node config sysctls by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_oauth_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) |
{ "all": [ "https://www.googleapis.com/auth/cloud-platform" ], "default-node-pool": []} | no |
| node_pools_resource_labels | Map of maps containing resource labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_resource_manager_tags | Map of maps containing resource manager tags by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_tags | Map of lists containing node network tags by node-pool name | map(list(string)) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_taints | Map of lists containing node taints by node-pool name | map(list(object({ key = string, value = string, effect = string }))) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_transparent_hugepage_defrag | Map of strings containing transparent hugepage defrag node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_transparent_hugepage_enabled | Map of strings containing transparent hugepage enabled node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| non_masquerade_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) |
[ "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"] | no |
| notification_config_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | string |
"" |
no |
| notification_filter_event_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT. | list(string) |
[] |
no |
| parallelstore_csi_driver | Whether the Parallelstore CSI driver Addon is enabled for this cluster. | bool |
null |
no |
| private_endpoint_subnetwork | The subnetwork to use for the hosted master network. | string |
null |
no |
| project_id | The project ID to host the cluster in (required) | string |
n/a | yes |
| ray_operator_config | The Ray Operator Addon configuration for this cluster. | object({ enabled = bool logging_enabled = optional(bool, false) monitoring_enabled = optional(bool, false) }) | { "enabled": false, "logging_enabled": false, "monitoring_enabled": false} | no |
| rbac_binding_config | RBACBindingConfig allows user to restrict ClusterRoleBindings an RoleBindings that can be created. | object({ enable_insecure_binding_system_unauthenticated = optional(bool, null) enable_insecure_binding_system_authenticated = optional(bool, null) }) | { "enable_insecure_binding_system_authenticated": null, "enable_insecure_binding_system_unauthenticated": null} | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string |
null |
no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool |
true |
no |
| registry_project_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the grant_registry_access variable is set to true, the storage.objectViewer and artifactregsitry.reader roles are assigned on these projects. |
list(string) |
[] |
no |
| release_channel | The release channel of this cluster. Accepted values are UNSPECIFIED, RAPID, REGULAR and STABLE. Defaults to REGULAR. |
string |
"REGULAR" |
no |
| remove_default_node_pool | Remove default node pool while setting up the cluster | bool |
false |
no |
| resource_manager_tags | (Optional) - List of resource manager tags applied to autopilot and auto-provisioned node pools. A maximum of 5 tags can be specified. Tags must be in one of these formats: "tagKeys/{tag_key_id}"="tagValues/{tag_value_id}", "{org_id}/{tag_key_name}"="{tag_value_name}", "{project_id}/{tag_key_name}"="{tag_value_name}". | map(string) |
{} |
no |
| 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 |
| security_posture_mode | Security posture mode. Accepted values are DISABLED and BASIC. Defaults to DISABLED. |
string |
"DISABLED" |
no |
| security_posture_vulnerability_mode | Security posture vulnerability mode. Accepted values are VULNERABILITY_DISABLED, VULNERABILITY_BASIC, and VULNERABILITY_ENTERPRISE. Defaults to VULNERABILITY_DISABLED. |
string |
"VULNERABILITY_DISABLED" |
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. This service account should already exists and it will be used by the node pools. If you wish to only override the service account name, you can use service_account_name variable. |
string |
"" |
no |
| service_account_name | The name of the service account that will be created if create_service_account is true. If you wish to use an existing service account, use service_account variable. | string |
"" |
no |
| service_external_ips | Whether external ips specified by a service will be allowed in this cluster | bool |
false |
no |
| shadow_firewall_rules_log_config | The log_config for shadow firewall rules. You can set this variable to null to disable logging. |
object({ metadata = string }) | { "metadata": "INCLUDE_ALL_METADATA"} | 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 |
| stack_type | The stack type to use for this cluster. Either IPV4 or IPV4_IPV6. Defaults to IPV4. |
string |
"IPV4" |
no |
| stateful_ha | Whether the Stateful HA Addon is enabled for this cluster. | 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 |
| subnetwork | The subnetwork to host the cluster in (required) | string |
n/a | yes |
| timeouts | Timeout for cluster operations. | map(string) |
{} |
no |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier for NodePools in the cluster. Valid values are TIER_UNSPECIFIED and TIER_1. Defaults to TIER_UNSPECIFIED. |
string |
null |
no |
| upstream_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list(string) |
[] |
no |
| user_managed_keys_config | The User Managed Keys configuration for the cluster. | object({ aggregation_ca = optional(string) cluster_ca = optional(string) control_plane_disk_encryption_key = optional(string) etcd_api_ca = optional(string) etcd_peer_ca = optional(string) gkeops_etcd_backup_encryption_key = optional(string) service_account_signing_keys = optional(list(string)) service_account_verification_keys = optional(list(string)) }) | null |
no |
| windows_node_pools | List of maps containing Windows node pools | list(map(string)) |
[] |
no |
| workload_config_audit_mode | (beta) Sets which mode of auditing should be used for the cluster's workloads. Accepted values are DISABLED, BASIC. | string |
"DISABLED" |
no |
| workload_vulnerability_mode | (beta) Sets which mode to use for Protect workload vulnerability scanning feature. Accepted values are DISABLED, BASIC. | string |
"" |
no |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cloudrun_enabled | Whether CloudRun enabled |
| cluster_id | Cluster ID |
| dns_cache_enabled | Whether DNS Cache enabled |
| endpoint | Cluster endpoint |
| endpoint_dns | Cluster endpoint DNS |
| fleet_membership | Fleet membership (if registered) |
| gateway_api_channel | The gateway api channel of this cluster. |
| horizontal_pod_autoscaling_enabled | Whether horizontal pod autoscaling enabled |
| http_load_balancing_enabled | Whether http load balancing enabled |
| identity_namespace | Workload Identity pool |
| identity_service_enabled | Whether Identity Service is enabled |
| instance_group_urls | List of GKE generated instance groups |
| intranode_visibility_enabled | Whether intra-node visibility is enabled |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| logging_service | Logging service used |
| master_authorized_networks_config | Networks from which access to master is permitted |
| master_ipv4_cidr_block | The IP range in CIDR notation used for the hosted master network |
| master_version | Current master kubernetes version |
| mesh_certificates_config | Mesh certificates configuration |
| min_master_version | Minimum master kubernetes version |
| monitoring_service | Monitoring service used |
| name | Cluster name |
| network_policy_enabled | Whether network policy enabled |
| node_pools_names | List of node pools names |
| node_pools_versions | Node pool versions by node pool name |
| peering_name | The name of the peering between this cluster and the Google owned VPC. |
| pod_security_policy_enabled | Whether pod security policy is enabled |
| region | Cluster region |
| release_channel | The release channel of this cluster |
| secret_manager_addon_enabled | Whether Secret Manager add-on is enabled |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| tpu_ipv4_cidr_block | The IP range in CIDR notation used for the TPUs |
| type | Cluster type (regional / zonal) |
| vertical_pod_autoscaling_enabled | Whether vertical pod autoscaling enabled |
| zones | List of zones in which the cluster resides |
node_pools variable
Use this variable for provisioning linux based node pools. For Windows based node pools use windows_node_pools
The node_pools variable takes the following parameters:
| Name | Description | Default | Requirement |
|---|---|---|---|
| accelerator_count | The number of the guest accelerator cards exposed to this instance | 0 | Optional |
| accelerator_type | The accelerator type resource to expose to the instance | " " | Optional |
| auto_repair | Whether the nodes will be automatically repaired | true | Optional |
| autoscaling | Configuration required by cluster autoscaler to adjust the size of the node pool to the current cluster usage | true | Optional |
| auto_upgrade | Whether the nodes will be automatically upgraded | true (if cluster is regional) | Optional |
| storage_pools | The list of Storage Pools where boot disks are provisioned. | Optional | |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. | " " | Optional |
| cpu_manager_policy | The CPU manager policy on the node. One of "none" or "static". | "static" | Optional |
| cpu_cfs_quota | Enforces the Pod's CPU limit. Setting this value to false means that the CPU limits for Pods are ignored | null | Optional |
| cpu_cfs_quota_period | The CPU CFS quota period value, which specifies the period of how often a cgroup's access to CPU resources should be reallocated | null | Optional |
| pod_pids_limit | Controls the maximum number of processes allowed to run in a pod. The value must be greater than or equal to 1024 and less than 4194304. | null | Optional |
| container_log_max_size | Defines the maximum size of the container log file before it is rotated. | null | Optional |
| container_log_max_files | Defines the maximum number of container log files that can be present for a container. | null | Optional |
| image_gc_low_threshold_percent | Defines the percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to. | null | Optional |
| image_gc_high_threshold_percent | Defines the percent of disk usage after which image garbage collection is always run. | null | Optional |
| image_minimum_gc_age | Defines the minimum age for an unused image before it is garbage collected. | null | Optional |
| image_maximum_gc_age | Defines the maximum age an image can be unused before it is garbage collected. | null | Optional |
| allowed_unsafe_sysctls | Defines a comma-separated allowlist of unsafe sysctls or sysctl patterns which can be set on the Pods. This should be passed as comma separated string. | null | Optional |
| enable_confidential_nodes | An optional flag to enable confidential node config. | false | Optional |
| disk_size_gb | Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB | 100 | Optional |
| disk_type | Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') | pd-standard | Optional |
| provisioned_iops | Indicates how many IOPS to provision for the disk. This sets the number of I/O operations per second that the disk can handle. For more details, see the Hyperdisk documentation. | null | Optional |
| provisioned_throughput | Indicates how much throughput to provision for the disk, in MB/s. This sets the amount of data that can be read or written to the disk per second. For more details, see the Hyperdisk documentation. | null | Optional |
| effect | Effect for the taint | Required | |
| enable_fast_socket | Enable the NCCL Fast Socket feature. enable_gvnic must also be enabled. |
null | Optional |
| enable_gcfs | Google Container File System (gcfs) has to be enabled for image streaming to be active. Needs image_type to be set to COS_CONTAINERD. | false | Optional |
| enable_gvnic | gVNIC (GVE) is an alternative to the virtIO-based ethernet driver. Needs a Container-Optimized OS node image. | false | Optional |
| enable_integrity_monitoring | Enables monitoring and attestation of the boot integrity of the instance. The attestation is performed against the integrity policy baseline. This baseline is initially derived from the implicitly trusted boot image when the instance is created. | true | Optional |
| enable_secure_boot | Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. | false | Optional |
| gpu_driver_version | Mode for how the GPU driver is installed | null | Optional |
| gpu_partition_size | Size of partitions to create on the GPU | null | Optional |
| image_type | The image type to use for this node. Note that changing the image type will delete and recreate all nodes in the node pool | COS_CONTAINERD | Optional |
| initial_node_count | The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. Changing this will force recreation of the resource. Defaults to the value of min_count | " " | Optional |
| insecure_kubelet_readonly_port_enabled | (boolean) Whether or not to enable the insecure Kubelet readonly port. | null | Optional |
| single_process_oom_kill | (boolean) On cgroupv2 nodes, defines whether processes in the container are OOM killed individually (true) or as a group (false, the kubelet default). Leave null to keep the kubelet default. | null | Optional |
| key | The key required for the taint | Required | |
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a hostpath volume or a local PersistentVolume. |
0 | Optional |
| local_ssd_ephemeral_storage_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| ephemeral_storage_local_ssd_data_cache_count | Number of raw-block local NVMe SSD disks to be attached to the node utilized for GKE Data Cache. | 0 | Optional |
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| local_nvme_ssd_count | Number of raw-block local NVMe SSD disks to be attached to the node.Each local SSD is 375 GB in size. If zero, it means no raw-block local NVMe SSD disks to be attached to the node. | 0 | Optional |
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
| enable_confidential_storage | Enabling Confidential Storage will create boot disk with confidential mode. | false | Optional |
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
| strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: SURGE, BLUE_GREEN, or for flex-start and queued provisioning SHORT_LIVED |
"SURGE" | Optional |
| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional |
| enable_nested_virtualization | Whether the node should have nested virtualization | null | Optional |
| performance_monitoring_unit | Level of Performance Monitoring Unit (PMU) requested. If unset, no access to the PMU is assumed. Values values are: ARCHITECTURAL, STANDARD, and ENHANCED |
null | Optional |
| max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with SURGE strategy. |
1 | Optional |
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with SURGE strategy. |
0 | Optional |
| node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with BLUE_GREEN strategy. |
"3600s" | Optional |
| batch_soak_duration | Soak time after each batch gets drained, with the default being zero seconds. Only works with BLUE_GREEN strategy. |
"0s" | Optional |
| batch_node_count | Absolute number of nodes to drain in a batch. If it is set to zero, this phase will be skipped. Cannot be used together with batch_percentage. Only works with BLUE_GREEN strategy. |
1 | Optional |
| batch_percentage | Percentage of nodes to drain in a batch. Must be in the range of [0.0, 1.0]. If it is set to zero, this phase will be skipped. Cannot be used together with batch_node_count. Only works with BLUE_GREEN strategy. |
null | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
| name | The name of the node pool | Required | |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as COMPACT if desired | Optional | |
| policy_name | If set, refers to the name of a custom resource policy supplied by the user. The resource policy must be in the same project and region as the node pool. | Optional | |
| tpu_topology | TPU placement topology for pod slice node pool. For detail see documentation | Optional | |
| pod_range | The name of the secondary range for pod IPs. | Optional | |
| node_affinity | The node affinty in the format "{\"key\": \"compute.googleapis.com/node-group-name\", \"operator\": \"IN\", \"values\": [\"node-group-name\"]}". |
Optional | |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | Required | |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
| node_metadata | Options to expose the node metadata to the workload running on the node | Optional | |
| preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional |
| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional |
| sandbox_type | Sandbox to use for pods in the node pool | Required | |
| service_account | The service account to be used by the Node VMs | " " | Optional |
| tags | The list of instance tags applied to all nodes | Required | |
| value | The value for the taint | Required | |
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
| location_policy | Location policy specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see documentation. gcfs_config must be enabled=true for this feature to work. |
Optional | |
| secondary_boot_disk_mode | Mode for the secondary boot disk. Defaults to CONTAINER_IMAGE_CACHE (preloads container images, requires gcfs_config enabled). Set to null to omit the field for data preloading (mounts data onto nodes for use via hostPath). |
"CONTAINER_IMAGE_CACHE" |
Optional |
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | Optional | |
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | Optional | |
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | Optional | |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier. Valid values are: "TIER_1" and "TIER_UNSPECIFIED". | Optional | |
| pod_cidr_overprovision_disabled | Disables GKE's default doubling of the per-node pod IP range allocation when set to true. |
Optional | |
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | Optional | |
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | Optional | |
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | Optional | |
| local_ssd_encryption_mode | specifies the method used for encrypting the local SSDs attached to the node. Valid values are: "STANDARD_ENCRYPTION" and "EPHEMERAL_KEY_ENCRYPTION" | Optional | |
| max_run_duration | The runtime of each node in the node pool in seconds, terminated by 's'. Example: "3600s". | null | Optional |
| flex_start | Enables Flex Start provisioning model for the node pool | null | Optional |
| respect_pdb_during_node_pool_deletion | Whether to respect Pod Disruption Budgets during node pool deletion. | null | Optional |
windows_node_pools variable
The windows_node_pools variable takes the same parameters as node_pools but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a specific requirement for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.
| Name | Description | Default | Requirement |
|---|---|---|---|
| windows_node_config_os_version | The Windows OS version to use for the windows node pool. Valid values are OS_VERSION_UNSPECIFIED, OS_VERSION_LTSC2019 and OS_VERSION_LTSC2022. | null | Optional |
Requirements
Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:
- Terraform and kubectl are installed on the machine where Terraform is executed.
- The Service Account you execute the module with has the right permissions.
- The Compute Engine and Kubernetes Engine APIs are active on the project you will launch the cluster in.
- If you are using a Shared VPC, the APIs must also be activated on the Shared VPC host project and your service account needs the proper permissions there.
The project factory can be used to provision projects with the correct APIs active and the necessary Shared VPC connections.
Software Dependencies
Kubectl
- kubectl 1.9.x
Terraform and Plugins
- Terraform 1.3+
- Terraform Provider for GCP Beta v7.39+
gcloud
Some submodules use the terraform-google-gcloud module. By default, this module assumes you already have gcloud installed in your $PATH.
See the module documentation for more information.
Configure a Service Account
In order to execute this module you must have a Service Account with the
following project roles:
- roles/compute.viewer
- roles/compute.securityAdmin (only required if
add_cluster_firewall_rulesis set totrue) - roles/container.clusterAdmin
- roles/container.developer
- roles/iam.serviceAccountAdmin
- roles/iam.serviceAccountUser
- roles/resourcemanager.projectIamAdmin (only required if
service_accountis set tocreate)
Additionally, if service_account is set to create and grant_registry_access is requested, the service account requires the following role on the registry_project_ids projects:
- roles/resourcemanager.projectIamAdmin
Enable APIs
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
- Compute Engine API - compute.googleapis.com
- Kubernetes Engine API - container.googleapis.com
Overview (`modules/beta-private-cluster/README.md`)
Terraform Kubernetes Engine Module
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, IP MASQ, Network Policy, etc. This particular submodule creates a private clusterBeta features are enabled in this submodule.
The resources/services/activations/deletions that this module will create/trigger are:
- Create a GKE cluster with the provided addons
- Create GKE Node Pool(s) with provided configuration and attach to cluster
- Replace the default kube-dns configmap if
stub_domainsare provided - Activate network policy if
network_policyis true - Add
ip-masq-agentconfigmap with providednon_masquerade_cidrsifconfigure_ip_masqis true
Sub modules are provided for creating private clusters, beta private clusters, and beta public clusters as well. Beta sub modules allow for the use of various GKE beta features. See the modules directory for the various sub modules.
Private Cluster Details
For details on configuring private clusters with this module, check the troubleshooting guide.
Compatibility
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.14+.
If you find incompatibilities using Terraform >=1.3, please open an issue.
If you haven't upgraded to 1.3 and need a Terraform
0.13.x-compatible version of this module, the last released version
intended for Terraform 0.13.x is 27.0.0.
If you haven't upgraded to 0.13 and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is 12.3.0.
Usage
There are multiple examples included in the examples folder but simple usage is as follows:
/* Detailed source-code truncated for AI context efficiency. */Then perform the following commands on the root folder:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| add_cluster_firewall_rules | Create additional firewall rules | bool |
false |
no |
| 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 |
| additional_ip_range_pods | List of names of the additional secondary subnet ip ranges to use for pods | list(string) |
[] |
no |
| additional_ip_ranges_config | the configuration for individual additional subnetworks attached to the cluster | list(object({ subnetwork = string, pod_ipv4_range_names = list(string) })) |
[] |
no |
| additive_vpc_scope_dns_domain | This will enable Cloud DNS additive VPC scope. Must provide a domain name that is unique within the VPC. For this to work cluster_dns = CLOUD_DNS and cluster_dns_scope = CLUSTER_SCOPE must both be set as well. |
string |
"" |
no |
| agent_sandbox_enabled | The status of the Agent Sandbox addon, which isolates untrusted code execution (requires GKE version 1.35.2-gke.1269000 or later and a gVisor-enabled node pool) | bool |
null |
no |
| anonymous_authentication_config_mode | Allows users to restrict or enable anonymous access to the cluster. Valid values are ENABLED and LIMITED. |
string |
null |
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 [email protected] | string |
null |
no |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool, if not overridden in node_pools. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. For more information about protecting resources with Cloud KMS Keys please see: https://cloud.google.com/compute/docs/disks/customer-managed-encryption |
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 | object({ enabled = bool autoscaling_profile = string min_cpu_cores = optional(number) max_cpu_cores = optional(number) min_memory_gb = optional(number) max_memory_gb = optional(number) gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number })) auto_repair = bool auto_upgrade = bool disk_size = optional(number) disk_type = optional(string) image_type = optional(string) strategy = optional(string) max_surge = optional(number) max_unavailable = optional(number) node_pool_soak_duration = optional(string) batch_soak_duration = optional(string) batch_percentage = optional(number) batch_node_count = optional(number) enable_secure_boot = optional(bool, false) enable_integrity_monitoring = optional(bool, true) enable_default_compute_class = optional(bool, false) }) | { "auto_repair": true, "auto_upgrade": true, "autoscaling_profile": "BALANCED", "disk_size": 100, "disk_type": "pd-standard", "enable_default_compute_class": false, "enable_integrity_monitoring": true, "enable_secure_boot": false, "enabled": false, "gpu_resources": [], "image_type": "COS_CONTAINERD", "max_cpu_cores": 0, "max_memory_gb": 0, "min_cpu_cores": 0, "min_memory_gb": 0} | 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 |
| cluster_ipv4_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string |
null |
no |
| cluster_resource_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) |
{} |
no |
| cluster_telemetry_type | Available options include ENABLED, DISABLED, and SYSTEM_ONLY | string |
null |
no |
| config_connector | Whether ConfigConnector is enabled for this cluster. | bool |
false |
no |
| configure_ip_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | bool |
false |
no |
| create_service_account | Defines if service account specified to run nodes should be created. | bool |
true |
no |
| database_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | list(object({ state = string, key_name = string })) |
[ { "key_name": "", "state": "DECRYPTED" }] | no |
| datapath_provider | 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. |
string |
"DATAPATH_PROVIDER_UNSPECIFIED" |
no |
| default_max_pods_per_node | The maximum number of pods to schedule per node | number |
110 |
no |
| deletion_protection | Whether or not to allow Terraform to destroy the cluster. | bool |
true |
no |
| deploy_using_private_endpoint | A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | bool |
false |
no |
| description | The description of the cluster | string |
"" |
no |
| disable_default_snat | Whether to disable the default SNAT to support the private use of public IP addresses | bool |
false |
no |
| disable_l4_lb_firewall_reconciliation | Disable L4 Load Balancer firewall reconciliation | bool |
null |
no |
| disable_legacy_metadata_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | bool |
true |
no |
| dns_allow_external_traffic | (Optional) Controls whether external traffic is allowed over the dns endpoint. | bool |
null |
no |
| dns_cache | The status of the NodeLocal DNSCache addon. | bool |
false |
no |
| dns_enable_k8s_tokens_via_dns | (Optional) Controls whether Kubernetes ServiceAccount token authentication is allowed via the DNS endpoint. | bool |
null |
no |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| enable_cilium_clusterwide_network_policy | Enable Cilium Cluster Wide Network Policies on the cluster | bool |
false |
no |
| enable_confidential_nodes | An optional flag to enable confidential node config. | bool |
false |
no |
| enable_cost_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | bool |
false |
no |
| enable_default_node_pools_metadata | Whether to enable the default node pools metadata key-value pairs such as cluster_name and node_pool |
bool |
true |
no |
| enable_fqdn_network_policy | Enable FQDN Network Policies on the cluster | bool |
null |
no |
| enable_gcfs | Enable image streaming on cluster level. | bool |
false |
no |
| enable_identity_service | (Optional) Enable the Identity Service component, which allows customers to use external identity providers with the K8S API. NOTE: Starting on July 1, 2025, new Google Cloud organizations that you create won't support Identity Service for GKE. | bool |
false |
no |
| enable_intranode_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | bool |
false |
no |
| enable_k8s_beta_apis | (Optional) - List of Kubernetes Beta APIs to enable in cluster. | list(string) |
[] |
no |
| enable_kubernetes_alpha | Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days. | bool |
false |
no |
| enable_l4_ilb_subsetting | Enable L4 ILB Subsetting on the cluster | bool |
false |
no |
| enable_legacy_lustre_port | Set it to true for GKE cluster runs a version earlier than 1.33.2-gke.4780000. Allows the Lustre CSI driver to initialize LNet (the virtual network layer for Lustre kernel module) using port 6988. This flag is required to workaround a port conflict with the gke-metadata-server on GKE nodes | bool |
false |
no |
| enable_managed_machine_learning_diagnostics | (beta) Enable Managed Machine Learning Diagnostics on the cluster. | bool |
null |
no |
| enable_mesh_certificates | Controls the issuance of workload mTLS certificates. When enabled the GKE Workload Identity Certificates controller and node agent will be deployed in the cluster. Requires Workload Identity. | bool |
false |
no |
| enable_multi_networking | Whether multi-networking is enabled for this cluster | bool |
null |
no |
| enable_network_egress_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | bool |
false |
no |
| enable_pod_security_policy | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. Pod Security Policy was removed from GKE clusters with version >= 1.25.0. | bool |
false |
no |
| enable_private_endpoint | Whether the master's internal IP address is used as the cluster endpoint | bool |
false |
no |
| enable_private_nodes | Whether nodes have internal IP addresses only | bool |
true |
no |
| enable_resource_consumption_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | bool |
true |
no |
| enable_secret_manager_addon | Enable the Secret Manager add-on for this cluster | bool |
false |
no |
| enable_secret_sync | Enable the Secret Sync add-on for this cluster. | bool |
false |
no |
| enable_shielded_nodes | Enable Shielded Nodes features on all nodes in this cluster | bool |
true |
no |
| enable_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| enable_vertical_pod_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool |
false |
no |
| enterprise_config | (Optional) Enable or disable GKE enterprise. Valid values are STANDARD and ENTERPRISE. | string |
null |
no |
| filestore_csi_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | bool |
false |
no |
| firewall_inbound_ports | List of TCP ports for admission/webhook controllers. Either flag add_master_webhook_firewall_rules or add_cluster_firewall_rules (also adds egress rules) must be set to true for inbound-ports firewall rules to be applied. |
list(string) |
[ "8443", "9443", "15017"] | no |
| firewall_priority | Priority rule for firewall rules | number |
1000 |
no |
| fleet_project | (Optional) Register the cluster with the fleet in this project. | string |
null |
no |
| fleet_project_grant_service_agent | (Optional) Grant the fleet project service identity the roles/gkehub.serviceAgent and roles/gkehub.crossProjectServiceAgent roles. |
bool |
false |
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 |
| gcp_public_cidrs_access_enabled | Allow access through Google Cloud public IP addresses | bool |
null |
no |
| gcs_fuse_csi_driver | Whether GCE FUSE CSI driver is enabled for this cluster. | bool |
false |
no |
| gke_auto_upgrade_config_patch_mode | The selected auto-upgrade patch type. Accepted values are: ACCELERATED: Upgrades to the latest available patch version in a given minor and release channel. |
string |
null |
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 |
| hpa_profile | Enable the Horizontal Pod Autoscaling profile for this cluster. Values are "NONE" and "PERFORMANCE". | string |
"" |
no |
| http_load_balancing | Enable httpload balancer addon | bool |
true |
no |
| identity_namespace | The workload pool to attach all Kubernetes service accounts to. (Default value of enabled automatically sets project-based pool [project_id].svc.id.goog) |
string |
"enabled" |
no |
| in_transit_encryption_config | Defines the config of in-transit encryption. Valid values are IN_TRANSIT_ENCRYPTION_DISABLED and IN_TRANSIT_ENCRYPTION_INTER_NODE_TRANSPARENT. |
string |
null |
no |
| initial_node_count | The number of nodes to create in this cluster's default node pool. | number |
0 |
no |
| insecure_kubelet_readonly_port_enabled | Whether or not to set insecure_kubelet_readonly_port_enabled for node pool defaults and autopilot clusters. Note: this can be set at the node pool level separately within node_pools. |
bool |
null |
no |
| ip_endpoints_enabled | (Optional) Controls whether to allow direct IP access. Defaults to true. |
bool |
null |
no |
| ip_masq_link_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | bool |
false |
no |
| ip_masq_resync_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string |
"60s" |
no |
| ip_range_pods | The name of the secondary subnet ip range to use for pods | string |
n/a | yes |
| ip_range_services | The name of the secondary subnet range to use for services. If not provided, the default 34.118.224.0/20 range will be used. |
string |
null |
no |
| issue_client_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| kubernetes_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string |
"latest" |
no |
| logging_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, KCP_CONNECTION, KCP_SSHD, KCP_HPA, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration. | list(string) |
[] |
no |
| logging_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string |
"logging.googleapis.com/kubernetes" |
no |
| logging_variant | (Optional) The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | string |
null |
no |
| lustre_csi_driver | The status of the Lustre CSI driver addon, which allows the usage of a Lustre instances as volumes | bool |
null |
no |
| maintenance_end_time | Time window specified for recurring maintenance operations in RFC3339 format | string |
"" |
no |
| maintenance_exclusions | List of maintenance exclusions. A cluster can have up to three | list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string })) |
[] |
no |
| maintenance_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string |
"" |
no |
| maintenance_start_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string |
"05:00" |
no |
| master_authorized_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | list(object({ cidr_block = string, display_name = string })) |
[] |
no |
| master_global_access_enabled | Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint. | bool |
true |
no |
| master_ipv4_cidr_block | (Optional) The IP range in CIDR notation to use for the hosted master network. | string |
null |
no |
| monitoring_auto_monitoring_config_scope | Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE | string |
"NONE" |
no |
| monitoring_enable_managed_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | bool |
null |
no |
| monitoring_enable_observability_metrics | Whether or not the advanced datapath metrics are enabled. | bool |
false |
no |
| monitoring_enable_observability_relay | Whether or not the advanced datapath relay is enabled. | bool |
false |
no |
| monitoring_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR, DCGM, and JOBSET. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. JOBSET is only supported in GKE 1.32.1-gke.1357001 and above. Empty list is default GKE configuration. | list(string) |
[] |
no |
| monitoring_metric_writer_role | The monitoring metrics writer role to assign to the GKE node service account | string |
"roles/monitoring.metricWriter" |
no |
| monitoring_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string |
"monitoring.googleapis.com/kubernetes" |
no |
| name | The name of the cluster (required) | string |
n/a | yes |
| network | The VPC network to host the cluster in (required) | string |
n/a | yes |
| network_policy | Enable network policy addon | bool |
false |
no |
| network_policy_provider | The network policy provider. | string |
"CALICO" |
no |
| network_project_id | The project ID of the shared VPC's host (for shared vpc support) | string |
"" |
no |
| network_tags | (Optional) - List of network tags applied to autopilot and auto-provisioned node pools. | list(string) |
[] |
no |
| network_tier_config | Network tier configuration for the cluster | string |
null |
no |
| node_metadata | Specifies how node metadata is exposed to the workload running on the node | string |
"GKE_METADATA" |
no |
| node_pools | List of maps containing node pools | list(map(any)) |
[ { "name": "default-node-pool" }] | no |
| node_pools_cgroup_mode | Map of strings containing cgroup node config by node-pool name. Note: GKE is removing cgroup v1 support in 1.35. | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_1g | Map of strings containing hugepage size 1g config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_2m | Map of strings containing hugepage size 2m node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_labels | Map of maps containing node labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_linux_node_configs_sysctls | Map of maps containing linux node config sysctls by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_oauth_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) |
{ "all": [ "https://www.googleapis.com/auth/cloud-platform" ], "default-node-pool": []} | no |
| node_pools_resource_labels | Map of maps containing resource labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_resource_manager_tags | Map of maps containing resource manager tags by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_tags | Map of lists containing node network tags by node-pool name | map(list(string)) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_taints | Map of lists containing node taints by node-pool name | map(list(object({ key = string, value = string, effect = string }))) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_transparent_hugepage_defrag | Map of strings containing transparent hugepage defrag node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_transparent_hugepage_enabled | Map of strings containing transparent hugepage enabled node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| non_masquerade_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) |
[ "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"] | no |
| notification_config_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | string |
"" |
no |
| notification_filter_event_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT. | list(string) |
[] |
no |
| parallelstore_csi_driver | Whether the Parallelstore CSI driver Addon is enabled for this cluster. | bool |
null |
no |
| private_endpoint_subnetwork | The subnetwork to use for the hosted master network. | string |
null |
no |
| project_id | The project ID to host the cluster in (required) | string |
n/a | yes |
| ray_operator_config | The Ray Operator Addon configuration for this cluster. | object({ enabled = bool logging_enabled = optional(bool, false) monitoring_enabled = optional(bool, false) }) | { "enabled": false, "logging_enabled": false, "monitoring_enabled": false} | no |
| rbac_binding_config | RBACBindingConfig allows user to restrict ClusterRoleBindings an RoleBindings that can be created. | object({ enable_insecure_binding_system_unauthenticated = optional(bool, null) enable_insecure_binding_system_authenticated = optional(bool, null) }) | { "enable_insecure_binding_system_authenticated": null, "enable_insecure_binding_system_unauthenticated": null} | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string |
null |
no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool |
true |
no |
| registry_project_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the grant_registry_access variable is set to true, the storage.objectViewer and artifactregsitry.reader roles are assigned on these projects. |
list(string) |
[] |
no |
| release_channel | The release channel of this cluster. Accepted values are UNSPECIFIED, RAPID, REGULAR and STABLE. Defaults to REGULAR. |
string |
"REGULAR" |
no |
| remove_default_node_pool | Remove default node pool while setting up the cluster | bool |
false |
no |
| resource_manager_tags | (Optional) - List of resource manager tags applied to autopilot and auto-provisioned node pools. A maximum of 5 tags can be specified. Tags must be in one of these formats: "tagKeys/{tag_key_id}"="tagValues/{tag_value_id}", "{org_id}/{tag_key_name}"="{tag_value_name}", "{project_id}/{tag_key_name}"="{tag_value_name}". | map(string) |
{} |
no |
| 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 |
| security_posture_mode | Security posture mode. Accepted values are DISABLED and BASIC. Defaults to DISABLED. |
string |
"DISABLED" |
no |
| security_posture_vulnerability_mode | Security posture vulnerability mode. Accepted values are VULNERABILITY_DISABLED, VULNERABILITY_BASIC, and VULNERABILITY_ENTERPRISE. Defaults to VULNERABILITY_DISABLED. |
string |
"VULNERABILITY_DISABLED" |
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. This service account should already exists and it will be used by the node pools. If you wish to only override the service account name, you can use service_account_name variable. |
string |
"" |
no |
| service_account_name | The name of the service account that will be created if create_service_account is true. If you wish to use an existing service account, use service_account variable. | string |
"" |
no |
| service_external_ips | Whether external ips specified by a service will be allowed in this cluster | bool |
false |
no |
| shadow_firewall_rules_log_config | The log_config for shadow firewall rules. You can set this variable to null to disable logging. |
object({ metadata = string }) | { "metadata": "INCLUDE_ALL_METADATA"} | 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 |
| stack_type | The stack type to use for this cluster. Either IPV4 or IPV4_IPV6. Defaults to IPV4. |
string |
"IPV4" |
no |
| stateful_ha | Whether the Stateful HA Addon is enabled for this cluster. | 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 |
| subnetwork | The subnetwork to host the cluster in (required) | string |
n/a | yes |
| timeouts | Timeout for cluster operations. | map(string) |
{} |
no |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier for NodePools in the cluster. Valid values are TIER_UNSPECIFIED and TIER_1. Defaults to TIER_UNSPECIFIED. |
string |
null |
no |
| upstream_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list(string) |
[] |
no |
| user_managed_keys_config | The User Managed Keys configuration for the cluster. | object({ aggregation_ca = optional(string) cluster_ca = optional(string) control_plane_disk_encryption_key = optional(string) etcd_api_ca = optional(string) etcd_peer_ca = optional(string) gkeops_etcd_backup_encryption_key = optional(string) service_account_signing_keys = optional(list(string)) service_account_verification_keys = optional(list(string)) }) | null |
no |
| windows_node_pools | List of maps containing Windows node pools | list(map(string)) |
[] |
no |
| workload_config_audit_mode | (beta) Sets which mode of auditing should be used for the cluster's workloads. Accepted values are DISABLED, BASIC. | string |
"DISABLED" |
no |
| workload_vulnerability_mode | (beta) Sets which mode to use for Protect workload vulnerability scanning feature. Accepted values are DISABLED, BASIC. | string |
"" |
no |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cloudrun_enabled | Whether CloudRun enabled |
| cluster_id | Cluster ID |
| dns_cache_enabled | Whether DNS Cache enabled |
| endpoint | Cluster endpoint |
| endpoint_dns | Cluster endpoint DNS |
| fleet_membership | Fleet membership (if registered) |
| gateway_api_channel | The gateway api channel of this cluster. |
| horizontal_pod_autoscaling_enabled | Whether horizontal pod autoscaling enabled |
| http_load_balancing_enabled | Whether http load balancing enabled |
| identity_namespace | Workload Identity pool |
| identity_service_enabled | Whether Identity Service is enabled |
| instance_group_urls | List of GKE generated instance groups |
| intranode_visibility_enabled | Whether intra-node visibility is enabled |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| logging_service | Logging service used |
| master_authorized_networks_config | Networks from which access to master is permitted |
| master_ipv4_cidr_block | The IP range in CIDR notation used for the hosted master network |
| master_version | Current master kubernetes version |
| mesh_certificates_config | Mesh certificates configuration |
| min_master_version | Minimum master kubernetes version |
| monitoring_service | Monitoring service used |
| name | Cluster name |
| network_policy_enabled | Whether network policy enabled |
| node_pools_names | List of node pools names |
| node_pools_versions | Node pool versions by node pool name |
| peering_name | The name of the peering between this cluster and the Google owned VPC. |
| pod_security_policy_enabled | Whether pod security policy is enabled |
| region | Cluster region |
| release_channel | The release channel of this cluster |
| secret_manager_addon_enabled | Whether Secret Manager add-on is enabled |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| tpu_ipv4_cidr_block | The IP range in CIDR notation used for the TPUs |
| type | Cluster type (regional / zonal) |
| vertical_pod_autoscaling_enabled | Whether vertical pod autoscaling enabled |
| zones | List of zones in which the cluster resides |
node_pools variable
Use this variable for provisioning linux based node pools. For Windows based node pools use windows_node_pools
The node_pools variable takes the following parameters:
| Name | Description | Default | Requirement |
|---|---|---|---|
| accelerator_count | The number of the guest accelerator cards exposed to this instance | 0 | Optional |
| accelerator_type | The accelerator type resource to expose to the instance | " " | Optional |
| auto_repair | Whether the nodes will be automatically repaired | true | Optional |
| autoscaling | Configuration required by cluster autoscaler to adjust the size of the node pool to the current cluster usage | true | Optional |
| auto_upgrade | Whether the nodes will be automatically upgraded | true (if cluster is regional) | Optional |
| storage_pools | The list of Storage Pools where boot disks are provisioned. | Optional | |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. | " " | Optional |
| cpu_manager_policy | The CPU manager policy on the node. One of "none" or "static". | "static" | Optional |
| cpu_cfs_quota | Enforces the Pod's CPU limit. Setting this value to false means that the CPU limits for Pods are ignored | null | Optional |
| cpu_cfs_quota_period | The CPU CFS quota period value, which specifies the period of how often a cgroup's access to CPU resources should be reallocated | null | Optional |
| pod_pids_limit | Controls the maximum number of processes allowed to run in a pod. The value must be greater than or equal to 1024 and less than 4194304. | null | Optional |
| container_log_max_size | Defines the maximum size of the container log file before it is rotated. | null | Optional |
| container_log_max_files | Defines the maximum number of container log files that can be present for a container. | null | Optional |
| image_gc_low_threshold_percent | Defines the percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to. | null | Optional |
| image_gc_high_threshold_percent | Defines the percent of disk usage after which image garbage collection is always run. | null | Optional |
| image_minimum_gc_age | Defines the minimum age for an unused image before it is garbage collected. | null | Optional |
| image_maximum_gc_age | Defines the maximum age an image can be unused before it is garbage collected. | null | Optional |
| allowed_unsafe_sysctls | Defines a comma-separated allowlist of unsafe sysctls or sysctl patterns which can be set on the Pods. This should be passed as comma separated string. | null | Optional |
| enable_confidential_nodes | An optional flag to enable confidential node config. | false | Optional |
| disk_size_gb | Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB | 100 | Optional |
| disk_type | Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') | pd-standard | Optional |
| provisioned_iops | Indicates how many IOPS to provision for the disk. This sets the number of I/O operations per second that the disk can handle. For more details, see the Hyperdisk documentation. | null | Optional |
| provisioned_throughput | Indicates how much throughput to provision for the disk, in MB/s. This sets the amount of data that can be read or written to the disk per second. For more details, see the Hyperdisk documentation. | null | Optional |
| effect | Effect for the taint | Required | |
| enable_fast_socket | Enable the NCCL Fast Socket feature. enable_gvnic must also be enabled. |
null | Optional |
| enable_gcfs | Google Container File System (gcfs) has to be enabled for image streaming to be active. Needs image_type to be set to COS_CONTAINERD. | false | Optional |
| enable_gvnic | gVNIC (GVE) is an alternative to the virtIO-based ethernet driver. Needs a Container-Optimized OS node image. | false | Optional |
| enable_integrity_monitoring | Enables monitoring and attestation of the boot integrity of the instance. The attestation is performed against the integrity policy baseline. This baseline is initially derived from the implicitly trusted boot image when the instance is created. | true | Optional |
| enable_secure_boot | Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. | false | Optional |
| gpu_driver_version | Mode for how the GPU driver is installed | null | Optional |
| gpu_partition_size | Size of partitions to create on the GPU | null | Optional |
| image_type | The image type to use for this node. Note that changing the image type will delete and recreate all nodes in the node pool | COS_CONTAINERD | Optional |
| initial_node_count | The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. Changing this will force recreation of the resource. Defaults to the value of min_count | " " | Optional |
| insecure_kubelet_readonly_port_enabled | (boolean) Whether or not to enable the insecure Kubelet readonly port. | null | Optional |
| single_process_oom_kill | (boolean) On cgroupv2 nodes, defines whether processes in the container are OOM killed individually (true) or as a group (false, the kubelet default). Leave null to keep the kubelet default. | null | Optional |
| key | The key required for the taint | Required | |
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a hostpath volume or a local PersistentVolume. |
0 | Optional |
| local_ssd_ephemeral_storage_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| ephemeral_storage_local_ssd_data_cache_count | Number of raw-block local NVMe SSD disks to be attached to the node utilized for GKE Data Cache. | 0 | Optional |
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| local_nvme_ssd_count | Number of raw-block local NVMe SSD disks to be attached to the node.Each local SSD is 375 GB in size. If zero, it means no raw-block local NVMe SSD disks to be attached to the node. | 0 | Optional |
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
| enable_confidential_storage | Enabling Confidential Storage will create boot disk with confidential mode. | false | Optional |
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
| strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: SURGE, BLUE_GREEN, or for flex-start and queued provisioning SHORT_LIVED |
"SURGE" | Optional |
| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional |
| enable_nested_virtualization | Whether the node should have nested virtualization | null | Optional |
| performance_monitoring_unit | Level of Performance Monitoring Unit (PMU) requested. If unset, no access to the PMU is assumed. Values values are: ARCHITECTURAL, STANDARD, and ENHANCED |
null | Optional |
| max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with SURGE strategy. |
1 | Optional |
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with SURGE strategy. |
0 | Optional |
| node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with BLUE_GREEN strategy. |
"3600s" | Optional |
| batch_soak_duration | Soak time after each batch gets drained, with the default being zero seconds. Only works with BLUE_GREEN strategy. |
"0s" | Optional |
| batch_node_count | Absolute number of nodes to drain in a batch. If it is set to zero, this phase will be skipped. Cannot be used together with batch_percentage. Only works with BLUE_GREEN strategy. |
1 | Optional |
| batch_percentage | Percentage of nodes to drain in a batch. Must be in the range of [0.0, 1.0]. If it is set to zero, this phase will be skipped. Cannot be used together with batch_node_count. Only works with BLUE_GREEN strategy. |
null | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
| name | The name of the node pool | Required | |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as COMPACT if desired | Optional | |
| policy_name | If set, refers to the name of a custom resource policy supplied by the user. The resource policy must be in the same project and region as the node pool. | Optional | |
| tpu_topology | TPU placement topology for pod slice node pool. For detail see documentation | Optional | |
| pod_range | The name of the secondary range for pod IPs. | Optional | |
| node_affinity | The node affinty in the format "{\"key\": \"compute.googleapis.com/node-group-name\", \"operator\": \"IN\", \"values\": [\"node-group-name\"]}". |
Optional | |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | Required | |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
| node_metadata | Options to expose the node metadata to the workload running on the node | Optional | |
| preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional |
| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional |
| sandbox_type | Sandbox to use for pods in the node pool | Required | |
| service_account | The service account to be used by the Node VMs | " " | Optional |
| tags | The list of instance tags applied to all nodes | Required | |
| value | The value for the taint | Required | |
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
| location_policy | Location policy specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see documentation. gcfs_config must be enabled=true for this feature to work. |
Optional | |
| secondary_boot_disk_mode | Mode for the secondary boot disk. Defaults to CONTAINER_IMAGE_CACHE (preloads container images, requires gcfs_config enabled). Set to null to omit the field for data preloading (mounts data onto nodes for use via hostPath). |
"CONTAINER_IMAGE_CACHE" |
Optional |
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | Optional | |
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | Optional | |
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | Optional | |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier. Valid values are: "TIER_1" and "TIER_UNSPECIFIED". | Optional | |
| pod_cidr_overprovision_disabled | Disables GKE's default doubling of the per-node pod IP range allocation when set to true. |
Optional | |
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | Optional | |
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | Optional | |
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | Optional | |
| local_ssd_encryption_mode | specifies the method used for encrypting the local SSDs attached to the node. Valid values are: "STANDARD_ENCRYPTION" and "EPHEMERAL_KEY_ENCRYPTION" | Optional | |
| max_run_duration | The runtime of each node in the node pool in seconds, terminated by 's'. Example: "3600s". | null | Optional |
| flex_start | Enables Flex Start provisioning model for the node pool | null | Optional |
| respect_pdb_during_node_pool_deletion | Whether to respect Pod Disruption Budgets during node pool deletion. | null | Optional |
windows_node_pools variable
The windows_node_pools variable takes the same parameters as node_pools but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a specific requirement for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.
| Name | Description | Default | Requirement |
|---|---|---|---|
| windows_node_config_os_version | The Windows OS version to use for the windows node pool. Valid values are OS_VERSION_UNSPECIFIED, OS_VERSION_LTSC2019 and OS_VERSION_LTSC2022. | null | Optional |
Requirements
Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:
- Terraform and kubectl are installed on the machine where Terraform is executed.
- The Service Account you execute the module with has the right permissions.
- The Compute Engine and Kubernetes Engine APIs are active on the project you will launch the cluster in.
- If you are using a Shared VPC, the APIs must also be activated on the Shared VPC host project and your service account needs the proper permissions there.
The project factory can be used to provision projects with the correct APIs active and the necessary Shared VPC connections.
Software Dependencies
Kubectl
- kubectl 1.9.x
Terraform and Plugins
- Terraform 1.3+
- Terraform Provider for GCP Beta v7.39+
gcloud
Some submodules use the terraform-google-gcloud module. By default, this module assumes you already have gcloud installed in your $PATH.
See the module documentation for more information.
Configure a Service Account
In order to execute this module you must have a Service Account with the
following project roles:
- roles/compute.viewer
- roles/compute.securityAdmin (only required if
add_cluster_firewall_rulesis set totrue) - roles/container.clusterAdmin
- roles/container.developer
- roles/iam.serviceAccountAdmin
- roles/iam.serviceAccountUser
- roles/resourcemanager.projectIamAdmin (only required if
service_accountis set tocreate)
Additionally, if service_account is set to create and grant_registry_access is requested, the service account requires the following role on the registry_project_ids projects:
- roles/resourcemanager.projectIamAdmin
Enable APIs
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
- Compute Engine API - compute.googleapis.com
- Kubernetes Engine API - container.googleapis.com
Overview (`modules/beta-public-cluster-update-variant/README.md`)
Terraform Kubernetes Engine Module
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, IP MASQ, Network Policy, etc.Beta features are enabled in this submodule.
The resources/services/activations/deletions that this module will create/trigger are:
- Create a GKE cluster with the provided addons
- Create GKE Node Pool(s) with provided configuration and attach to cluster
- Replace the default kube-dns configmap if
stub_domainsare provided - Activate network policy if
network_policyis true - Add
ip-masq-agentconfigmap with providednon_masquerade_cidrsifconfigure_ip_masqis true
Sub modules are provided for creating private clusters, beta private clusters, and beta public clusters as well. Beta sub modules allow for the use of various GKE beta features. See the modules directory for the various sub modules.
Node Pool Update Variant
In [#256] update variants added support for node pools to be created before being destroyed.
Before, if a node pool has to be recreated for any number of reasons,
the node pool is deleted then, created. This can be a problem if it is the only node pool in the GKE
cluster and the new node pool cannot be provisioned. In this scenario, pods could not be scheduled.
[#256] allows a node pool to be created before it is deleted so that any issues with node pool creation
and/or provisioning are discovered before the node pool is removed. This feature is controlled by the
variable node_pools_create_before_destroy. In order to avoid node pool name collisions,
a 4 character alphanumeric is added as a suffix to the name.
The benefit is that you always have some node pools active.
We don't actually cordon/drain the traffic beyond what the GKE API itself will do,
but we do make sure the new node pool is created before the old one is destroyed.
The implications of this are that:
- We append a random ID on the node pool names (since you can't have two simultaneously active node pools)
- For a brief period, you'll have 2x as many resources/node pools
- You will indeed need sufficient IP space (and compute capacity) to create both node pools
Compatibility
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.14+.
If you find incompatibilities using Terraform >=1.3, please open an issue.
If you haven't upgraded to 1.3 and need a Terraform
0.13.x-compatible version of this module, the last released version
intended for Terraform 0.13.x is 27.0.0.
If you haven't upgraded to 0.13 and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is 12.3.0.
Usage
There are multiple examples included in the examples folder but simple usage is as follows:
/* Detailed source-code truncated for AI context efficiency. */Then perform the following commands on the root folder:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| add_cluster_firewall_rules | Create additional firewall rules | bool |
false |
no |
| 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 |
| additional_ip_range_pods | List of names of the additional secondary subnet ip ranges to use for pods | list(string) |
[] |
no |
| additional_ip_ranges_config | the configuration for individual additional subnetworks attached to the cluster | list(object({ subnetwork = string, pod_ipv4_range_names = list(string) })) |
[] |
no |
| additive_vpc_scope_dns_domain | This will enable Cloud DNS additive VPC scope. Must provide a domain name that is unique within the VPC. For this to work cluster_dns = CLOUD_DNS and cluster_dns_scope = CLUSTER_SCOPE must both be set as well. |
string |
"" |
no |
| agent_sandbox_enabled | The status of the Agent Sandbox addon, which isolates untrusted code execution (requires GKE version 1.35.2-gke.1269000 or later and a gVisor-enabled node pool) | bool |
null |
no |
| anonymous_authentication_config_mode | Allows users to restrict or enable anonymous access to the cluster. Valid values are ENABLED and LIMITED. |
string |
null |
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 [email protected] | string |
null |
no |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool, if not overridden in node_pools. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. For more information about protecting resources with Cloud KMS Keys please see: https://cloud.google.com/compute/docs/disks/customer-managed-encryption |
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 | object({ enabled = bool autoscaling_profile = string min_cpu_cores = optional(number) max_cpu_cores = optional(number) min_memory_gb = optional(number) max_memory_gb = optional(number) gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number })) auto_repair = bool auto_upgrade = bool disk_size = optional(number) disk_type = optional(string) image_type = optional(string) strategy = optional(string) max_surge = optional(number) max_unavailable = optional(number) node_pool_soak_duration = optional(string) batch_soak_duration = optional(string) batch_percentage = optional(number) batch_node_count = optional(number) enable_secure_boot = optional(bool, false) enable_integrity_monitoring = optional(bool, true) enable_default_compute_class = optional(bool, false) }) | { "auto_repair": true, "auto_upgrade": true, "autoscaling_profile": "BALANCED", "disk_size": 100, "disk_type": "pd-standard", "enable_default_compute_class": false, "enable_integrity_monitoring": true, "enable_secure_boot": false, "enabled": false, "gpu_resources": [], "image_type": "COS_CONTAINERD", "max_cpu_cores": 0, "max_memory_gb": 0, "min_cpu_cores": 0, "min_memory_gb": 0} | 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 |
| cluster_ipv4_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string |
null |
no |
| cluster_resource_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) |
{} |
no |
| cluster_telemetry_type | Available options include ENABLED, DISABLED, and SYSTEM_ONLY | string |
null |
no |
| config_connector | Whether ConfigConnector is enabled for this cluster. | bool |
false |
no |
| configure_ip_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | bool |
false |
no |
| create_service_account | Defines if service account specified to run nodes should be created. | bool |
true |
no |
| database_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | list(object({ state = string, key_name = string })) |
[ { "key_name": "", "state": "DECRYPTED" }] | no |
| datapath_provider | 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. |
string |
"DATAPATH_PROVIDER_UNSPECIFIED" |
no |
| default_max_pods_per_node | The maximum number of pods to schedule per node | number |
110 |
no |
| deletion_protection | Whether or not to allow Terraform to destroy the cluster. | bool |
true |
no |
| description | The description of the cluster | string |
"" |
no |
| disable_default_snat | Whether to disable the default SNAT to support the private use of public IP addresses | bool |
false |
no |
| disable_l4_lb_firewall_reconciliation | Disable L4 Load Balancer firewall reconciliation | bool |
null |
no |
| disable_legacy_metadata_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | bool |
true |
no |
| dns_allow_external_traffic | (Optional) Controls whether external traffic is allowed over the dns endpoint. | bool |
null |
no |
| dns_cache | The status of the NodeLocal DNSCache addon. | bool |
false |
no |
| dns_enable_k8s_tokens_via_dns | (Optional) Controls whether Kubernetes ServiceAccount token authentication is allowed via the DNS endpoint. | bool |
null |
no |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| enable_cilium_clusterwide_network_policy | Enable Cilium Cluster Wide Network Policies on the cluster | bool |
false |
no |
| enable_confidential_nodes | An optional flag to enable confidential node config. | bool |
false |
no |
| enable_cost_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | bool |
false |
no |
| enable_default_node_pools_metadata | Whether to enable the default node pools metadata key-value pairs such as cluster_name and node_pool |
bool |
true |
no |
| enable_fqdn_network_policy | Enable FQDN Network Policies on the cluster | bool |
null |
no |
| enable_gcfs | Enable image streaming on cluster level. | bool |
false |
no |
| enable_identity_service | (Optional) Enable the Identity Service component, which allows customers to use external identity providers with the K8S API. NOTE: Starting on July 1, 2025, new Google Cloud organizations that you create won't support Identity Service for GKE. | bool |
false |
no |
| enable_intranode_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | bool |
false |
no |
| enable_k8s_beta_apis | (Optional) - List of Kubernetes Beta APIs to enable in cluster. | list(string) |
[] |
no |
| enable_kubernetes_alpha | Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days. | bool |
false |
no |
| enable_l4_ilb_subsetting | Enable L4 ILB Subsetting on the cluster | bool |
false |
no |
| enable_legacy_lustre_port | Set it to true for GKE cluster runs a version earlier than 1.33.2-gke.4780000. Allows the Lustre CSI driver to initialize LNet (the virtual network layer for Lustre kernel module) using port 6988. This flag is required to workaround a port conflict with the gke-metadata-server on GKE nodes | bool |
false |
no |
| enable_managed_machine_learning_diagnostics | (beta) Enable Managed Machine Learning Diagnostics on the cluster. | bool |
null |
no |
| enable_mesh_certificates | Controls the issuance of workload mTLS certificates. When enabled the GKE Workload Identity Certificates controller and node agent will be deployed in the cluster. Requires Workload Identity. | bool |
false |
no |
| enable_multi_networking | Whether multi-networking is enabled for this cluster | bool |
null |
no |
| enable_network_egress_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | bool |
false |
no |
| enable_pod_security_policy | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. Pod Security Policy was removed from GKE clusters with version >= 1.25.0. | bool |
false |
no |
| enable_resource_consumption_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | bool |
true |
no |
| enable_secret_manager_addon | Enable the Secret Manager add-on for this cluster | bool |
false |
no |
| enable_secret_sync | Enable the Secret Sync add-on for this cluster. | bool |
false |
no |
| enable_shielded_nodes | Enable Shielded Nodes features on all nodes in this cluster | bool |
true |
no |
| enable_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| enable_vertical_pod_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool |
false |
no |
| enterprise_config | (Optional) Enable or disable GKE enterprise. Valid values are STANDARD and ENTERPRISE. | string |
null |
no |
| filestore_csi_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | bool |
false |
no |
| firewall_inbound_ports | List of TCP ports for admission/webhook controllers. Either flag add_master_webhook_firewall_rules or add_cluster_firewall_rules (also adds egress rules) must be set to true for inbound-ports firewall rules to be applied. |
list(string) |
[ "8443", "9443", "15017"] | no |
| firewall_priority | Priority rule for firewall rules | number |
1000 |
no |
| fleet_project | (Optional) Register the cluster with the fleet in this project. | string |
null |
no |
| fleet_project_grant_service_agent | (Optional) Grant the fleet project service identity the roles/gkehub.serviceAgent and roles/gkehub.crossProjectServiceAgent roles. |
bool |
false |
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 |
| gcp_public_cidrs_access_enabled | Allow access through Google Cloud public IP addresses | bool |
null |
no |
| gcs_fuse_csi_driver | Whether GCE FUSE CSI driver is enabled for this cluster. | bool |
false |
no |
| gke_auto_upgrade_config_patch_mode | The selected auto-upgrade patch type. Accepted values are: ACCELERATED: Upgrades to the latest available patch version in a given minor and release channel. |
string |
null |
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 |
| hpa_profile | Enable the Horizontal Pod Autoscaling profile for this cluster. Values are "NONE" and "PERFORMANCE". | string |
"" |
no |
| http_load_balancing | Enable httpload balancer addon | bool |
true |
no |
| identity_namespace | The workload pool to attach all Kubernetes service accounts to. (Default value of enabled automatically sets project-based pool [project_id].svc.id.goog) |
string |
"enabled" |
no |
| in_transit_encryption_config | Defines the config of in-transit encryption. Valid values are IN_TRANSIT_ENCRYPTION_DISABLED and IN_TRANSIT_ENCRYPTION_INTER_NODE_TRANSPARENT. |
string |
null |
no |
| initial_node_count | The number of nodes to create in this cluster's default node pool. | number |
0 |
no |
| insecure_kubelet_readonly_port_enabled | Whether or not to set insecure_kubelet_readonly_port_enabled for node pool defaults and autopilot clusters. Note: this can be set at the node pool level separately within node_pools. |
bool |
null |
no |
| ip_endpoints_enabled | (Optional) Controls whether to allow direct IP access. Defaults to true. |
bool |
null |
no |
| ip_masq_link_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | bool |
false |
no |
| ip_masq_resync_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string |
"60s" |
no |
| ip_range_pods | The name of the secondary subnet ip range to use for pods | string |
n/a | yes |
| ip_range_services | The name of the secondary subnet range to use for services. If not provided, the default 34.118.224.0/20 range will be used. |
string |
null |
no |
| issue_client_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| kubernetes_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string |
"latest" |
no |
| logging_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, KCP_CONNECTION, KCP_SSHD, KCP_HPA, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration. | list(string) |
[] |
no |
| logging_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string |
"logging.googleapis.com/kubernetes" |
no |
| logging_variant | (Optional) The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | string |
null |
no |
| lustre_csi_driver | The status of the Lustre CSI driver addon, which allows the usage of a Lustre instances as volumes | bool |
null |
no |
| maintenance_end_time | Time window specified for recurring maintenance operations in RFC3339 format | string |
"" |
no |
| maintenance_exclusions | List of maintenance exclusions. A cluster can have up to three | list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string })) |
[] |
no |
| maintenance_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string |
"" |
no |
| maintenance_start_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string |
"05:00" |
no |
| master_authorized_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | list(object({ cidr_block = string, display_name = string })) |
[] |
no |
| monitoring_auto_monitoring_config_scope | Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE | string |
"NONE" |
no |
| monitoring_enable_managed_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | bool |
null |
no |
| monitoring_enable_observability_metrics | Whether or not the advanced datapath metrics are enabled. | bool |
false |
no |
| monitoring_enable_observability_relay | Whether or not the advanced datapath relay is enabled. | bool |
false |
no |
| monitoring_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR, DCGM, and JOBSET. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. JOBSET is only supported in GKE 1.32.1-gke.1357001 and above. Empty list is default GKE configuration. | list(string) |
[] |
no |
| monitoring_metric_writer_role | The monitoring metrics writer role to assign to the GKE node service account | string |
"roles/monitoring.metricWriter" |
no |
| monitoring_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string |
"monitoring.googleapis.com/kubernetes" |
no |
| name | The name of the cluster (required) | string |
n/a | yes |
| network | The VPC network to host the cluster in (required) | string |
n/a | yes |
| network_policy | Enable network policy addon | bool |
false |
no |
| network_policy_provider | The network policy provider. | string |
"CALICO" |
no |
| network_project_id | The project ID of the shared VPC's host (for shared vpc support) | string |
"" |
no |
| network_tags | (Optional) - List of network tags applied to autopilot and auto-provisioned node pools. | list(string) |
[] |
no |
| network_tier_config | Network tier configuration for the cluster | string |
null |
no |
| node_metadata | Specifies how node metadata is exposed to the workload running on the node | string |
"GKE_METADATA" |
no |
| node_pools | List of maps containing node pools | list(map(any)) |
[ { "name": "default-node-pool" }] | no |
| node_pools_cgroup_mode | Map of strings containing cgroup node config by node-pool name. Note: GKE is removing cgroup v1 support in 1.35. | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_1g | Map of strings containing hugepage size 1g config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_2m | Map of strings containing hugepage size 2m node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_labels | Map of maps containing node labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_linux_node_configs_sysctls | Map of maps containing linux node config sysctls by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_oauth_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) |
{ "all": [ "https://www.googleapis.com/auth/cloud-platform" ], "default-node-pool": []} | no |
| node_pools_resource_labels | Map of maps containing resource labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_resource_manager_tags | Map of maps containing resource manager tags by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_tags | Map of lists containing node network tags by node-pool name | map(list(string)) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_taints | Map of lists containing node taints by node-pool name | map(list(object({ key = string, value = string, effect = string }))) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_transparent_hugepage_defrag | Map of strings containing transparent hugepage defrag node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_transparent_hugepage_enabled | Map of strings containing transparent hugepage enabled node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| non_masquerade_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) |
[ "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"] | no |
| notification_config_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | string |
"" |
no |
| notification_filter_event_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT. | list(string) |
[] |
no |
| parallelstore_csi_driver | Whether the Parallelstore CSI driver Addon is enabled for this cluster. | bool |
null |
no |
| project_id | The project ID to host the cluster in (required) | string |
n/a | yes |
| ray_operator_config | The Ray Operator Addon configuration for this cluster. | object({ enabled = bool logging_enabled = optional(bool, false) monitoring_enabled = optional(bool, false) }) | { "enabled": false, "logging_enabled": false, "monitoring_enabled": false} | no |
| rbac_binding_config | RBACBindingConfig allows user to restrict ClusterRoleBindings an RoleBindings that can be created. | object({ enable_insecure_binding_system_unauthenticated = optional(bool, null) enable_insecure_binding_system_authenticated = optional(bool, null) }) | { "enable_insecure_binding_system_authenticated": null, "enable_insecure_binding_system_unauthenticated": null} | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string |
null |
no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool |
true |
no |
| registry_project_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the grant_registry_access variable is set to true, the storage.objectViewer and artifactregsitry.reader roles are assigned on these projects. |
list(string) |
[] |
no |
| release_channel | The release channel of this cluster. Accepted values are UNSPECIFIED, RAPID, REGULAR and STABLE. Defaults to REGULAR. |
string |
"REGULAR" |
no |
| remove_default_node_pool | Remove default node pool while setting up the cluster | bool |
false |
no |
| resource_manager_tags | (Optional) - List of resource manager tags applied to autopilot and auto-provisioned node pools. A maximum of 5 tags can be specified. Tags must be in one of these formats: "tagKeys/{tag_key_id}"="tagValues/{tag_value_id}", "{org_id}/{tag_key_name}"="{tag_value_name}", "{project_id}/{tag_key_name}"="{tag_value_name}". | map(string) |
{} |
no |
| 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 |
| security_posture_mode | Security posture mode. Accepted values are DISABLED and BASIC. Defaults to DISABLED. |
string |
"DISABLED" |
no |
| security_posture_vulnerability_mode | Security posture vulnerability mode. Accepted values are VULNERABILITY_DISABLED, VULNERABILITY_BASIC, and VULNERABILITY_ENTERPRISE. Defaults to VULNERABILITY_DISABLED. |
string |
"VULNERABILITY_DISABLED" |
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. This service account should already exists and it will be used by the node pools. If you wish to only override the service account name, you can use service_account_name variable. |
string |
"" |
no |
| service_account_name | The name of the service account that will be created if create_service_account is true. If you wish to use an existing service account, use service_account variable. | string |
"" |
no |
| service_external_ips | Whether external ips specified by a service will be allowed in this cluster | bool |
false |
no |
| shadow_firewall_rules_log_config | The log_config for shadow firewall rules. You can set this variable to null to disable logging. |
object({ metadata = string }) | { "metadata": "INCLUDE_ALL_METADATA"} | 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 |
| stack_type | The stack type to use for this cluster. Either IPV4 or IPV4_IPV6. Defaults to IPV4. |
string |
"IPV4" |
no |
| stateful_ha | Whether the Stateful HA Addon is enabled for this cluster. | 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 |
| subnetwork | The subnetwork to host the cluster in (required) | string |
n/a | yes |
| timeouts | Timeout for cluster operations. | map(string) |
{} |
no |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier for NodePools in the cluster. Valid values are TIER_UNSPECIFIED and TIER_1. Defaults to TIER_UNSPECIFIED. |
string |
null |
no |
| upstream_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list(string) |
[] |
no |
| user_managed_keys_config | The User Managed Keys configuration for the cluster. | object({ aggregation_ca = optional(string) cluster_ca = optional(string) control_plane_disk_encryption_key = optional(string) etcd_api_ca = optional(string) etcd_peer_ca = optional(string) gkeops_etcd_backup_encryption_key = optional(string) service_account_signing_keys = optional(list(string)) service_account_verification_keys = optional(list(string)) }) | null |
no |
| windows_node_pools | List of maps containing Windows node pools | list(map(string)) |
[] |
no |
| workload_config_audit_mode | (beta) Sets which mode of auditing should be used for the cluster's workloads. Accepted values are DISABLED, BASIC. | string |
"DISABLED" |
no |
| workload_vulnerability_mode | (beta) Sets which mode to use for Protect workload vulnerability scanning feature. Accepted values are DISABLED, BASIC. | string |
"" |
no |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cloudrun_enabled | Whether CloudRun enabled |
| cluster_id | Cluster ID |
| dns_cache_enabled | Whether DNS Cache enabled |
| endpoint | Cluster endpoint |
| endpoint_dns | Cluster endpoint DNS |
| fleet_membership | Fleet membership (if registered) |
| gateway_api_channel | The gateway api channel of this cluster. |
| horizontal_pod_autoscaling_enabled | Whether horizontal pod autoscaling enabled |
| http_load_balancing_enabled | Whether http load balancing enabled |
| identity_namespace | Workload Identity pool |
| identity_service_enabled | Whether Identity Service is enabled |
| instance_group_urls | List of GKE generated instance groups |
| intranode_visibility_enabled | Whether intra-node visibility is enabled |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| logging_service | Logging service used |
| master_authorized_networks_config | Networks from which access to master is permitted |
| master_version | Current master kubernetes version |
| mesh_certificates_config | Mesh certificates configuration |
| min_master_version | Minimum master kubernetes version |
| monitoring_service | Monitoring service used |
| name | Cluster name |
| network_policy_enabled | Whether network policy enabled |
| node_pools_names | List of node pools names |
| node_pools_versions | Node pool versions by node pool name |
| pod_security_policy_enabled | Whether pod security policy is enabled |
| region | Cluster region |
| release_channel | The release channel of this cluster |
| secret_manager_addon_enabled | Whether Secret Manager add-on is enabled |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| tpu_ipv4_cidr_block | The IP range in CIDR notation used for the TPUs |
| type | Cluster type (regional / zonal) |
| vertical_pod_autoscaling_enabled | Whether vertical pod autoscaling enabled |
| zones | List of zones in which the cluster resides |
node_pools variable
Use this variable for provisioning linux based node pools. For Windows based node pools use windows_node_pools
The node_pools variable takes the following parameters:
| Name | Description | Default | Requirement |
|---|---|---|---|
| accelerator_count | The number of the guest accelerator cards exposed to this instance | 0 | Optional |
| accelerator_type | The accelerator type resource to expose to the instance | " " | Optional |
| auto_repair | Whether the nodes will be automatically repaired | true | Optional |
| autoscaling | Configuration required by cluster autoscaler to adjust the size of the node pool to the current cluster usage | true | Optional |
| auto_upgrade | Whether the nodes will be automatically upgraded | true (if cluster is regional) | Optional |
| storage_pools | The list of Storage Pools where boot disks are provisioned. | Optional | |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. | " " | Optional |
| cpu_manager_policy | The CPU manager policy on the node. One of "none" or "static". | "static" | Optional |
| cpu_cfs_quota | Enforces the Pod's CPU limit. Setting this value to false means that the CPU limits for Pods are ignored | null | Optional |
| cpu_cfs_quota_period | The CPU CFS quota period value, which specifies the period of how often a cgroup's access to CPU resources should be reallocated | null | Optional |
| pod_pids_limit | Controls the maximum number of processes allowed to run in a pod. The value must be greater than or equal to 1024 and less than 4194304. | null | Optional |
| container_log_max_size | Defines the maximum size of the container log file before it is rotated. | null | Optional |
| container_log_max_files | Defines the maximum number of container log files that can be present for a container. | null | Optional |
| image_gc_low_threshold_percent | Defines the percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to. | null | Optional |
| image_gc_high_threshold_percent | Defines the percent of disk usage after which image garbage collection is always run. | null | Optional |
| image_minimum_gc_age | Defines the minimum age for an unused image before it is garbage collected. | null | Optional |
| image_maximum_gc_age | Defines the maximum age an image can be unused before it is garbage collected. | null | Optional |
| allowed_unsafe_sysctls | Defines a comma-separated allowlist of unsafe sysctls or sysctl patterns which can be set on the Pods. This should be passed as comma separated string. | null | Optional |
| enable_confidential_nodes | An optional flag to enable confidential node config. | false | Optional |
| disk_size_gb | Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB | 100 | Optional |
| disk_type | Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') | pd-standard | Optional |
| provisioned_iops | Indicates how many IOPS to provision for the disk. This sets the number of I/O operations per second that the disk can handle. For more details, see the Hyperdisk documentation. | null | Optional |
| provisioned_throughput | Indicates how much throughput to provision for the disk, in MB/s. This sets the amount of data that can be read or written to the disk per second. For more details, see the Hyperdisk documentation. | null | Optional |
| effect | Effect for the taint | Required | |
| enable_fast_socket | Enable the NCCL Fast Socket feature. enable_gvnic must also be enabled. |
null | Optional |
| enable_gcfs | Google Container File System (gcfs) has to be enabled for image streaming to be active. Needs image_type to be set to COS_CONTAINERD. | false | Optional |
| enable_gvnic | gVNIC (GVE) is an alternative to the virtIO-based ethernet driver. Needs a Container-Optimized OS node image. | false | Optional |
| enable_integrity_monitoring | Enables monitoring and attestation of the boot integrity of the instance. The attestation is performed against the integrity policy baseline. This baseline is initially derived from the implicitly trusted boot image when the instance is created. | true | Optional |
| enable_secure_boot | Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. | false | Optional |
| gpu_driver_version | Mode for how the GPU driver is installed | null | Optional |
| gpu_partition_size | Size of partitions to create on the GPU | null | Optional |
| image_type | The image type to use for this node. Note that changing the image type will delete and recreate all nodes in the node pool | COS_CONTAINERD | Optional |
| initial_node_count | The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. Changing this will force recreation of the resource. Defaults to the value of min_count | " " | Optional |
| insecure_kubelet_readonly_port_enabled | (boolean) Whether or not to enable the insecure Kubelet readonly port. | null | Optional |
| single_process_oom_kill | (boolean) On cgroupv2 nodes, defines whether processes in the container are OOM killed individually (true) or as a group (false, the kubelet default). Leave null to keep the kubelet default. | null | Optional |
| key | The key required for the taint | Required | |
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a hostpath volume or a local PersistentVolume. |
0 | Optional |
| local_ssd_ephemeral_storage_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| ephemeral_storage_local_ssd_data_cache_count | Number of raw-block local NVMe SSD disks to be attached to the node utilized for GKE Data Cache. | 0 | Optional |
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| local_nvme_ssd_count | Number of raw-block local NVMe SSD disks to be attached to the node.Each local SSD is 375 GB in size. If zero, it means no raw-block local NVMe SSD disks to be attached to the node. | 0 | Optional |
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
| enable_confidential_storage | Enabling Confidential Storage will create boot disk with confidential mode. | false | Optional |
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
| strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: SURGE, BLUE_GREEN, or for flex-start and queued provisioning SHORT_LIVED |
"SURGE" | Optional |
| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional |
| enable_nested_virtualization | Whether the node should have nested virtualization | null | Optional |
| performance_monitoring_unit | Level of Performance Monitoring Unit (PMU) requested. If unset, no access to the PMU is assumed. Values values are: ARCHITECTURAL, STANDARD, and ENHANCED |
null | Optional |
| max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with SURGE strategy. |
1 | Optional |
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with SURGE strategy. |
0 | Optional |
| node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with BLUE_GREEN strategy. |
"3600s" | Optional |
| batch_soak_duration | Soak time after each batch gets drained, with the default being zero seconds. Only works with BLUE_GREEN strategy. |
"0s" | Optional |
| batch_node_count | Absolute number of nodes to drain in a batch. If it is set to zero, this phase will be skipped. Cannot be used together with batch_percentage. Only works with BLUE_GREEN strategy. |
1 | Optional |
| batch_percentage | Percentage of nodes to drain in a batch. Must be in the range of [0.0, 1.0]. If it is set to zero, this phase will be skipped. Cannot be used together with batch_node_count. Only works with BLUE_GREEN strategy. |
null | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
| name | The name of the node pool | Required | |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as COMPACT if desired | Optional | |
| policy_name | If set, refers to the name of a custom resource policy supplied by the user. The resource policy must be in the same project and region as the node pool. | Optional | |
| tpu_topology | TPU placement topology for pod slice node pool. For detail see documentation | Optional | |
| pod_range | The name of the secondary range for pod IPs. | Optional | |
| enable_private_nodes | Whether nodes have internal IP addresses only. | Optional | |
| node_affinity | The node affinty in the format "{\"key\": \"compute.googleapis.com/node-group-name\", \"operator\": \"IN\", \"values\": [\"node-group-name\"]}". |
Optional | |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | Required | |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
| node_metadata | Options to expose the node metadata to the workload running on the node | Optional | |
| preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional |
| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional |
| sandbox_type | Sandbox to use for pods in the node pool | Required | |
| service_account | The service account to be used by the Node VMs | " " | Optional |
| tags | The list of instance tags applied to all nodes | Required | |
| value | The value for the taint | Required | |
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
| location_policy | Location policy specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see documentation. gcfs_config must be enabled=true for this feature to work. |
Optional | |
| secondary_boot_disk_mode | Mode for the secondary boot disk. Defaults to CONTAINER_IMAGE_CACHE (preloads container images, requires gcfs_config enabled). Set to null to omit the field for data preloading (mounts data onto nodes for use via hostPath). |
"CONTAINER_IMAGE_CACHE" |
Optional |
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | Optional | |
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | Optional | |
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | Optional | |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier. Valid values are: "TIER_1" and "TIER_UNSPECIFIED". | Optional | |
| pod_cidr_overprovision_disabled | Disables GKE's default doubling of the per-node pod IP range allocation when set to true. |
Optional | |
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | Optional | |
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | Optional | |
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | Optional | |
| local_ssd_encryption_mode | specifies the method used for encrypting the local SSDs attached to the node. Valid values are: "STANDARD_ENCRYPTION" and "EPHEMERAL_KEY_ENCRYPTION" | Optional | |
| max_run_duration | The runtime of each node in the node pool in seconds, terminated by 's'. Example: "3600s". | null | Optional |
| flex_start | Enables Flex Start provisioning model for the node pool | null | Optional |
| respect_pdb_during_node_pool_deletion | Whether to respect Pod Disruption Budgets during node pool deletion. | null | Optional |
windows_node_pools variable
The windows_node_pools variable takes the same parameters as node_pools but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a specific requirement for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.
| Name | Description | Default | Requirement |
|---|---|---|---|
| windows_node_config_os_version | The Windows OS version to use for the windows node pool. Valid values are OS_VERSION_UNSPECIFIED, OS_VERSION_LTSC2019 and OS_VERSION_LTSC2022. | null | Optional |
Requirements
Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:
- Terraform and kubectl are installed on the machine where Terraform is executed.
- The Service Account you execute the module with has the right permissions.
- The Compute Engine and Kubernetes Engine APIs are active on the project you will launch the cluster in.
- If you are using a Shared VPC, the APIs must also be activated on the Shared VPC host project and your service account needs the proper permissions there.
The project factory can be used to provision projects with the correct APIs active and the necessary Shared VPC connections.
Software Dependencies
Kubectl
- kubectl 1.9.x
Terraform and Plugins
- Terraform 1.3+
- Terraform Provider for GCP Beta v7.39+
gcloud
Some submodules use the terraform-google-gcloud module. By default, this module assumes you already have gcloud installed in your $PATH.
See the module documentation for more information.
Configure a Service Account
In order to execute this module you must have a Service Account with the
following project roles:
- roles/compute.viewer
- roles/compute.securityAdmin (only required if
add_cluster_firewall_rulesis set totrue) - roles/container.clusterAdmin
- roles/container.developer
- roles/iam.serviceAccountAdmin
- roles/iam.serviceAccountUser
- roles/resourcemanager.projectIamAdmin (only required if
service_accountis set tocreate)
Additionally, if service_account is set to create and grant_registry_access is requested, the service account requires the following role on the registry_project_ids projects:
- roles/resourcemanager.projectIamAdmin
Enable APIs
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
- Compute Engine API - compute.googleapis.com
- Kubernetes Engine API - container.googleapis.com
Overview (`modules/beta-public-cluster/README.md`)
Terraform Kubernetes Engine Module
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, IP MASQ, Network Policy, etc.Beta features are enabled in this submodule.
The resources/services/activations/deletions that this module will create/trigger are:
- Create a GKE cluster with the provided addons
- Create GKE Node Pool(s) with provided configuration and attach to cluster
- Replace the default kube-dns configmap if
stub_domainsare provided - Activate network policy if
network_policyis true - Add
ip-masq-agentconfigmap with providednon_masquerade_cidrsifconfigure_ip_masqis true
Sub modules are provided for creating private clusters, beta private clusters, and beta public clusters as well. Beta sub modules allow for the use of various GKE beta features. See the modules directory for the various sub modules.
Compatibility
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.14+.
If you find incompatibilities using Terraform >=1.3, please open an issue.
If you haven't upgraded to 1.3 and need a Terraform
0.13.x-compatible version of this module, the last released version
intended for Terraform 0.13.x is 27.0.0.
If you haven't upgraded to 0.13 and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is 12.3.0.
Usage
There are multiple examples included in the examples folder but simple usage is as follows:
/* Detailed source-code truncated for AI context efficiency. */Then perform the following commands on the root folder:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| add_cluster_firewall_rules | Create additional firewall rules | bool |
false |
no |
| 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 |
| additional_ip_range_pods | List of names of the additional secondary subnet ip ranges to use for pods | list(string) |
[] |
no |
| additional_ip_ranges_config | the configuration for individual additional subnetworks attached to the cluster | list(object({ subnetwork = string, pod_ipv4_range_names = list(string) })) |
[] |
no |
| additive_vpc_scope_dns_domain | This will enable Cloud DNS additive VPC scope. Must provide a domain name that is unique within the VPC. For this to work cluster_dns = CLOUD_DNS and cluster_dns_scope = CLUSTER_SCOPE must both be set as well. |
string |
"" |
no |
| agent_sandbox_enabled | The status of the Agent Sandbox addon, which isolates untrusted code execution (requires GKE version 1.35.2-gke.1269000 or later and a gVisor-enabled node pool) | bool |
null |
no |
| anonymous_authentication_config_mode | Allows users to restrict or enable anonymous access to the cluster. Valid values are ENABLED and LIMITED. |
string |
null |
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 [email protected] | string |
null |
no |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool, if not overridden in node_pools. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. For more information about protecting resources with Cloud KMS Keys please see: https://cloud.google.com/compute/docs/disks/customer-managed-encryption |
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 | object({ enabled = bool autoscaling_profile = string min_cpu_cores = optional(number) max_cpu_cores = optional(number) min_memory_gb = optional(number) max_memory_gb = optional(number) gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number })) auto_repair = bool auto_upgrade = bool disk_size = optional(number) disk_type = optional(string) image_type = optional(string) strategy = optional(string) max_surge = optional(number) max_unavailable = optional(number) node_pool_soak_duration = optional(string) batch_soak_duration = optional(string) batch_percentage = optional(number) batch_node_count = optional(number) enable_secure_boot = optional(bool, false) enable_integrity_monitoring = optional(bool, true) enable_default_compute_class = optional(bool, false) }) | { "auto_repair": true, "auto_upgrade": true, "autoscaling_profile": "BALANCED", "disk_size": 100, "disk_type": "pd-standard", "enable_default_compute_class": false, "enable_integrity_monitoring": true, "enable_secure_boot": false, "enabled": false, "gpu_resources": [], "image_type": "COS_CONTAINERD", "max_cpu_cores": 0, "max_memory_gb": 0, "min_cpu_cores": 0, "min_memory_gb": 0} | 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 |
| cluster_ipv4_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | string |
null |
no |
| cluster_resource_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | map(string) |
{} |
no |
| cluster_telemetry_type | Available options include ENABLED, DISABLED, and SYSTEM_ONLY | string |
null |
no |
| config_connector | Whether ConfigConnector is enabled for this cluster. | bool |
false |
no |
| configure_ip_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | bool |
false |
no |
| create_service_account | Defines if service account specified to run nodes should be created. | bool |
true |
no |
| database_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | list(object({ state = string, key_name = string })) |
[ { "key_name": "", "state": "DECRYPTED" }] | no |
| datapath_provider | 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. |
string |
"DATAPATH_PROVIDER_UNSPECIFIED" |
no |
| default_max_pods_per_node | The maximum number of pods to schedule per node | number |
110 |
no |
| deletion_protection | Whether or not to allow Terraform to destroy the cluster. | bool |
true |
no |
| description | The description of the cluster | string |
"" |
no |
| disable_default_snat | Whether to disable the default SNAT to support the private use of public IP addresses | bool |
false |
no |
| disable_l4_lb_firewall_reconciliation | Disable L4 Load Balancer firewall reconciliation | bool |
null |
no |
| disable_legacy_metadata_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | bool |
true |
no |
| dns_allow_external_traffic | (Optional) Controls whether external traffic is allowed over the dns endpoint. | bool |
null |
no |
| dns_cache | The status of the NodeLocal DNSCache addon. | bool |
false |
no |
| dns_enable_k8s_tokens_via_dns | (Optional) Controls whether Kubernetes ServiceAccount token authentication is allowed via the DNS endpoint. | bool |
null |
no |
| enable_binary_authorization | Enable BinAuthZ Admission controller | bool |
false |
no |
| enable_cilium_clusterwide_network_policy | Enable Cilium Cluster Wide Network Policies on the cluster | bool |
false |
no |
| enable_confidential_nodes | An optional flag to enable confidential node config. | bool |
false |
no |
| enable_cost_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | bool |
false |
no |
| enable_default_node_pools_metadata | Whether to enable the default node pools metadata key-value pairs such as cluster_name and node_pool |
bool |
true |
no |
| enable_fqdn_network_policy | Enable FQDN Network Policies on the cluster | bool |
null |
no |
| enable_gcfs | Enable image streaming on cluster level. | bool |
false |
no |
| enable_identity_service | (Optional) Enable the Identity Service component, which allows customers to use external identity providers with the K8S API. NOTE: Starting on July 1, 2025, new Google Cloud organizations that you create won't support Identity Service for GKE. | bool |
false |
no |
| enable_intranode_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | bool |
false |
no |
| enable_k8s_beta_apis | (Optional) - List of Kubernetes Beta APIs to enable in cluster. | list(string) |
[] |
no |
| enable_kubernetes_alpha | Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days. | bool |
false |
no |
| enable_l4_ilb_subsetting | Enable L4 ILB Subsetting on the cluster | bool |
false |
no |
| enable_legacy_lustre_port | Set it to true for GKE cluster runs a version earlier than 1.33.2-gke.4780000. Allows the Lustre CSI driver to initialize LNet (the virtual network layer for Lustre kernel module) using port 6988. This flag is required to workaround a port conflict with the gke-metadata-server on GKE nodes | bool |
false |
no |
| enable_managed_machine_learning_diagnostics | (beta) Enable Managed Machine Learning Diagnostics on the cluster. | bool |
null |
no |
| enable_mesh_certificates | Controls the issuance of workload mTLS certificates. When enabled the GKE Workload Identity Certificates controller and node agent will be deployed in the cluster. Requires Workload Identity. | bool |
false |
no |
| enable_multi_networking | Whether multi-networking is enabled for this cluster | bool |
null |
no |
| enable_network_egress_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | bool |
false |
no |
| enable_pod_security_policy | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. Pod Security Policy was removed from GKE clusters with version >= 1.25.0. | bool |
false |
no |
| enable_resource_consumption_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | bool |
true |
no |
| enable_secret_manager_addon | Enable the Secret Manager add-on for this cluster | bool |
false |
no |
| enable_secret_sync | Enable the Secret Sync add-on for this cluster. | bool |
false |
no |
| enable_shielded_nodes | Enable Shielded Nodes features on all nodes in this cluster | bool |
true |
no |
| enable_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| enable_vertical_pod_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool |
false |
no |
| enterprise_config | (Optional) Enable or disable GKE enterprise. Valid values are STANDARD and ENTERPRISE. | string |
null |
no |
| filestore_csi_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | bool |
false |
no |
| firewall_inbound_ports | List of TCP ports for admission/webhook controllers. Either flag add_master_webhook_firewall_rules or add_cluster_firewall_rules (also adds egress rules) must be set to true for inbound-ports firewall rules to be applied. |
list(string) |
[ "8443", "9443", "15017"] | no |
| firewall_priority | Priority rule for firewall rules | number |
1000 |
no |
| fleet_project | (Optional) Register the cluster with the fleet in this project. | string |
null |
no |
| fleet_project_grant_service_agent | (Optional) Grant the fleet project service identity the roles/gkehub.serviceAgent and roles/gkehub.crossProjectServiceAgent roles. |
bool |
false |
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 |
| gcp_public_cidrs_access_enabled | Allow access through Google Cloud public IP addresses | bool |
null |
no |
| gcs_fuse_csi_driver | Whether GCE FUSE CSI driver is enabled for this cluster. | bool |
false |
no |
| gke_auto_upgrade_config_patch_mode | The selected auto-upgrade patch type. Accepted values are: ACCELERATED: Upgrades to the latest available patch version in a given minor and release channel. |
string |
null |
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 |
| hpa_profile | Enable the Horizontal Pod Autoscaling profile for this cluster. Values are "NONE" and "PERFORMANCE". | string |
"" |
no |
| http_load_balancing | Enable httpload balancer addon | bool |
true |
no |
| identity_namespace | The workload pool to attach all Kubernetes service accounts to. (Default value of enabled automatically sets project-based pool [project_id].svc.id.goog) |
string |
"enabled" |
no |
| in_transit_encryption_config | Defines the config of in-transit encryption. Valid values are IN_TRANSIT_ENCRYPTION_DISABLED and IN_TRANSIT_ENCRYPTION_INTER_NODE_TRANSPARENT. |
string |
null |
no |
| initial_node_count | The number of nodes to create in this cluster's default node pool. | number |
0 |
no |
| insecure_kubelet_readonly_port_enabled | Whether or not to set insecure_kubelet_readonly_port_enabled for node pool defaults and autopilot clusters. Note: this can be set at the node pool level separately within node_pools. |
bool |
null |
no |
| ip_endpoints_enabled | (Optional) Controls whether to allow direct IP access. Defaults to true. |
bool |
null |
no |
| ip_masq_link_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | bool |
false |
no |
| ip_masq_resync_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string |
"60s" |
no |
| ip_range_pods | The name of the secondary subnet ip range to use for pods | string |
n/a | yes |
| ip_range_services | The name of the secondary subnet range to use for services. If not provided, the default 34.118.224.0/20 range will be used. |
string |
null |
no |
| issue_client_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | bool |
false |
no |
| kubernetes_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string |
"latest" |
no |
| logging_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, KCP_CONNECTION, KCP_SSHD, KCP_HPA, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration. | list(string) |
[] |
no |
| logging_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string |
"logging.googleapis.com/kubernetes" |
no |
| logging_variant | (Optional) The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | string |
null |
no |
| lustre_csi_driver | The status of the Lustre CSI driver addon, which allows the usage of a Lustre instances as volumes | bool |
null |
no |
| maintenance_end_time | Time window specified for recurring maintenance operations in RFC3339 format | string |
"" |
no |
| maintenance_exclusions | List of maintenance exclusions. A cluster can have up to three | list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string })) |
[] |
no |
| maintenance_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string |
"" |
no |
| maintenance_start_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string |
"05:00" |
no |
| master_authorized_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | list(object({ cidr_block = string, display_name = string })) |
[] |
no |
| monitoring_auto_monitoring_config_scope | Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE | string |
"NONE" |
no |
| monitoring_enable_managed_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | bool |
null |
no |
| monitoring_enable_observability_metrics | Whether or not the advanced datapath metrics are enabled. | bool |
false |
no |
| monitoring_enable_observability_relay | Whether or not the advanced datapath relay is enabled. | bool |
false |
no |
| monitoring_enabled_components | List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR, DCGM, and JOBSET. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. JOBSET is only supported in GKE 1.32.1-gke.1357001 and above. Empty list is default GKE configuration. | list(string) |
[] |
no |
| monitoring_metric_writer_role | The monitoring metrics writer role to assign to the GKE node service account | string |
"roles/monitoring.metricWriter" |
no |
| monitoring_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string |
"monitoring.googleapis.com/kubernetes" |
no |
| name | The name of the cluster (required) | string |
n/a | yes |
| network | The VPC network to host the cluster in (required) | string |
n/a | yes |
| network_policy | Enable network policy addon | bool |
false |
no |
| network_policy_provider | The network policy provider. | string |
"CALICO" |
no |
| network_project_id | The project ID of the shared VPC's host (for shared vpc support) | string |
"" |
no |
| network_tags | (Optional) - List of network tags applied to autopilot and auto-provisioned node pools. | list(string) |
[] |
no |
| network_tier_config | Network tier configuration for the cluster | string |
null |
no |
| node_metadata | Specifies how node metadata is exposed to the workload running on the node | string |
"GKE_METADATA" |
no |
| node_pools | List of maps containing node pools | list(map(any)) |
[ { "name": "default-node-pool" }] | no |
| node_pools_cgroup_mode | Map of strings containing cgroup node config by node-pool name. Note: GKE is removing cgroup v1 support in 1.35. | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_1g | Map of strings containing hugepage size 1g config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_hugepage_size_2m | Map of strings containing hugepage size 2m node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_labels | Map of maps containing node labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_linux_node_configs_sysctls | Map of maps containing linux node config sysctls by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_metadata | Map of maps containing node metadata by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_oauth_scopes | Map of lists containing node oauth scopes by node-pool name | map(list(string)) |
{ "all": [ "https://www.googleapis.com/auth/cloud-platform" ], "default-node-pool": []} | no |
| node_pools_resource_labels | Map of maps containing resource labels by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_resource_manager_tags | Map of maps containing resource manager tags by node-pool name | map(map(string)) |
{ "all": {}, "default-node-pool": {}} | no |
| node_pools_tags | Map of lists containing node network tags by node-pool name | map(list(string)) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_taints | Map of lists containing node taints by node-pool name | map(list(object({ key = string, value = string, effect = string }))) |
{ "all": [], "default-node-pool": []} | no |
| node_pools_transparent_hugepage_defrag | Map of strings containing transparent hugepage defrag node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| node_pools_transparent_hugepage_enabled | Map of strings containing transparent hugepage enabled node config by node-pool name | map(string) |
{ "all": "", "default-node-pool": ""} | no |
| non_masquerade_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list(string) |
[ "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"] | no |
| notification_config_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | string |
"" |
no |
| notification_filter_event_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE_AVAILABLE_EVENT, UPGRADE_EVENT, and SECURITY_BULLETIN_EVENT. | list(string) |
[] |
no |
| parallelstore_csi_driver | Whether the Parallelstore CSI driver Addon is enabled for this cluster. | bool |
null |
no |
| project_id | The project ID to host the cluster in (required) | string |
n/a | yes |
| ray_operator_config | The Ray Operator Addon configuration for this cluster. | object({ enabled = bool logging_enabled = optional(bool, false) monitoring_enabled = optional(bool, false) }) | { "enabled": false, "logging_enabled": false, "monitoring_enabled": false} | no |
| rbac_binding_config | RBACBindingConfig allows user to restrict ClusterRoleBindings an RoleBindings that can be created. | object({ enable_insecure_binding_system_unauthenticated = optional(bool, null) enable_insecure_binding_system_authenticated = optional(bool, null) }) | { "enable_insecure_binding_system_authenticated": null, "enable_insecure_binding_system_unauthenticated": null} | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | string |
null |
no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool |
true |
no |
| registry_project_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the grant_registry_access variable is set to true, the storage.objectViewer and artifactregsitry.reader roles are assigned on these projects. |
list(string) |
[] |
no |
| release_channel | The release channel of this cluster. Accepted values are UNSPECIFIED, RAPID, REGULAR and STABLE. Defaults to REGULAR. |
string |
"REGULAR" |
no |
| remove_default_node_pool | Remove default node pool while setting up the cluster | bool |
false |
no |
| resource_manager_tags | (Optional) - List of resource manager tags applied to autopilot and auto-provisioned node pools. A maximum of 5 tags can be specified. Tags must be in one of these formats: "tagKeys/{tag_key_id}"="tagValues/{tag_value_id}", "{org_id}/{tag_key_name}"="{tag_value_name}", "{project_id}/{tag_key_name}"="{tag_value_name}". | map(string) |
{} |
no |
| 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 |
| security_posture_mode | Security posture mode. Accepted values are DISABLED and BASIC. Defaults to DISABLED. |
string |
"DISABLED" |
no |
| security_posture_vulnerability_mode | Security posture vulnerability mode. Accepted values are VULNERABILITY_DISABLED, VULNERABILITY_BASIC, and VULNERABILITY_ENTERPRISE. Defaults to VULNERABILITY_DISABLED. |
string |
"VULNERABILITY_DISABLED" |
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. This service account should already exists and it will be used by the node pools. If you wish to only override the service account name, you can use service_account_name variable. |
string |
"" |
no |
| service_account_name | The name of the service account that will be created if create_service_account is true. If you wish to use an existing service account, use service_account variable. | string |
"" |
no |
| service_external_ips | Whether external ips specified by a service will be allowed in this cluster | bool |
false |
no |
| shadow_firewall_rules_log_config | The log_config for shadow firewall rules. You can set this variable to null to disable logging. |
object({ metadata = string }) | { "metadata": "INCLUDE_ALL_METADATA"} | 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 |
| stack_type | The stack type to use for this cluster. Either IPV4 or IPV4_IPV6. Defaults to IPV4. |
string |
"IPV4" |
no |
| stateful_ha | Whether the Stateful HA Addon is enabled for this cluster. | 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 |
| subnetwork | The subnetwork to host the cluster in (required) | string |
n/a | yes |
| timeouts | Timeout for cluster operations. | map(string) |
{} |
no |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier for NodePools in the cluster. Valid values are TIER_UNSPECIFIED and TIER_1. Defaults to TIER_UNSPECIFIED. |
string |
null |
no |
| upstream_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list(string) |
[] |
no |
| user_managed_keys_config | The User Managed Keys configuration for the cluster. | object({ aggregation_ca = optional(string) cluster_ca = optional(string) control_plane_disk_encryption_key = optional(string) etcd_api_ca = optional(string) etcd_peer_ca = optional(string) gkeops_etcd_backup_encryption_key = optional(string) service_account_signing_keys = optional(list(string)) service_account_verification_keys = optional(list(string)) }) | null |
no |
| windows_node_pools | List of maps containing Windows node pools | list(map(string)) |
[] |
no |
| workload_config_audit_mode | (beta) Sets which mode of auditing should be used for the cluster's workloads. Accepted values are DISABLED, BASIC. | string |
"DISABLED" |
no |
| workload_vulnerability_mode | (beta) Sets which mode to use for Protect workload vulnerability scanning feature. Accepted values are DISABLED, BASIC. | string |
"" |
no |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cloudrun_enabled | Whether CloudRun enabled |
| cluster_id | Cluster ID |
| dns_cache_enabled | Whether DNS Cache enabled |
| endpoint | Cluster endpoint |
| endpoint_dns | Cluster endpoint DNS |
| fleet_membership | Fleet membership (if registered) |
| gateway_api_channel | The gateway api channel of this cluster. |
| horizontal_pod_autoscaling_enabled | Whether horizontal pod autoscaling enabled |
| http_load_balancing_enabled | Whether http load balancing enabled |
| identity_namespace | Workload Identity pool |
| identity_service_enabled | Whether Identity Service is enabled |
| instance_group_urls | List of GKE generated instance groups |
| intranode_visibility_enabled | Whether intra-node visibility is enabled |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| logging_service | Logging service used |
| master_authorized_networks_config | Networks from which access to master is permitted |
| master_version | Current master kubernetes version |
| mesh_certificates_config | Mesh certificates configuration |
| min_master_version | Minimum master kubernetes version |
| monitoring_service | Monitoring service used |
| name | Cluster name |
| network_policy_enabled | Whether network policy enabled |
| node_pools_names | List of node pools names |
| node_pools_versions | Node pool versions by node pool name |
| pod_security_policy_enabled | Whether pod security policy is enabled |
| region | Cluster region |
| release_channel | The release channel of this cluster |
| secret_manager_addon_enabled | Whether Secret Manager add-on is enabled |
| service_account | The service account to default running nodes as if not overridden in node_pools. |
| tpu_ipv4_cidr_block | The IP range in CIDR notation used for the TPUs |
| type | Cluster type (regional / zonal) |
| vertical_pod_autoscaling_enabled | Whether vertical pod autoscaling enabled |
| zones | List of zones in which the cluster resides |
node_pools variable
Use this variable for provisioning linux based node pools. For Windows based node pools use windows_node_pools
The node_pools variable takes the following parameters:
| Name | Description | Default | Requirement |
|---|---|---|---|
| accelerator_count | The number of the guest accelerator cards exposed to this instance | 0 | Optional |
| accelerator_type | The accelerator type resource to expose to the instance | " " | Optional |
| auto_repair | Whether the nodes will be automatically repaired | true | Optional |
| autoscaling | Configuration required by cluster autoscaler to adjust the size of the node pool to the current cluster usage | true | Optional |
| auto_upgrade | Whether the nodes will be automatically upgraded | true (if cluster is regional) | Optional |
| storage_pools | The list of Storage Pools where boot disks are provisioned. | Optional | |
| boot_disk_kms_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool. This should be of the form projects/[KEY_PROJECT_ID]/locations/[LOCATION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]. | " " | Optional |
| cpu_manager_policy | The CPU manager policy on the node. One of "none" or "static". | "static" | Optional |
| cpu_cfs_quota | Enforces the Pod's CPU limit. Setting this value to false means that the CPU limits for Pods are ignored | null | Optional |
| cpu_cfs_quota_period | The CPU CFS quota period value, which specifies the period of how often a cgroup's access to CPU resources should be reallocated | null | Optional |
| pod_pids_limit | Controls the maximum number of processes allowed to run in a pod. The value must be greater than or equal to 1024 and less than 4194304. | null | Optional |
| container_log_max_size | Defines the maximum size of the container log file before it is rotated. | null | Optional |
| container_log_max_files | Defines the maximum number of container log files that can be present for a container. | null | Optional |
| image_gc_low_threshold_percent | Defines the percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to. | null | Optional |
| image_gc_high_threshold_percent | Defines the percent of disk usage after which image garbage collection is always run. | null | Optional |
| image_minimum_gc_age | Defines the minimum age for an unused image before it is garbage collected. | null | Optional |
| image_maximum_gc_age | Defines the maximum age an image can be unused before it is garbage collected. | null | Optional |
| allowed_unsafe_sysctls | Defines a comma-separated allowlist of unsafe sysctls or sysctl patterns which can be set on the Pods. This should be passed as comma separated string. | null | Optional |
| enable_confidential_nodes | An optional flag to enable confidential node config. | false | Optional |
| disk_size_gb | Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB | 100 | Optional |
| disk_type | Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') | pd-standard | Optional |
| provisioned_iops | Indicates how many IOPS to provision for the disk. This sets the number of I/O operations per second that the disk can handle. For more details, see the Hyperdisk documentation. | null | Optional |
| provisioned_throughput | Indicates how much throughput to provision for the disk, in MB/s. This sets the amount of data that can be read or written to the disk per second. For more details, see the Hyperdisk documentation. | null | Optional |
| effect | Effect for the taint | Required | |
| enable_fast_socket | Enable the NCCL Fast Socket feature. enable_gvnic must also be enabled. |
null | Optional |
| enable_gcfs | Google Container File System (gcfs) has to be enabled for image streaming to be active. Needs image_type to be set to COS_CONTAINERD. | false | Optional |
| enable_gvnic | gVNIC (GVE) is an alternative to the virtIO-based ethernet driver. Needs a Container-Optimized OS node image. | false | Optional |
| enable_integrity_monitoring | Enables monitoring and attestation of the boot integrity of the instance. The attestation is performed against the integrity policy baseline. This baseline is initially derived from the implicitly trusted boot image when the instance is created. | true | Optional |
| enable_secure_boot | Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. | false | Optional |
| gpu_driver_version | Mode for how the GPU driver is installed | null | Optional |
| gpu_partition_size | Size of partitions to create on the GPU | null | Optional |
| image_type | The image type to use for this node. Note that changing the image type will delete and recreate all nodes in the node pool | COS_CONTAINERD | Optional |
| initial_node_count | The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. Changing this will force recreation of the resource. Defaults to the value of min_count | " " | Optional |
| insecure_kubelet_readonly_port_enabled | (boolean) Whether or not to enable the insecure Kubelet readonly port. | null | Optional |
| single_process_oom_kill | (boolean) On cgroupv2 nodes, defines whether processes in the container are OOM killed individually (true) or as a group (false, the kubelet default). Leave null to keep the kubelet default. | null | Optional |
| key | The key required for the taint | Required | |
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a hostpath volume or a local PersistentVolume. |
0 | Optional |
| local_ssd_ephemeral_storage_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| ephemeral_storage_local_ssd_data_cache_count | Number of raw-block local NVMe SSD disks to be attached to the node utilized for GKE Data Cache. | 0 | Optional |
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an emptyDir volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. |
0 | Optional |
| local_nvme_ssd_count | Number of raw-block local NVMe SSD disks to be attached to the node.Each local SSD is 375 GB in size. If zero, it means no raw-block local NVMe SSD disks to be attached to the node. | 0 | Optional |
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
| enable_confidential_storage | Enabling Confidential Storage will create boot disk with confidential mode. | false | Optional |
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
| strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: SURGE, BLUE_GREEN, or for flex-start and queued provisioning SHORT_LIVED |
"SURGE" | Optional |
| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional |
| enable_nested_virtualization | Whether the node should have nested virtualization | null | Optional |
| performance_monitoring_unit | Level of Performance Monitoring Unit (PMU) requested. If unset, no access to the PMU is assumed. Values values are: ARCHITECTURAL, STANDARD, and ENHANCED |
null | Optional |
| max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with SURGE strategy. |
1 | Optional |
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with SURGE strategy. |
0 | Optional |
| node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with BLUE_GREEN strategy. |
"3600s" | Optional |
| batch_soak_duration | Soak time after each batch gets drained, with the default being zero seconds. Only works with BLUE_GREEN strategy. |
"0s" | Optional |
| batch_node_count | Absolute number of nodes to drain in a batch. If it is set to zero, this phase will be skipped. Cannot be used together with batch_percentage. Only works with BLUE_GREEN strategy. |
1 | Optional |
| batch_percentage | Percentage of nodes to drain in a batch. Must be in the range of [0.0, 1.0]. If it is set to zero, this phase will be skipped. Cannot be used together with batch_node_count. Only works with BLUE_GREEN strategy. |
null | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
| name | The name of the node pool | Required | |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as COMPACT if desired | Optional | |
| policy_name | If set, refers to the name of a custom resource policy supplied by the user. The resource policy must be in the same project and region as the node pool. | Optional | |
| tpu_topology | TPU placement topology for pod slice node pool. For detail see documentation | Optional | |
| pod_range | The name of the secondary range for pod IPs. | Optional | |
| enable_private_nodes | Whether nodes have internal IP addresses only. | Optional | |
| node_affinity | The node affinty in the format "{\"key\": \"compute.googleapis.com/node-group-name\", \"operator\": \"IN\", \"values\": [\"node-group-name\"]}". |
Optional | |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | Required | |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
| node_metadata | Options to expose the node metadata to the workload running on the node | Optional | |
| preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional |
| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional |
| sandbox_type | Sandbox to use for pods in the node pool | Required | |
| service_account | The service account to be used by the Node VMs | " " | Optional |
| tags | The list of instance tags applied to all nodes | Required | |
| value | The value for the taint | Required | |
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
| location_policy | Location policy specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see documentation. gcfs_config must be enabled=true for this feature to work. |
Optional | |
| secondary_boot_disk_mode | Mode for the secondary boot disk. Defaults to CONTAINER_IMAGE_CACHE (preloads container images, requires gcfs_config enabled). Set to null to omit the field for data preloading (mounts data onto nodes for use via hostPath). |
"CONTAINER_IMAGE_CACHE" |
Optional |
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | Optional | |
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | Optional | |
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | Optional | |
| total_egress_bandwidth_tier | Specifies the total network bandwidth tier. Valid values are: "TIER_1" and "TIER_UNSPECIFIED". | Optional | |
| pod_cidr_overprovision_disabled | Disables GKE's default doubling of the per-node pod IP range allocation when set to true. |
Optional | |
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | Optional | |
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | Optional | |
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | Optional | |
| local_ssd_encryption_mode | specifies the method used for encrypting the local SSDs attached to the node. Valid values are: "STANDARD_ENCRYPTION" and "EPHEMERAL_KEY_ENCRYPTION" | Optional | |
| max_run_duration | The runtime of each node in the node pool in seconds, terminated by 's'. Example: "3600s". | null | Optional |
| flex_start | Enables Flex Start provisioning model for the node pool | null | Optional |
| respect_pdb_during_node_pool_deletion | Whether to respect Pod Disruption Budgets during node pool deletion. | null | Optional |
windows_node_pools variable
The windows_node_pools variable takes the same parameters as node_pools but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a specific requirement for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.
| Name | Description | Default | Requirement |
|---|---|---|---|
| windows_node_config_os_version | The Windows OS version to use for the windows node pool. Valid values are OS_VERSION_UNSPECIFIED, OS_VERSION_LTSC2019 and OS_VERSION_LTSC2022. | null | Optional |
Requirements
Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:
- Terraform and kubectl are installed on the machine where Terraform is executed.
- The Service Account you execute the module with has the right permissions.
- The Compute Engine and Kubernetes Engine APIs are active on the project you will launch the cluster in.
- If you are using a Shared VPC, the APIs must also be activated on the Shared VPC host project and your service account needs the proper permissions there.
The project factory can be used to provision projects with the correct APIs active and the necessary Shared VPC connections.
Software Dependencies
Kubectl
- kubectl 1.9.x
Terraform and Plugins
- Terraform 1.3+
- Terraform Provider for GCP Beta v7.39+
gcloud
Some submodules use the terraform-google-gcloud module. By default, this module assumes you already have gcloud installed in your $PATH.
See the module documentation for more information.
Configure a Service Account
In order to execute this module you must have a Service Account with the
following project roles:
- roles/compute.viewer
- roles/compute.securityAdmin (only required if
add_cluster_firewall_rulesis set totrue) - roles/container.clusterAdmin
- roles/container.developer
- roles/iam.serviceAccountAdmin
- roles/iam.serviceAccountUser
- roles/resourcemanager.projectIamAdmin (only required if
service_accountis set tocreate)
Additionally, if service_account is set to create and grant_registry_access is requested, the service account requires the following role on the registry_project_ids projects:
- roles/resourcemanager.projectIamAdmin
Enable APIs
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
- Compute Engine API - compute.googleapis.com
- Kubernetes Engine API - container.googleapis.com
Overview (`modules/binary-authorization/README.md`)
Binary Authorization Infrastructure
This module creates the infrastructure and Attestors necessary to generate attestations on image digests.
Compatibility/Requirements
- GCP Project ID where the project has an active billing account associated with it
- Terraform version 1.3+
- Google Kubernetes Engine cluster with "Binary Authorization" enabled
Usage
# Create a Key Ring
resource "google_kms_key_ring" "keyring" {
name = "my-example-attestor-key-ring"
location = var.keyring-region
lifecycle {
prevent_destroy = false
}
}
# Create Quality Assurance attestor
module "quality-attestor" {
source = "terraform-google-modules/kubernetes-engine/google//modules/binary-authorization"
attestor-name = "quality-assurance"
keyring-id = google_kms_key_ring.keyring.id
}Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| attestor-name | Name of the attestor | string |
n/a | yes |
| crypto-algorithm | Algorithm used for the async signing keys | string |
"RSA_SIGN_PKCS1_4096_SHA512" |
no |
| disable_dependent_services | Whether services that are enabled and which depend on this service should also be disabled when this service is destroyed. https://www.terraform.io/docs/providers/google/r/google_project_service.html#disable_dependent_services | bool |
false |
no |
| disable_services_on_destroy | Whether project services will be disabled when the resources are destroyed. https://www.terraform.io/docs/providers/google/r/google_project_service.html#disable_on_destroy | bool |
false |
no |
| keyring-id | Keyring ID to attach attestor keys | string |
n/a | yes |
| project_id | Project ID to apply services into | string |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| attestor | Name of the built attestor |
| key | Name of the Key created for the attestor |
Next Steps
After building the Attestors, Attestations can be associated with image digests.
This module does not include a Binary Authorization policy for a cluster. A sample policy implemented as Dry-Run/Log-Only using our "quality-assurance" Attestor could look like this:
resource "google_binary_authorization_policy" "policy" {
admission_whitelist_patterns {
name_pattern = "gcr.io/${var.project_id}/*" # Enable local project GCR
}
global_policy_evaluation_mode = "ENABLE"
# Production ready (all attestors required)
default_admission_rule {
evaluation_mode = "REQUIRE_ATTESTATION"
enforcement_mode = "DRYRUN_AUDIT_LOG_ONLY"
require_attestations_by = [
module.quality-attestor.attestor # Our Attestor
]
}
}Overview (`modules/fleet-app-operator-permissions/README.md`)
Terraform Module for Fleet App Operator Permissions
This module bundles different permissions (IAM and RBAC Role Bindings) required for Fleet team management. A platform admin can use this module to set up permissions for an app operator (user or group) in a team--including usage of Fleet Scopes, Connect Gateway, logging, and metrics--based on predefined roles (VIEW, EDIT, ADMIN).
Usage
Example:
module "fleet_app_operator_permissions" {
source = "terraform-google-modules/kubernetes-engine/google//modules/fleet-app-operator-permissions"
fleet_project_id = "my-project-id"
scope_id = "frontend-team"
users = ["[email protected]", "[email protected]"]
groups = ["[email protected]"]
role = "EDIT"
}
Example:
module "fleet_app_operator_permissions" {
source = "terraform-google-modules/kubernetes-engine/google//modules/fleet-app-operator-permissions"
fleet_project_id = "my-project-id"
scope_id = "frontend-team"
users = ["[email protected]", "[email protected]"]
groups = ["[email protected]"]
custom_role = "my-custom-role"
}To deploy this config, run:
terraform initto get the pluginsterraform planto see the infrastructure planterraform applyto apply the infrastructure buildterraform destroyto destroy the built infrastructure
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| custom_role | The principal's role for the Fleet Scope which is a custom Kubernetes ClusterRole. Either a predefined role or a custom role should be set | string |
null |
no |
| fleet_project_id | The project to which the Fleet belongs. | string |
n/a | yes |
| groups | The list of app operator group principals, e.g., [email protected], principalSet://iam.googleapis.com/locations/global/workforcePools/my-pool/group/people. |
list(string) |
[] |
no |
| role | The principal's predefined role for the Fleet Scope (VIEW/EDIT/ADMIN). Either a predefined role or a custom role should be set |
string |
null |
no |
| scope_id | The scope for which IAM and RBAC role bindings are created. | string |
n/a | yes |
| users | The list of app operator user principals, e.g., [email protected], principal://iam.googleapis.com/locations/global/workforcePools/my-pool/subject/person, serviceAccount:[email protected]. |
list(string) |
[] |
no |
Outputs
| Name | Description |
|---|---|
| fleet_project_id | The project to which the Fleet belongs. |
| wait | An output to use when you want to depend on Scope RBAC Role Binding creation finishing. |
Overview (`modules/fleet-membership/README.md`)
Terraform Kubernetes Engine Hub Submodule
This module registers a GKE cluster in an Anthos Environ.
Specifically, this module automates the following steps for registering a cluster
Usage
There is a GKE full example and a Generic K8s example provided. Simple usage is as follows:
module "hub" {
source = "terraform-google-modules/kubernetes-engine/google//modules/fleet-membership"
project_id = "my-project-id"
cluster_name = "my-cluster-name"
}To deploy this config:
- Run
terraform apply
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_name | The GKE cluster name | string |
n/a | yes |
| enable_fleet_registration | Enables GKE Hub Registration when set to true | bool |
true |
no |
| hub_project_id | The project in which the GKE Hub belongs. Defaults to GKE cluster project_id. | string |
"" |
no |
| location | The location (zone or region) this cluster has been created in. | string |
n/a | yes |
| membership_location | Membership location for the cluster. Defaults to global. | string |
"global" |
no |
| membership_name | Membership name that uniquely represents the cluster being registered. Defaults to $project_id-$location-$cluster_name. |
string |
"" |
no |
| project_id | The project in which the GKE cluster belongs. | string |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| cluster_membership_id | The ID of the hub membership |
| location | The location of the hub membership. |
| project_id | The project of the hub membership. |
| wait | An output to use when you want to depend on registration finishing |
Overview (`modules/gke-autopilot-cluster/README.md`)
GKE Autopilot Cluster
This submodule creates a basic private cluster with Autopilot enabled. Beta features are enabled in this submodule.
For a module with a complete configuration of a Google Cloud Platform Kubernetes Engine private cluster with Autopilot including GKE cluster, IP masq, Service account creation and Firewall configuration see the module beta-autopilot-private-cluster.
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| addons_config | The configuration for addons supported by GKE Autopilot. | object({ gcp_filestore_csi_driver_config = optional(object({ enabled = optional(bool) })) gke_backup_agent_config = optional(object({ enabled = optional(bool) })) ray_operator_config = optional(object({ enabled = optional(bool) ray_cluster_logging_config = optional(object({ enabled = optional(bool) })) ray_cluster_monitoring_config = optional(object({ enabled = optional(bool) })) })) }) | null |
no |
| allow_net_admin | (Optional) Enable NET_ADMIN for the cluster. | bool |
false |
no |
| authenticator_groups_config | Configuration for the Google Groups for GKE feature. The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected]. | object({ security_group = string }) | null |
no |
| binary_authorization | Configuration options for the Binary Authorization feature. Can be PROJECT_SINGLETON_POLICY_ENFORCE or DISABLED |
object({ evaluation_mode = optional(string) }) | null |
no |
| cluster_autoscaling | Per-cluster configuration of Node Auto-Provisioning with Cluster Autoscaler to automatically adjust the size of the cluster. | object({ auto_provisioning_defaults = optional(object({ service_account = optional(string) boot_disk_kms_key = optional(string) })) }) | null |
no |
| cluster_ipv4_cidr | The IP address range of the Kubernetes pods in this cluster in CIDR notation (e.g. 10.96.0.0/14). Leave blank to have one automatically chosen or specify a /14 block in 10.0.0.0/8. This field will only work for routes-based clusters, where ip_allocation_policy is not defined. | string |
null |
no |
| cluster_telemetry | Configuration for ClusterTelemetry feature. Telemetry integration for the cluster. Supported values (ENABLED, DISABLED, SYSTEM_ONLY); SYSTEM_ONLY (Only system components are monitored and logged) is only available in GKE versions 1.15 and later. | object({ type = string }) | null |
no |
| confidential_nodes | Configuration for Confidential Nodes feature. | object({ enabled = bool }) | null |
no |
| control_plane_endpoints_config | Configuration for all of the cluster's control plane endpoints. | object({ dns_endpoint_config = optional(object({ allow_external_traffic = optional(bool) })) ip_endpoints_config = optional(object({ enabled = optional(bool) })) }) | null |
no |
| cost_management_config | The Cost Management configuration for the cluster. | object({ enabled = optional(bool) }) | null |
no |
| database_encryption | Application-layer Secrets Encryption settings. | object({ state = optional(string) key_name = optional(string) }) | null |
no |
| datapath_provider | The desired datapath provider for this cluster. This is set to LEGACY_DATAPATH by default, which uses the IPTables-based kube-proxy implementation. Set to ADVANCED_DATAPATH to enable Dataplane v2. | string |
null |
no |
| default_snat_status | GKE SNAT DefaultSnatStatus contains the desired state of whether default sNAT should be disabled on the cluster, API doc. In-node sNAT rules will be disabled when defaultSnatStatus is disabled.When disabled is set to false, default IP masquerade rules will be applied to the nodes to prevent sNAT on cluster internal traffic | object({ disabled = bool }) | null |
no |
| deletion_protection | Whether Terraform will be prevented from destroying the cluster. Deleting this cluster via terraform destroy or terraform apply will only succeed if this field is false in the Terraform state. | bool |
false |
no |
| description | Description of the cluster. | string |
"" |
no |
| disable_l4_lb_firewall_reconciliation | If true, stops GKE from reconciling firewall rules for L4 ILB Services. | bool |
null |
no |
| dns_config | Configuration for Cloud DNS for GKE. | object({ additive_vpc_scope_dns_domain = optional(string) cluster_dns = optional(string) cluster_dns_scope = optional(string) cluster_dns_domain = optional(string) }) | null |
no |
| enable_cilium_clusterwide_network_policy | Enables Cilium-based GKE Dataplane V2 wide network policy. This feature is in public beta. | bool |
null |
no |
| enable_fqdn_network_policy | Whether FQDN Network Policy is enabled on this cluster. | bool |
null |
no |
| enable_k8s_beta_apis | Configuration for Kubernetes Beta APIs. | object({ enabled_apis = list(string) }) | null |
no |
| enable_l4_ilb_subsetting | Enables L4 ILB subsetting. L4 ILB subsetting can be used with clusters of all sizes. This feature is in public beta. | bool |
null |
no |
| enable_multi_networking | Enable multi-networking for this cluster. This feature requires projects to have enabled GKE multi-networking series APIs. This feature is in public beta. | bool |
null |
no |
| enterprise_config | Enterprise configuration for the cluster. Sets the tier of the cluster. Available options include STANDARD and ENTERPRISE. | object({ desired_tier = string }) | null |
no |
| fleet | Fleet configuration for the cluster. The name of the Fleet host project where this cluster will be registered. | object({ project = optional(string) }) | null |
no |
| gateway_api_config | Configuration for the Gateway API, which manages access to Kubernetes services. | object({ channel = string }) | null |
no |
| identity_service_config | Whether to enable the Identity Service component. It is disabled by default. Set enabled=true to enable. | object({ enabled = optional(bool) }) | null |
no |
| in_transit_encryption_config | Defines the config of in-transit encryption. Valid values are IN_TRANSIT_ENCRYPTION_DISABLED and IN_TRANSIT_ENCRYPTION_INTER_NODE_TRANSPARENT. |
string |
null |
no |
| ip_allocation_policy | Configuration of cluster IP allocation for VPC-native clusters. If this block is unset during creation, it will be set by the GKE backend. | object({ cluster_secondary_range_name = optional(string) services_secondary_range_name = optional(string) cluster_ipv4_cidr_block = optional(string) services_ipv4_cidr_block = optional(string) stack_type = optional(string) additional_pod_ranges_config = optional(object({ pod_range_names = list(string) })) }) | null |
no |
| location | The location (region or zone) in which the cluster master will be created, as well as the default node location. If you specify a zone (such as us-central1-a), the cluster will be a zonal cluster with a single cluster master. If you specify a region (such as us-west1), the cluster will be a regional cluster with multiple masters spread across zones in the region, and with default node locations in those zones as well. | string |
n/a | yes |
| logging_config | The GKE components exposing logs. Supported values include: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. | object({ enable_components = optional(list(string)) }) | null |
no |
| maintenance_policy | The maintenance policy to use for the cluster. | object({ daily_maintenance_window = optional(object({ start_time = optional(string) })) recurring_window = optional(object({ start_time = optional(string) end_time = optional(string) recurrence = optional(string) })) maintenance_exclusion = optional(list(object({ exclusion_name = optional(string) start_time = optional(string) end_time = optional(string) exclusion_options = optional(object({ scope = optional(string) })) }))) }) | { "daily_maintenance_window": { "start_time": "05:00" }} | no |
| master_auth | The authentication information for accessing the Kubernetes master. | object({ client_certificate_config = optional(object({ issue_client_certificate = optional(bool) })) }) | null |
no |
| master_authorized_networks_config | The desired configuration options for master authorized networks. Cidr Block must follow Cidr notation | object({ cidr_blocks = list(object({ display_name = string cidr_block = string })) gcp_public_cidrs_access_enabled = optional(bool) private_endpoint_enforcement_enabled = optional(bool) }) | n/a | yes |
| mesh_certificates | Configuration for the provisioning of managed mesh certificates. | object({ enable_certificates = optional(bool) }) | null |
no |
| min_master_version | The minimum version of the master. GKE will auto-update the master to new versions, so this does not guarantee the master version--use the read-only master_version field to obtain a current version. If unset, the server's default version will be used. | string |
null |
no |
| monitoring_config | (Optional) The GKE components exposing metrics. Supported values include: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR, DCGM and JOBSET. | object({ enable_components = optional(list(string)) }) | null |
no |
| name | The name of the cluster (required) | string |
n/a | yes |
| network | The name or self_link of the Google Compute Engine network to which the cluster is connected. For Shared VPC, this network must be in the host project. | string |
n/a | yes |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes are created in the region's zones by default. This list must be a subset of the compute/zones in the region to which the cluster belongs. This field is optional for Zonal clusters and required for Regional clusters. | list(string) |
null |
no |
| node_pool_auto_config | Node pool auto-configuration for the cluster. This block contains settings for managing Kubelet, resource manager tags, network tags, and Linux node configurations for automatically provisioned node pools. | object({ node_kubelet_config = optional(object({ insecure_kubelet_readonly_port_enabled = optional(bool) })) resource_manager_tags = optional(map(string)) network_tags = optional(object({ tags = optional(list(string)) })) linux_node_config = optional(object({ cgroup_mode = optional(string) })) }) | { "node_kubelet_config": { "insecure_kubelet_readonly_port_enabled": false }} | no |
| notification_config | Configuration for the cluster upgrade notifications feature. | object({ pubsub = object({ enabled = bool topic = optional(string) filter = optional(object({ event_type = optional(string) })) }) }) | null |
no |
| pod_autoscaling | Enable the Horizontal Pod Autoscaling profile for this cluster.Acceptable values are:'NONE' - Customers explicitly opt-out of HPA profiles, 'PERFORMANCE' - PERFORMANCE is used when customers opt-in to the performance HPA profile. In this profile we support a higher number of HPAs per cluster and faster metrics collection for workload autoscaling. See HPAProfile for more details. | object({ hpa_profile = string }) | null |
no |
| pod_security_policy_config | Configuration for the PodSecurityPolicy feature. | object({ enabled = bool }) | null |
no |
| private_cluster_config | Configuration for private clusters, clusters with private nodes. | object({ enable_private_nodes = optional(bool) enable_private_endpoint = optional(bool) master_ipv4_cidr_block = optional(string) private_endpoint_subnetwork = optional(string) master_global_access_config = optional(object({ enabled = optional(bool) })) }) | { "enable_private_endpoint": true, "enable_private_nodes": true, "master_global_access_config": { "enabled": true }} | no |
| private_ipv6_google_access | The desired state of IPv6 access to Google Services. By default, no private IPv6 access to or from Google Services (all access will be via IPv4). | string |
null |
no |
| project_id | The ID of the project in which the resource belongs. | string |
n/a | yes |
| protect_config | Enable/Disable Protect API features for the cluster. | object({ workload_config = object({ audit_mode = string }) workload_vulnerability_mode = optional(string) }) | null |
no |
| release_channel | The release channel of this cluster. Accepted values are UNSPECIFIED, RAPID, REGULAR and STABLE. Defaults to REGULAR. |
object({ channel = optional(string) }) | { "channel": "REGULAR"} | no |
| resource_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster. Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field 'effective_labels' for all of the labels present on the resource. | map(string) |
null |
no |
| resource_usage_export_config | Configuration for the ResourceUsageExportConfig feature. | object({ enable_network_egress_metering = optional(bool) enable_resource_consumption_metering = optional(bool) bigquery_destination = object({ dataset_id = string }) }) | null |
no |
| secret_manager_config | Configuration for the SecretManagerConfig feature | object({ enabled = bool }) | null |
no |
| secret_sync_config | Configuration for the Secret Sync add-on for this cluster. | object({ enabled = bool }) | null |
no |
| security_posture_config | Security posture configuration for the cluster. mode - Sets the mode of the Kubernetes security posture API's off-cluster features. Available options include DISABLED, BASIC, and ENTERPRISE. vulnerability_mode - Sets the mode of the Kubernetes security posture API's workload vulnerability scanning. Available options include VULNERABILITY_DISABLED, VULNERABILITY_BASIC and VULNERABILITY_ENTERPRISE. | object({ mode = optional(string) vulnerability_mode = optional(string) }) | null |
no |
| service_external_ips_config | Configuration for controlling how IPs are allocated to Service objects. | object({ enabled = optional(bool) }) | { "enabled": false} | no |
| subnetwork | The name or self_link of the Google Compute Engine subnetwork in which the cluster's instances are launched. | string |
n/a | yes |
| timeouts | Timeout for cluster operations. | object({ create = optional(string) update = optional(string) delete = optional(string) }) | { "create": "45m", "delete": "45m", "update": "45m"} | no |
| vertical_pod_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it. | object({ enabled = optional(bool) }) | { "enabled": true} | no |
| workload_alts_config | Workload ALTS configuration for the cluster. Whether the alts handshaker should be enabled or not for direct-path. Requires Workload Identity (workloadPool) must be non-empty | object({ enable_alts = bool }) | null |
no |
| workload_identity_config | Configuration for the use of Kubernetes Service Accounts in GCP IAM policies. | object({ workload_pool = string }) | n/a | yes |
Outputs
| Name | Description |
|---|---|
| addons_config | The configuration for addons supported by GKE Autopilot. |
| ca_certificate | Cluster ca certificate (base64 encoded) |
| cluster_id | Cluster ID |
| cluster_name | Cluster name |
| endpoint | Cluster endpoint |
| endpoint_dns | Cluster endpoint DNS |
| identity_service_enabled | Whether Identity Service is enabled |
| intranode_visibility_enabled | Whether intra-node visibility is enabled |
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
| logging_service | Logging service used |
| master_authorized_networks_config | Networks from which access to master is permitted |
| master_version | Current master kubernetes version |
| min_master_version | Minimum master kubernetes version |
| monitoring_service | Monitoring service used |
| node_locations | The list of zones in which the cluster's nodes are located. |
| secret_manager_addon_enabled | Whether Secret Manager add-on is enabled |
| vertical_pod_autoscaling_enabled | Whether vertical pod autoscaling enabled |
Overview (`modules/gke-node-pool/README.md`)
GKE Node Pool
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| autoscaling | Configuration required by cluster autoscaler to adjust the size of the node pool to the current cluster usage. | object({ min_node_count = optional(number) max_node_count = optional(number) total_min_node_count = optional(number) total_max_node_count = optional(number) location_policy = optional(string) }) | { "max_node_count": 100, "min_node_count": 1} | no |
| cluster | The cluster to create the node pool for. Cluster must be present in location provided for clusters. May be specified in the format projects/{project_id}/locations/{location}/clusters/{cluster} or as just the name of the cluster. | string |
n/a | yes |
| initial_node_count | The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. | number |
null |
no |
| kubernetes_version | The Kubernetes version for the nodes in this pool. Note that if this field and auto_upgrade are both specified, they will fight each other for what the node version should be, so setting both is highly discouraged. While a fuzzy version can be specified, it's recommended that you specify explicit versions as Terraform will see spurious diffs when fuzzy versions are used. See the google_container_engine_versions data source's version_prefix field to approximate fuzzy versions in a Terraform-compatible way. | string |
null |
no |
| location | The location (region or zone) of the cluster. | string |
null |
no |
| management | Node management configuration, wherein auto-repair and auto-upgrade is configured. - auto_repair: Whether the nodes will be automatically repaired. Enabled by default. - auto_upgrade : Whether the nodes will be automatically upgraded. Enabled by default. | object({ auto_repair = optional(bool) auto_upgrade = optional(bool) }) | { "auto_repair": true, "auto_upgrade": true} | no |
| max_pods_per_node | The maximum number of pods per node in this node pool. Note that this does not work on node pools which are 'route-based' - that is, node pools belonging to clusters that do not have IP Aliasing enabled. See the official documentation for more information. | number |
null |
no |
| name | The name of the node pool. If left blank, Terraform will auto-generate a unique name. | string |
null |
no |
| name_prefix | Creates a unique name for the node pool beginning with the specified prefix. Conflicts with name. | string |
null |
no |
| network_config | The network configuration of the pool. | object({ create_pod_range = optional(bool) enable_private_nodes = optional(bool) pod_ipv4_cidr_block = optional(string) pod_range = optional(string) additional_node_network_configs = optional(list(object({ network = string subnetwork = string }))) additional_pod_network_configs = optional(list(object({ subnetwork = string secondary_pod_range = string max_pods_per_node = number }))) pod_cidr_overprovision_config = optional(object({ disabled = bool })) network_performance_config = optional(object({ total_egress_bandwidth_tier = string })) }) | null |
no |
| node_config | Parameters used in creating the node pool. | object({ confidential_nodes = optional(object({ enabled = bool })) disk_size_gb = optional(number) disk_type = optional(string) enable_confidential_storage = optional(bool) local_ssd_encryption_mode = optional(string) ephemeral_storage_config = optional(object({ local_ssd_count = number })) ephemeral_storage_local_ssd_config = optional(object({ local_ssd_count = number data_cache_count = optional(number) })) fast_socket = optional(object({ enabled = bool })) local_nvme_ssd_block_config = optional(object({ local_ssd_count = number })) logging_variant = optional(string) secondary_boot_disks = optional(object({ disk_image = string mode = optional(string) })) gcfs_config = optional(object({ enabled = bool })) gvnic = optional(object({ enabled = bool })) guest_accelerator = optional(object({ type = string count = number gpu_driver_installation_config = optional(object({ gpu_driver_version = string })) gpu_partition_size = optional(string) gpu_sharing_config = optional(object({ gpu_sharing_strategy = string max_shared_clients_per_gpu = number })) })) image_type = optional(string) labels = optional(map(string)) resource_labels = optional(map(string)) max_run_duration = optional(string) flex_start = optional(bool) local_ssd_count = optional(number) machine_type = optional(string) metadata = optional(map(string)) min_cpu_platform = optional(string) oauth_scopes = optional(list(string)) preemptible = optional(bool) reservation_affinity = optional(object({ consume_reservation_type = string key = optional(string) values = optional(list(string)) })) spot = optional(bool) sandbox_config = optional(object({ sandbox_type = string })) boot_disk_kms_key = optional(string) service_account = optional(string) shielded_instance_config = optional(object({ enable_secure_boot = optional(bool) enable_integrity_monitoring = optional(bool) })) storage_pools = optional(list(string)) tags = optional(list(string)) resource_manager_tags = optional(map(string)) taint = optional(list(object({ key = string value = string effect = string }))) workload_metadata_config = optional(object({ mode = optional(string) })) kubelet_config = optional(object({ cpu_manager_policy = optional(string) cpu_cfs_quota = optional(bool) cpu_cfs_quota_period = optional(string) insecure_kubelet_readonly_port_enabled = optional(bool) pod_pids_limit = optional(number) container_log_max_size = optional(string) container_log_max_files = optional(number) image_gc_low_threshold_percent = optional(number) image_gc_high_threshold_percent = optional(number) image_minimum_gc_age = optional(string) allowed_unsafe_sysctls = optional(list(string)) shutdown_grace_period_seconds = optional(number) shutdown_grace_period_critical_pods_seconds = optional(number) })) linux_node_config = optional(object({ sysctls = optional(map(string)) cgroup_mode = optional(string) hugepages_config = optional(object({ hugepage_size_2m = optional(number) hugepage_size_1g = optional(number) })) })) windows_node_config = optional(object({ osversion = string })) containerd_config = optional(object({ private_registry_access_config = optional(object({ enabled = bool certificate_authority_domain_config = optional(object({ fqdns = list(string) gcp_secret_manager_certificate_config = object({ secret_uri = string }) })) })) })) node_group = optional(string) sole_tenant_config = optional(object({ node_affinity = optional(object({ key = string operator = string values = list(string) })) })) }) | { "disk_size_gb": 100, "disk_type": "pd-standard", "image_type": "COS_CONTAINERD", "kubelet_config": { "insecure_kubelet_readonly_port_enabled": false }, "machine_type": "e2-medium", "workload_metadata_config": { "mode": "GKE_METADATA" }} | no |
| node_count | The number of nodes per instance group. This field can be used to update the number of nodes per instance group but should not be used alongside autoscaling. | number |
1 |
no |
| node_locations | The list of zones in which the node pool's nodes should be located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. If unspecified, the cluster-level node_locations will be used. Note: node_locations will not revert to the cluster's default set of zones upon being unset. You must manually reconcile the list of zones with your cluster. | list(string) |
null |
no |
| placement_policy | Specifies a custom placement policy for the nodes. - type: The type of the policy. Supports a single value: COMPACT. Specifying COMPACT placement policy type places node pool's nodes in a closer physical proximity in order to reduce network latency between nodes. - policy_name: If set, refers to the name of a custom resource policy supplied by the user. The resource policy must be in the same project and region as the node pool. If not found, InvalidArgument error is returned. - tpu_topology: The TPU topology like "2x4" or "2x2x2". | object({ type = string policy_name = optional(string) tpu_topology = optional(string) }) | null |
no |
| project_id | The ID of the project in which to create the node pool. | string |
n/a | yes |
| queued_provisioning | Specifies node pool-level settings of queued provisioning. - enabled (Required) - Makes nodes obtainable through the ProvisioningRequest API exclusively. | object({ enabled = bool }) | null |
no |
| timeouts | Timeout for cluster operations. | object({ create = optional(string) update = optional(string) delete = optional(string) }) | { "create": "45m", "delete": "45m", "update": "45m"} | no |
| upgrade_settings | Specify node upgrade settings to change how GKE upgrades nodes. | object({ max_surge = optional(number) max_unavailable = optional(number) strategy = optional(string) blue_green_settings = optional(object({ standard_rollout_policy = object({ batch_percentage = optional(number) batch_node_count = optional(number) batch_soak_duration = optional(string) }) node_pool_soak_duration = optional(string) })) }) | { "max_surge": 1, "max_unavailable": 0, "strategy": "SURGE"} | no |
Outputs
| Name | Description |
|---|---|
| id | an identifier for the resource with format {{project_id}}/{{location}}/{{cluster}}/{{name}} |
| instance_group_urls | The resource URLs of the managed instance groups associated with this node pool. |
| managed_instance_group_urls | List of instance group URLs which have been assigned to this node pool. |
| name | The name of the node pool. |
Overview (`modules/gke-standard-cluster/README.md`)
GKE Standard Cluster
This submodule creates a basic private cluster. Beta features are enabled in this submodule.
For a module with a complete configuration of a Google Cloud Platform Kube