-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
309 lines (248 loc) · 8.37 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
data "aws_availability_zones" "available" {}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"
name = module.eks.cluster_name
cidr = local.vpc_cidr
azs = data.aws_availability_zones.available.names
private_subnets = local.private_subnets
public_subnets = local.public_subnets
enable_nat_gateway = true
create_igw = true
enable_dns_hostnames = true
private_subnet_tags = {
"kubernetes.io/cluster/${module.eks.cluster_name}" = "shared"
"kubernetes.io/role/internal-elb" = "1"
}
public_subnet_tags = {
"kubernetes.io/cluster/${module.eks.cluster_name}" = "shared"
"kubernetes.io/role/elb" = "1"
}
}
module "eks" {
source = "git::https://github.com/camptocamp/devops-stack-module-cluster-eks.git?ref=v4.2.0"
# source = "../../devops-stack-module-cluster-eks"
cluster_name = local.cluster_name
kubernetes_version = local.kubernetes_version
base_domain = local.base_domain
subdomain = local.subdomain
vpc_id = module.vpc.vpc_id
private_subnet_ids = module.vpc.private_subnets
public_subnet_ids = module.vpc.public_subnets
cluster_endpoint_public_access_cidrs = ["0.0.0.0/0"]
node_groups = {
"${module.eks.cluster_name}-main" = {
ami_type = "AL2_ARM_64" # Use 'AL2_x86_64' for x86 VMs like 'm5.large'
instance_types = ["m7g.xlarge"]
min_size = 3
max_size = 3
desired_size = 3
nlbs_attachment = true
disk_size = 50
labels = {
"devops-stack.io/nodepool" = "main"
}
},
# "${module.eks.cluster_name}-monit" = {
# instance_types = ["m5a.large"]
# min_size = 1
# max_size = 2
# desired_size = 1
# target_group_arns = module.eks.nlb_target_groups
# taints = {
# nodegroup = {
# key = "nodegroup"
# value = "monitoring"
# effect = "NO_SCHEDULE"
# }
# }
# },
}
create_public_nlb = true
}
module "oidc" {
source = "git::https://github.com/camptocamp/devops-stack-module-oidc-aws-cognito.git?ref=v1.1.1"
# source = "../../devops-stack-module-oidc-aws-cognito"
cluster_name = module.eks.cluster_name
base_domain = module.eks.base_domain
subdomain = local.subdomain
create_pool = true
user_map = {
gheleno = {
username = "gheleno"
email = "goncalo.heleno@camptocamp.com"
first_name = "Gonçalo"
last_name = "Heleno"
}
}
}
module "argocd_bootstrap" {
source = "git::https://github.com/camptocamp/devops-stack-module-argocd.git//bootstrap?ref=v7.1.0"
# source = "../../devops-stack-module-argocd/bootstrap"
argocd_projects = {
"${module.eks.cluster_name}" = {
destination_cluster = "in-cluster"
}
}
depends_on = [module.eks]
}
module "metrics-server" {
source = "git::https://github.com/camptocamp/devops-stack-module-metrics-server.git?ref=v3.0.0"
# source = "../../devops-stack-module-metrics-server"
argocd_project = module.eks.cluster_name
app_autosync = local.app_autosync
dependency_ids = {
argocd = module.argocd_bootstrap.id
}
}
resource "dmsnitch_snitch" "alertmanager_deadmanssnitch_url" {
name = "${module.eks.cluster_name}-deadmansnitch"
interval = "30_minute"
tags = ["sandbox"]
alert_email = ["is-devops-stack-alert-aaaanyw3phgkla47zgvvbtydpy@camptocamp.slack.com"]
}
module "traefik" {
source = "git::https://github.com/camptocamp/devops-stack-module-traefik.git//eks?ref=v9.0.1"
# source = "../../devops-stack-module-traefik/eks"
argocd_project = module.eks.cluster_name
app_autosync = local.app_autosync
enable_service_monitor = local.enable_service_monitor
dependency_ids = {
argocd = module.argocd_bootstrap.id
}
}
module "cert-manager" {
source = "git::https://github.com/camptocamp/devops-stack-module-cert-manager.git//eks?ref=v10.0.0"
cluster_name = module.eks.cluster_name
base_domain = module.eks.base_domain
argocd_project = module.eks.cluster_name
letsencrypt_issuer_email = local.letsencrypt_issuer_email
app_autosync = local.app_autosync
enable_service_monitor = local.enable_service_monitor
cluster_oidc_issuer_url = module.eks.cluster_oidc_issuer_url
replicas = {
controller = 3
webhook = 2
}
dependency_ids = {
argocd = module.argocd_bootstrap.id
}
}
module "loki-stack" {
source = "git::https://github.com/camptocamp/devops-stack-module-loki-stack.git//eks?ref=v10.0.0"
# source = "../../devops-stack-module-loki-stack/eks"
argocd_project = module.eks.cluster_name
app_autosync = local.app_autosync
logs_storage = {
bucket_id = aws_s3_bucket.loki_logs_storage.id
create_role = true
cluster_oidc_issuer_url = module.eks.cluster_oidc_issuer_url
}
dependency_ids = {
argocd = module.argocd_bootstrap.id
ebs = module.ebs.id
}
}
module "thanos" {
source = "git::https://github.com/camptocamp/devops-stack-module-thanos.git//eks?ref=v7.0.1"
# source = "../../devops-stack-module-thanos/eks"
cluster_name = module.eks.cluster_name
base_domain = module.eks.base_domain
subdomain = local.subdomain
cluster_issuer = local.cluster_issuer
argocd_project = module.eks.cluster_name
app_autosync = local.app_autosync
enable_service_monitor = local.enable_service_monitor
thanos = {
oidc = module.oidc.oidc
}
metrics_storage = {
bucket_id = aws_s3_bucket.thanos_metrics_storage.id
create_role = true
cluster_oidc_issuer_url = module.eks.cluster_oidc_issuer_url
}
dependency_ids = {
argocd = module.argocd_bootstrap.id
ebs = module.ebs.id
traefik = module.traefik.id
cert-manager = module.cert-manager.id
oidc = module.oidc.id
}
}
module "kube-prometheus-stack" {
source = "git::https://github.com/camptocamp/devops-stack-module-kube-prometheus-stack.git//eks?ref=v13.0.1"
# source = "../../devops-stack-module-kube-prometheus-stack/eks"
cluster_name = module.eks.cluster_name
base_domain = module.eks.base_domain
subdomain = local.subdomain
cluster_issuer = local.cluster_issuer
argocd_project = module.eks.cluster_name
app_autosync = local.app_autosync
prometheus = {
oidc = module.oidc.oidc
}
grafana = {
oidc = module.oidc.oidc
}
alertmanager = {
oidc = module.oidc.oidc
}
metrics_storage = {
bucket_id = aws_s3_bucket.thanos_metrics_storage.id
create_role = true
cluster_oidc_issuer_url = module.eks.cluster_oidc_issuer_url
}
dependency_ids = {
argocd = module.argocd_bootstrap.id
ebs = module.ebs.id
traefik = module.traefik.id
cert-manager = module.cert-manager.id
oidc = module.oidc.id
thanos = module.thanos.id
loki-stack = module.loki-stack.id
}
}
module "argocd" {
source = "git::https://github.com/camptocamp/devops-stack-module-argocd.git?ref=v7.1.0"
# source = "../../devops-stack-module-argocd"
cluster_name = module.eks.cluster_name
base_domain = module.eks.base_domain
subdomain = local.subdomain
cluster_issuer = local.cluster_issuer
argocd_project = module.eks.cluster_name
accounts_pipeline_tokens = module.argocd_bootstrap.argocd_accounts_pipeline_tokens
server_secretkey = module.argocd_bootstrap.argocd_server_secretkey
app_autosync = local.app_autosync
high_availability = {
enabled = true
}
admin_enabled = false
exec_enabled = true
oidc = {
name = "Cognito"
issuer = module.oidc.oidc.issuer_url
clientID = module.oidc.oidc.client_id
clientSecret = module.oidc.oidc.client_secret
requestedIDTokenClaims = {
groups = {
essential = true
}
}
requestedScopes = [
"openid", "profile", "email"
]
}
rbac = {
policy_csv = <<-EOT
g, pipeline, role:admin
g, devops-stack-admins, role:admin
EOT
}
dependency_ids = {
argocd = module.argocd_bootstrap.id
traefik = module.traefik.id
cert-manager = module.cert-manager.id
oidc = module.oidc.id
kube-prometheus-stack = module.kube-prometheus-stack.id
}
}