-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
97 lines (90 loc) · 3.33 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
resource "helm_release" "this" {
count = 1 - local.argocd_enabled
depends_on = [
var.module_depends_on
]
name = local.name
repository = local.repository
chart = local.chart
version = local.version
namespace = local.namespace
timeout = 1200
dynamic "set" {
for_each = local.conf
content {
name = set.key
value = set.value
}
}
}
resource "local_file" "this" {
count = local.argocd_enabled
content = yamlencode(local.app)
filename = "${var.argocd.path}/${local.name}.yaml"
}
locals {
argocd_enabled = length(var.argocd) > 0 ? 1 : 0
namespace = var.namespace
name = var.internal ? "internal-nginx" : "ingress-nginx"
repository = "https://kubernetes.github.io/ingress-nginx"
chart = "ingress-nginx"
version = var.chart_version
app = {
"apiVersion" = "argoproj.io/v1alpha1"
"kind" = "Application"
"metadata" = {
"name" = local.name
"namespace" = var.argocd.namespace
}
"spec" = {
"destination" = {
"namespace" = local.namespace
"server" = "https://kubernetes.default.svc"
}
"project" = "default"
"source" = {
"repoURL" = local.repository
"targetRevision" = local.version
"chart" = local.chart
"helm" = {
"parameters" = values({
for key, value in local.conf :
key => {
"name" = key
"value" = tostring(value)
}
})
}
}
"syncPolicy" = {
"automated" = {
"prune" = true
"selfHeal" = true
}
}
"syncOptions" = {
"createNamespace" = true
}
}
}
conf = merge(local.conf_defaults, var.conf)
conf_defaults = merge(
var.aws_private ? {
"controller.service.internal.enabled" = true
"controller.service.annotations.service\\.beta\\.kubernetes\\.io/aws-load-balancer-internal" = "0.0.0.0"
} : {},
var.internal ? {
"controller.ingressClass" = "internal"
"controller.service.internal.enabled" = true
"controller.service.annotations.service\\.beta\\.kubernetes\\.io/aws-load-balancer-internal" = "0.0.0.0"
} : {},
{
"controller.service.annotations.service\\.beta\\.kubernetes\\.io/aws-load-balancer-type" = "nlb"
"controller.service.annotations.service\\.beta\\.kubernetes\\.io/aws-load-balancer-additional-resource-tags" = join(",", values({ for t in keys(var.tags) : t => "${t}=${var.tags[t]}" }))
"rbac.create" = true
"resources.limits.cpu" = "100m",
"resources.limits.memory" = "300Mi",
"resources.requests.cpu" = "100m",
"resources.requests.memory" = "300Mi",
})
}