-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
70 lines (68 loc) · 2.08 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
provider "google" {
version = ">= 3.90.0"
region = var.region
}
module "gke_auth" {
source = "terraform-google-modules/kubernetes-engine/google//modules/auth"
depends_on = [module.gke]
project_id = var.project_id
location = module.gke.location
cluster_name = module.gke.name
}
resource "local_file" "kubeconfig" {
content = module.gke_auth.kubeconfig_raw
filename = "kubeconfig-${var.env_name}"
depends_on = [google_project_service.project]
}
module "gcp-network" {
source = "terraform-google-modules/network/google"
version = "~> 2.5"
depends_on = [google_project_service.project]
project_id = var.project_id
network_name = "${var.network}-${var.env_name}"
subnets = [
{
subnet_name = "${var.subnetwork}-${var.env_name}"
subnet_ip = "10.10.0.0/16"
subnet_region = var.region
},
]
secondary_ranges = {
"${var.subnetwork}-${var.env_name}" = [
{
range_name = var.ip_range_pods_name
ip_cidr_range = "10.20.0.0/16"
},
{
range_name = var.ip_range_services_name
ip_cidr_range = "10.30.0.0/16"
},
]
}
}
module "gke" {
source = "terraform-google-modules/kubernetes-engine/google//modules/private-cluster"
depends_on = [google_project_service.project]
project_id = var.project_id
name = "${var.cluster_name}-${var.env_name}"
regional = true
region = var.region
network = module.gcp-network.network_name
subnetwork = module.gcp-network.subnets_names[0]
ip_range_pods = var.ip_range_pods_name
ip_range_services = var.ip_range_services_name
horizontal_pod_autoscaling = true
node_pools = [
{
name = "node-pool"
machine_type = "e2-medium"
node_locations = "us-east1-b"
min_count = 3
max_count = 12
disk_size_gb = 30,
autoscaling = true,
auto_repair = true
auto_upgrade = true
},
]
}