Initial cluster setup.
This commit is contained in:
parent
5051230431
commit
940045b321
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.terraform.lock.hcl
|
||||||
|
.terraform/
|
||||||
|
terraform.tfstate
|
||||||
|
terraform.tfstate.backup
|
73
main.tf
Normal file
73
main.tf
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
variable "project" {
|
||||||
|
description = "Project ID."
|
||||||
|
type = string
|
||||||
|
default = "secret-footing-312423"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "region" {
|
||||||
|
description = "Region."
|
||||||
|
type = string
|
||||||
|
default = "us-central1"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "zone" {
|
||||||
|
description = "Zone."
|
||||||
|
type = string
|
||||||
|
default = "us-central1-c"
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "google" {
|
||||||
|
project = var.project
|
||||||
|
region = var.region
|
||||||
|
zone = var.zone
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_project_service" "gke" {
|
||||||
|
project = var.project
|
||||||
|
service = "container.googleapis.com"
|
||||||
|
disable_dependent_services = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_service_account" "gke" {
|
||||||
|
project = var.project
|
||||||
|
account_id = "gke-service-account"
|
||||||
|
display_name = "GKE Service Account"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_container_cluster" "primary" {
|
||||||
|
project = var.project
|
||||||
|
name = "gke-cluster"
|
||||||
|
location = var.region
|
||||||
|
|
||||||
|
remove_default_node_pool = true
|
||||||
|
initial_node_count = 1
|
||||||
|
enable_shielded_nodes = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_container_node_pool" "primary" {
|
||||||
|
project = google_container_cluster.primary.project
|
||||||
|
name_prefix = "node-pool"
|
||||||
|
location = var.region
|
||||||
|
cluster = google_container_cluster.primary.name
|
||||||
|
|
||||||
|
autoscaling {
|
||||||
|
min_node_count = 0
|
||||||
|
max_node_count = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
node_config {
|
||||||
|
preemptible = true
|
||||||
|
machine_type = "e2-medium"
|
||||||
|
|
||||||
|
service_account = google_service_account.gke.email
|
||||||
|
oauth_scopes = [
|
||||||
|
"https://www.googleapis.com/auth/cloud-platform"
|
||||||
|
]
|
||||||
|
|
||||||
|
metadata = {
|
||||||
|
disable-legacy-endpoints = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
tags = []
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user