-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path15_ingress.tf
73 lines (68 loc) · 1.9 KB
/
15_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
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
locals {
ingressPort = one(flatten([
for k, v in local.serviceClusterIpPorts : v.ingressEnabled ? [v] : []
]))
ingressEnabled = local.ingressPort != null ? local.serviceClusterIpEnabled : false
}
resource "kubernetes_ingress_v1" "ingress" {
for_each = local.ingressEnabled ? var.ingress : {}
metadata {
name = "${var.consistency.hard.namespaceUniqueName}-${each.key}"
namespace = var.consistency.hard.namespace
labels = var.consistency.soft.labels
annotations = each.value.annotations
}
spec {
ingress_class_name = each.value.ingressClassName
dynamic "rule" {
for_each = length(each.value.overridePaths) == 0 ? each.value.fqdns : []
content {
host = rule.value
http {
path {
backend {
service {
name = kubernetes_service_v1.clusterIp.0.metadata.0.name
port {
name = local.ingressPort.name
}
}
}
path = "/"
path_type = each.value.pathType
}
}
}
}
dynamic "rule" {
for_each = length(each.value.overridePaths) != 0 ? each.value.fqdns : []
content {
host = rule.value
http {
dynamic "path" {
for_each = each.value.overridePaths
content {
backend {
service {
name = kubernetes_service_v1.clusterIp.0.metadata.0.name
port {
name = local.ingressPort.name
}
}
}
path = path.value
path_type = each.value.pathType
}
}
}
}
}
dynamic "tls" {
for_each = each.value.tlsEnabled ? each.value.fqdns : []
content {
hosts = [tls.value]
secret_name = "tls-${tls.value}"
}
}
}
}