cloud-foundation-fabric/modules/gke-cluster-autopilot/README.md

9.8 KiB

GKE cluster Autopilot module

This module allows simplified creation and management of GKE Autopilot clusters. Some sensible defaults are set initially, in order to allow less verbose usage for most use cases.

Example

GKE Cluster

module "cluster-1" {
  source     = "./fabric/modules/gke-cluster-autopilot"
  project_id = "myproject"
  name       = "cluster-1"
  location   = "europe-west1"
  vpc_config = {
    network    = var.vpc.self_link
    subnetwork = var.subnet.self_link
    secondary_range_names = {
      pods     = "pods"
      services = "services"
    }
    master_authorized_ranges = {
      internal-vms = "10.0.0.0/8"
    }
    master_ipv4_cidr_block = "192.168.0.0/28"
  }
  private_cluster_config = {
    enable_private_endpoint = true
    master_global_access    = false
  }
  labels = {
    environment = "dev"
  }
}
# tftest modules=1 resources=1 inventory=basic.yaml

Cloud DNS

This example shows how to use Cloud DNS as a Kubernetes DNS provider for GKE Standard clusters.

module "cluster-1" {
  source     = "./fabric/modules/gke-cluster-autopilot"
  project_id = var.project_id
  name       = "cluster-1"
  location   = "europe-west1"
  vpc_config = {
    network               = var.vpc.self_link
    subnetwork            = var.subnet.self_link
    secondary_range_names = { pods = "pods", services = "services" }
  }
  enable_features = {
    dns = {
      provider = "CLOUD_DNS"
      scope    = "CLUSTER_SCOPE"
      domain   = "gke.local"
    }
  }
}
# tftest modules=1 resources=1 inventory=dns.yaml

Backup for GKE

This example shows how to enable the Backup for GKE agent and configure a Backup Plan for GKE Standard clusters.

module "cluster-1" {
  source     = "./fabric/modules/gke-cluster-autopilot"
  project_id = var.project_id
  name       = "cluster-1"
  location   = "europe-west1"
  vpc_config = {
    network               = var.vpc.self_link
    subnetwork            = var.subnet.self_link
    secondary_range_names = { pods = "pods", services = "services" }
  }
  backup_configs = {
    enable_backup_agent = true
    backup_plans = {
      "backup-1" = {
        region   = "europe-west-2"
        schedule = "0 9 * * 1"
      }
    }
  }
}
# tftest modules=1 resources=2 inventory=backup.yaml

Variables

name description type required default
location Autopilot cluster are always regional. string
name Cluster name. string
project_id Cluster project id. string
vpc_config VPC-level configuration. object({…})
backup_configs Configuration for Backup for GKE. object({…}) {}
description Cluster description. string null
enable_addons Addons enabled in the cluster (true means enabled). object({…}) {…}
enable_features Enable cluster-level features. Certain features allow configuration. object({…}) {…}
issue_client_certificate Enable issuing client certificate. bool false
labels Cluster resource labels. map(string) null
maintenance_config Maintenance window configuration. object({…}) {…}
min_master_version Minimum version of the master, defaults to the version of the most recent official release. string null
node_locations Zones in which the cluster's nodes are located. list(string) []
private_cluster_config Private cluster configuration. object({…}) null
release_channel Release channel for GKE upgrades. string null
service_account The Google Cloud Platform Service Account to be used by the node VMs created by GKE Autopilot. string null
tags Network tags applied to nodes. list(string) null

Outputs

name description sensitive
ca_certificate Public certificate of the cluster (base64-encoded).
cluster Cluster resource.
endpoint Cluster endpoint.
id Cluster ID.
location Cluster location.
master_version Master version.
name Cluster name.
notifications GKE PubSub notifications topic.
self_link Cluster self link.
workload_identity_pool Workload identity pool.