-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.tf
131 lines (108 loc) · 3.38 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
resource "time_static" "cert_create_time" {}
# create namespaces for linkerd and any extensions (linkerd-viz or linkerd-jaeger)
resource "kubernetes_namespace" "namespace" {
for_each = toset(local.namespaces)
metadata {
name = each.key
annotations = { "linkerd.io/inject" = "disabled" }
labels = {
"linkerd.io/extension" = trimprefix(each.key, "linkerd-")
"linkerd.io/is-control-plane" = "true"
"linkerd.io/control-plane-ns" = each.key
"config.linkerd.io/admission-webhooks" = "disabled"
}
}
}
resource "helm_release" "crds" {
name = "linkerd"
chart = "linkerd-crds"
namespace = var.chart_namespace
repository = "https://helm.linkerd.io/edge"
version = "1.4.0"
timeout = var.chart_timeout
atomic = var.atomic
create_namespace = false
devel = true
depends_on = [kubernetes_namespace.namespace]
}
module "issuer" {
source = "./modules/issuer"
namespace = var.chart_namespace
extensions = var.extensions
trust_anchor_validity_hours = var.trust_anchor_validity_hours
issuer_validity_hours = var.issuer_validity_hours
ca_cert_expiration_hours = var.ca_cert_expiration_hours
depends_on = [helm_release.crds]
}
resource "helm_release" "cni" {
depends_on = [kubernetes_namespace.namespace]
count = var.cni_enabled ? 1 : 0
name = "linkerd-cni"
namespace = "linkerd-cni"
chart = "linkerd2-cni"
repository = var.chart_repository
timeout = var.chart_timeout
atomic = var.atomic
create_namespace = true
devel = true
}
resource "helm_release" "control_plane" {
name = "linkerd-control-plane"
chart = "linkerd-control-plane"
namespace = var.chart_namespace
create_namespace = false
repository = "https://helm.linkerd.io/edge"
version = "1.9.3-edge"
timeout = var.chart_timeout
atomic = var.atomic
devel = true
set_sensitive {
name = "identityTrustAnchorsPEM"
value = module.issuer.cert_pem.root
}
dynamic "set_sensitive" {
for_each = toset(local.components.linkerd)
content {
name = "${set_sensitive.key}.caBundle"
value = module.issuer.cert_pem.webhook
}
}
dynamic "set" {
for_each = toset(local.components.linkerd)
content {
name = "${set.key}.externalSecret"
value = true
}
}
values = concat(
var.ha_enabled ? [file("${path.module}/templates/control-plane-ha.yaml")] : [],
[yamlencode(local.linkerd), var.additional_yaml_config]
)
depends_on = [helm_release.cni, module.issuer]
}
resource "helm_release" "extension" {
for_each = var.extensions
name = "linkerd-${each.key}"
chart = "linkerd-${each.key}"
namespace = "linkerd-${each.key}"
repository = var.chart_repository
timeout = var.chart_timeout
atomic = var.atomic
devel = true
dynamic "set_sensitive" {
for_each = toset(local.components[each.key])
content {
name = "${set_sensitive.key}.caBundle"
value = module.issuer.cert_pem.webhook
}
}
dynamic "set" {
for_each = toset(local.components[each.key])
content {
name = "${set.key}.externalSecret"
value = true
}
}
values = lookup(local.extension_values, each.key, [])
depends_on = [helm_release.control_plane]
}