-
Notifications
You must be signed in to change notification settings - Fork 12
/
router.tf
175 lines (149 loc) · 3.72 KB
/
router.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
resource "kubernetes_service" "router_cs" {
metadata {
name = "router-cs"
namespace = var.namespace
labels = local.router_labels
}
spec {
port {
name = "router"
port = 8888
}
selector = local.router_labels
}
}
resource "kubernetes_deployment" "router" {
metadata {
name = "router"
namespace = var.namespace
labels = local.router_labels
}
spec {
replicas = var.router_replicas
selector {
match_labels = local.router_labels
}
template {
metadata {
labels = local.router_labels
}
spec {
container {
name = "router"
image = local.druid_image
image_pull_policy = "Always"
port {
name = "router"
container_port = 8888
}
env_from {
config_map_ref {
name = "druid-common-config"
}
}
env_from {
secret_ref {
name = "druid-secret"
}
}
env {
name = "DRUID_HOST"
value_from {
field_ref {
field_path = "status.podIP"
}
}
}
dynamic "env" {
for_each = local.router_env_variables
content {
name = env.value.name
value = env.value.value
}
}
resources {
limits {
cpu = var.router_limits_cpu
memory = var.router_limits_memory
}
requests {
cpu = var.router_requests_cpu
memory = var.router_requests_memory
}
}
volume_mount {
name = "data"
mount_path = "/var/druid/"
}
liveness_probe {
http_get {
path = "/status/health"
port = "8888"
}
initial_delay_seconds = 60
}
readiness_probe {
http_get {
path = "/status/health"
port = "8888"
}
initial_delay_seconds = 60
}
security_context {
capabilities {
add = ["IPC_LOCK"]
}
}
}
volume {
name = "druid-secret"
secret {
secret_name = "druid-secret"
}
}
volume {
name = "data"
}
dynamic "toleration" {
for_each = [for t in var.router_tolerations : {
effect = t.effect
key = t.key
operator = t.operator
toleration_seconds = t.toleration_seconds
value = t.value
}]
content {
effect = toleration.value.effect
key = toleration.value.key
operator = toleration.value.operator
toleration_seconds = toleration.value.toleration_seconds
value = toleration.value.value
}
}
termination_grace_period_seconds = 1800
}
}
}
}
resource "kubernetes_ingress" "router" {
count = var.enable_router_ingress ? 1 : 0
metadata {
name = "router"
namespace = var.namespace
annotations = var.router_annotations_ingress
}
spec {
rule {
host = var.router_host
http {
path {
path = "/"
backend {
service_name = kubernetes_service.router_cs.metadata.0.name
service_port = kubernetes_service.router_cs.spec.0.port.0.port
}
}
}
}
}
}