This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster.tf
123 lines (100 loc) · 3.03 KB
/
cluster.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
111
112
113
114
115
116
117
118
119
120
121
122
123
data "google_container_engine_versions" "gke_version" {
location = var.region
version_prefix = "1.27."
}
data "google_service_account" "default" {
account_id = "github-ci"
}
resource "google_compute_network" "infra-vpc" {
name = "infra-${var.region}-vpc"
auto_create_subnetworks = "false"
}
resource "google_compute_subnetwork" "infra-subnet" {
name = "infra-${var.region}-subnet"
region = var.region
network = resource.google_compute_network.infra-vpc.name
ip_cidr_range = "10.10.0.0/24"
}
resource "google_container_cluster" "infra" {
name = "infra-${var.region}"
location = var.region
remove_default_node_pool = true
initial_node_count = 1
network = resource.google_compute_network.infra-vpc.name
subnetwork = resource.google_compute_subnetwork.infra-subnet.name
cluster_autoscaling {
enabled = true
resource_limits {
resource_type = "cpu"
minimum = 2
maximum = 24
}
resource_limits {
resource_type = "memory"
minimum = 8
maximum = 48
}
auto_provisioning_defaults {
service_account = data.google_service_account.default.email
oauth_scopes = [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
disk_type = "pd-standard"
}
}
node_config {
service_account = data.google_service_account.default.email
oauth_scopes = [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
disk_type = "pd-standard"
disk_size_gb = 25
machine_type = "n1-standard-1"
metadata = {
disable-legacy-endpoints = "true"
}
}
monitoring_config {
managed_prometheus {
enabled = true
}
}
}
resource "google_container_node_pool" "infra-primary-nodes" {
name = resource.google_container_cluster.infra.name
location = var.region
cluster = resource.google_container_cluster.infra.name
version = data.google_container_engine_versions.gke_version.release_channel_latest_version["STABLE"]
node_count = 1
autoscaling {
min_node_count = 1
max_node_count = 3
}
node_config {
service_account = data.google_service_account.default.email
oauth_scopes = [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
disk_type = "pd-standard"
disk_size_gb = 25
machine_type = "n1-standard-1"
metadata = {
disable-legacy-endpoints = "true"
}
}
}
provider "kubernetes" {
host = "https://${resource.google_container_cluster.infra.endpoint}"
token = data.google_client_config.default.access_token
cluster_ca_certificate = base64decode(resource.google_container_cluster.infra.master_auth[0].cluster_ca_certificate)
}
provider "helm" {
kubernetes {
host = "https://${resource.google_container_cluster.infra.endpoint}"
token = data.google_client_config.default.access_token
cluster_ca_certificate = base64decode(resource.google_container_cluster.infra.master_auth[0].cluster_ca_certificate)
}
}