forked from demeter-run/ext-cardano-ogmios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathogmios.tf
152 lines (134 loc) · 3.83 KB
/
ogmios.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
locals {
name = "ogmios-${var.network}-${var.ogmios_version}-${var.salt}"
image = var.ogmios_image
container_port = 1337
default_args = [
"--node-socket", "/ipc/node.socket",
"--node-config", "/config/config.json",
"--host", "0.0.0.0"
]
container_args = var.ogmios_version == "5" ? local.default_args : concat(local.default_args, ["--include-cbor"])
}
resource "kubernetes_deployment_v1" "ogmios" {
wait_for_rollout = false
metadata {
name = local.name
namespace = var.namespace
labels = {
"role" = "instance"
"demeter.run/kind" = "OgmiosInstance"
"cardano.demeter.run/network" = var.network
"cardano.demeter.run/ogmios-version" = var.ogmios_version
}
}
spec {
replicas = var.replicas
strategy {
rolling_update {
max_surge = 2
max_unavailable = 0
}
}
selector {
match_labels = {
"role" = "instance"
"demeter.run/instance" = local.name
"cardano.demeter.run/network" = var.network
"cardano.demeter.run/ogmios-version" = var.ogmios_version
}
}
template {
metadata {
name = local.name
labels = {
"role" = "instance"
"demeter.run/instance" = local.name
"cardano.demeter.run/network" = var.network
"cardano.demeter.run/ogmios-version" = var.ogmios_version
}
}
spec {
restart_policy = "Always"
security_context {
fs_group = 1000
}
container {
name = "main"
image = local.image
image_pull_policy = "IfNotPresent"
args = local.container_args
resources {
limits = {
cpu = var.resources.limits.cpu
memory = var.resources.limits.memory
}
requests = {
cpu = var.resources.requests.cpu
memory = var.resources.requests.memory
}
}
port {
container_port = local.container_port
name = "api"
protocol = "TCP"
}
volume_mount {
name = "ipc"
mount_path = "/ipc"
}
volume_mount {
name = "node-config"
mount_path = "/config"
}
liveness_probe {
http_get {
path = "/health"
port = "api"
scheme = "HTTP"
}
initial_delay_seconds = 60
period_seconds = 30
timeout_seconds = 5
success_threshold = 1
failure_threshold = 2
}
}
container {
name = "socat"
image = "alpine/socat"
args = [
"UNIX-LISTEN:/ipc/node.socket,reuseaddr,fork,unlink-early",
"TCP-CONNECT:${var.node_private_dns}"
]
security_context {
run_as_user = 1000
run_as_group = 1000
}
volume_mount {
name = "ipc"
mount_path = "/ipc"
}
}
volume {
name = "ipc"
empty_dir {}
}
volume {
name = "node-config"
config_map {
name = "configs-${var.network}"
}
}
dynamic "toleration" {
for_each = var.tolerations
content {
effect = toleration.value.effect
key = toleration.value.key
operator = toleration.value.operator
value = toleration.value.value
}
}
}
}
}
}