-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
executable file
·110 lines (93 loc) · 2.63 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
terraform {
required_version = ">= 0.12"
required_providers {
google = {
source = "hashicorp/google"
version = "3.54.0"
}
helm = {
source = "hashicorp/helm"
version = "2.0.2"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.0.3"
}
}
}
provider "kubernetes" {
config_path = var.config_path
alias = "k8s"
}
provider "helm" {
kubernetes {
config_path = var.config_path
}
}
provider "google" {
project = var.project
region = var.region
}
resource "google_compute_network" "vpc" {
name = "${var.project}-vpc"
auto_create_subnetworks = "false"
}
resource "google_compute_subnetwork" "subnet" {
name = "${var.project}-subnet"
region = var.region
network = google_compute_network.vpc.name
ip_cidr_range = var.ip_cidr_range
}
resource "google_container_cluster" "primary" {
name = "gke-cluster-${var.project}"
location = var.location
network = google_compute_network.vpc.name
subnetwork = google_compute_subnetwork.subnet.name
node_locations = var.node_locations
monitoring_service = "monitoring.googleapis.com/kubernetes"
logging_service = "logging.googleapis.com/kubernetes"
remove_default_node_pool = var.remove_default_node_pool
initial_node_count = var.initial_node_count
}
resource "google_container_node_pool" "primary_preemptible_nodes" {
name = "preemptible-nodes-${var.project}"
project = var.project
location = var.location
cluster = google_container_cluster.primary.name
initial_node_count = var.initial_node_count
management {
auto_repair = var.auto_repair
auto_upgrade = var.auto_upgrade
}
autoscaling {
min_node_count = var.min_node_count
max_node_count = var.max_node_count
}
node_config {
preemptible = true
machine_type = var.machine_type
metadata = {
disable-legacy-endpoints = "true"
}
oauth_scopes = var.oauth_scopes
}
depends_on = [
google_container_cluster.primary
]
}
module "helm" {
source = "./modules/helm"
count = var.install_apps ? 1 : 0
rabbitmq_auth_username = var.rabbitmq_auth_username
rabbitmq_auth_password = var.rabbitmq_auth_password
rabbitmq_auth_erlangCookie = var.rabbitmq_auth_erlangCookie
grafana_admin_user = var.grafana_admin_user
grafana_admin_password = var.grafana_admin_password
providers = {
kubernetes = kubernetes.k8s
}
depends_on = [
google_container_node_pool.primary_preemptible_nodes,
google_container_cluster.primary
]
}