Skip to content

Instantly share code, notes, and snippets.

@izakfilmalter
Last active June 6, 2022 16:48
Show Gist options
  • Save izakfilmalter/b95ed1375e7b4ff934614997bdc494d0 to your computer and use it in GitHub Desktop.
Save izakfilmalter/b95ed1375e7b4ff934614997bdc494d0 to your computer and use it in GitHub Desktop.
Terraform config to set up basic GKE cluster for Temporal.
terraform {
required_version = ">= 1.2.1"
cloud {
organization = var.tf_organization
workspaces {
name = var.tf_workspace
}
}
}
provider "google" {
project = var.gcp_project
region = var.gcp_region
}
tf_organization = "acme-inc"
tf_workspace = "infrastructure"
gcp_project = "acme-app"
gcp_region = "us-central1"
subnetwork_name = "acme-subnetwork"
network_name ="acme-network"
cluster_name = "acme-workers"
subnetwork_services_name = "services-range"
subnetwork_pod_name = "pod-ranges"
variable "tf_organization" {
description = "Terraform Organization"
type = string
}
variable "tf_workspace" {
description = "Terraform Workspace Name"
type = string
}
variable "gcp_project" {
description = "GCP Project"
type = string
}
variable "gcp_region" {
description = "GCP Region"
type = string
}
variable "subnetwork_name" {
description = "google_compute_subnetwork name"
type = string
}
variable "network_name" {
description = "google_compute_network name"
type = string
}
variable "cluster_name" {
description = "google_container_cluster name"
type = string
}
variable "subnetwork_services_name" {
description = "Services ip range name"
type = string
}
variable "subnetwork_pod_name" {
description = "Pod ip range name"
type = string
}
resource "google_compute_subnetwork" "kub-cluster" {
name = var.subnetwork_name
ip_cidr_range = "10.0.0.0/16"
region = var.gcp_region
network = google_compute_network.kub-cluster.id
secondary_ip_range {
range_name = var.subnetwork_services_name
ip_cidr_range = "10.3.0.0/16"
}
secondary_ip_range {
range_name = var.subnetwork_pod_name
ip_cidr_range = "10.2.0.0/16"
}
}
resource "google_compute_network" "kub-cluster" {
name = var.network_name
auto_create_subnetworks = false
}
resource "google_container_cluster" "kub-cluster" {
name = var.cluster_name
location = var.gcp_region
initial_node_count = 1
network = google_compute_network.kub-cluster.id
subnetwork = google_compute_subnetwork.kub-cluster.id
ip_allocation_policy {
cluster_secondary_range_name = var.subnetwork_services_name
services_secondary_range_name = google_compute_subnetwork.kub-cluster.secondary_ip_range.1.range_name
}
cluster_autoscaling {
enabled = true
resource_limits {
resource_type = "cpu"
minimum = 6
maximum = 24
}
resource_limits {
resource_type = "memory"
minimum = 12
maximum = 48
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment