-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathingress.tf
46 lines (41 loc) · 1.16 KB
/
ingress.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
resource "kubernetes_ingress" "ingress" {
for_each = {
for key, value in local.ports_map :
key => value
if length(lookup(value, "ingress", [])) > 0
}
metadata {
name = "${var.name}-${each.key}"
namespace = var.namespace
annotations = merge(
lookup(local.ingress_annotations, lookup(each.value, "default_ingress_annotations", "none")),
lookup(each.value, "cert_manager_issuer", "") == "" ? {} : { "cert-manager.io/issuer" = each.value["cert_manager_issuer"] },
lookup(each.value, "ingress_annotations", {})
)
}
spec {
dynamic "tls" {
for_each = lookup(each.value, "cert_manager_issuer", "") == "" ? [] : [
lookup(each.value, "cert_manager_issuer", "")]
content {
hosts = keys(each.value["ingress"])
secret_name = "${var.name}-${each.key}"
}
}
dynamic "rule" {
for_each = each.value["ingress"]
content {
host = rule.key
http {
path {
backend {
service_name = var.name
service_port = each.value["port"]
}
path = rule.value
}
}
}
}
}
}