Skip to content

Commit 6a55641

Browse files
chore: Fix mumak after hardfork (#40)
* chore: Update indexers after hardfork * Fix configurations
1 parent beed720 commit 6a55641

File tree

7 files changed

+266
-49
lines changed

7 files changed

+266
-49
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[source]
2+
type = "N2C"
3+
socket_path = "/ipc/node.socket"
4+
5+
[intersect]
6+
type = "Origin"
7+
8+
[chain]
9+
type = "${network}"
10+
11+
[sink]
12+
type = "SqlDb"
13+
apply_template = "INSERT INTO blocks (slot, cbor) VALUES ('{{point.slot}}', decode('{{record.hex}}', 'hex'));"
14+
undo_template = "DELETE FROM blocks WHERE slot = {{point.slot}}"
15+
reset_template = "DELETE FROM blocks WHERE slot > {{#if point.slot}}{{point.slot}}{{else}}-1{{/if}};"
16+
17+
[cursor]
18+
type = "File"
19+
path = "/data/cursor"
20+
21+
[policy]
22+
missing_data = "Skip"
23+
cbor_errors = "Warn"
24+
25+
[metrics]
26+
address = "0.0.0.0:9186"
27+
endpoint = "/metrics"

bootstrap/indexer/block_indexer.tf

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
resource "kubernetes_stateful_set_v1" "block_indexer" {
2+
wait_for_rollout = false
3+
4+
metadata {
5+
name = local.block_instance_name
6+
namespace = var.namespace
7+
labels = {
8+
"role" = "BlockIndexer"
9+
"demeter.run/kind" = "MumakBlockIndexer"
10+
"cardano.demeter.run/network" = var.network
11+
}
12+
}
13+
14+
15+
spec {
16+
replicas = 1
17+
service_name = "mumak-block-indexer"
18+
19+
selector {
20+
match_labels = {
21+
"role" = "BlockIndexer"
22+
"demeter.run/instance" = local.block_instance_name
23+
"cardano.demeter.run/network" = var.network
24+
}
25+
}
26+
27+
volume_claim_template {
28+
metadata {
29+
name = "data"
30+
namespace = var.namespace
31+
labels = {
32+
"demeter.run/instance" = local.block_instance_name
33+
}
34+
}
35+
spec {
36+
access_modes = ["ReadWriteOnce"]
37+
38+
resources {
39+
requests = {
40+
storage = "1Gi"
41+
}
42+
}
43+
storage_class_name = "gp3"
44+
}
45+
}
46+
47+
template {
48+
49+
metadata {
50+
name = local.block_instance_name
51+
labels = {
52+
"role" = "BlockIndexer"
53+
"demeter.run/instance" = local.block_instance_name
54+
"cardano.demeter.run/network" = var.network
55+
}
56+
}
57+
58+
spec {
59+
restart_policy = "Always"
60+
61+
security_context {
62+
fs_group = 1000
63+
}
64+
65+
container {
66+
name = "indexer"
67+
image = "${var.image}:${var.image_tag}"
68+
args = ["daemon", "--config", "/etc/oura/daemon.toml"]
69+
image_pull_policy = "IfNotPresent"
70+
71+
resources {
72+
limits = {
73+
cpu = var.resources.limits.cpu
74+
memory = var.resources.limits.memory
75+
}
76+
requests = {
77+
cpu = var.resources.requests.cpu
78+
memory = var.resources.requests.memory
79+
}
80+
}
81+
82+
env {
83+
name = "RUST_LOG"
84+
value = "debug"
85+
}
86+
87+
env {
88+
name = "POSTGRES_PASSWORD"
89+
value_from {
90+
secret_key_ref {
91+
name = var.postgres_secret_name
92+
key = "password"
93+
}
94+
}
95+
}
96+
97+
env {
98+
name = "OURA_SINK_CONNECTION"
99+
value = "postgres://postgres:$(POSTGRES_PASSWORD)@${var.postgres_host}:5432/${var.db}"
100+
}
101+
102+
port {
103+
container_port = 9186
104+
name = "metrics"
105+
}
106+
107+
volume_mount {
108+
name = "ipc"
109+
mount_path = "/ipc"
110+
}
111+
112+
volume_mount {
113+
name = "configs"
114+
mount_path = "/etc/oura"
115+
}
116+
117+
volume_mount {
118+
name = "data"
119+
mount_path = "/data"
120+
}
121+
}
122+
123+
container {
124+
name = "socat"
125+
image = "alpine/socat"
126+
args = [
127+
"UNIX-LISTEN:/ipc/node.socket,reuseaddr,fork,unlink-early",
128+
"TCP-CONNECT:${var.node_private_dns}"
129+
]
130+
131+
security_context {
132+
run_as_user = 1000
133+
run_as_group = 1000
134+
}
135+
136+
volume_mount {
137+
name = "ipc"
138+
mount_path = "/ipc"
139+
}
140+
}
141+
142+
volume {
143+
name = "ipc"
144+
empty_dir {}
145+
}
146+
147+
volume {
148+
name = "configs"
149+
config_map {
150+
name = local.block_configmap_name
151+
}
152+
}
153+
154+
toleration {
155+
effect = "NoSchedule"
156+
key = "demeter.run/compute-profile"
157+
operator = "Equal"
158+
value = "general-purpose"
159+
}
160+
161+
toleration {
162+
effect = "NoSchedule"
163+
key = "demeter.run/compute-arch"
164+
operator = "Equal"
165+
value = "x86"
166+
}
167+
168+
toleration {
169+
effect = "NoSchedule"
170+
key = "demeter.run/availability-sla"
171+
operator = "Equal"
172+
value = "consistent"
173+
}
174+
}
175+
}
176+
}
177+
}
178+

bootstrap/indexer/config.tf

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
resource "kubernetes_config_map" "config" {
1+
resource "kubernetes_config_map" "block_config" {
22
metadata {
33
namespace = var.namespace
4-
name = local.configmap_name
4+
name = local.block_configmap_name
55
}
66

77
data = {
8-
"daemon.toml" = "${templatefile("${path.module}/daemon.toml.tftpl", { network = var.network })}"
8+
"daemon.toml" = "${templatefile("${path.module}/block.daemon.toml.tftpl", { network = var.network })}"
9+
}
10+
}
11+
12+
resource "kubernetes_config_map" "tx_config" {
13+
metadata {
14+
namespace = var.namespace
15+
name = local.tx_configmap_name
16+
}
17+
18+
data = {
19+
"daemon.toml" = "${templatefile("${path.module}/tx.daemon.toml.tftpl", { network = var.network })}"
920
}
1021
}

bootstrap/indexer/daemon.toml.tftpl

Lines changed: 0 additions & 33 deletions
This file was deleted.

bootstrap/indexer/main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
locals {
2-
configmap_name = "oura-config-${var.instance_name}"
2+
block_configmap_name = "oura-config-${var.instance_name}-blocks"
3+
tx_configmap_name = "oura-config-${var.instance_name}-txs"
4+
5+
block_instance_name = "${var.instance_name}-block"
6+
tx_instance_name = "${var.instance_name}-tx"
37
}
48

59
variable "namespace" {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[source]
2+
type = "N2C"
3+
socket_path = "/ipc/node.socket"
4+
5+
[intersect]
6+
type = "Origin"
7+
8+
[chain]
9+
type = "${network}"
10+
11+
[[filters]]
12+
type = "SplitBlock"
13+
14+
[sink]
15+
type = "SqlDb"
16+
apply_template = "INSERT INTO txs (slot, cbor) VALUES ('{{point.slot}}', decode('{{record.hex}}', 'hex'));"
17+
undo_template = "DELETE FROM txs WHERE slot = {{point.slot}}"
18+
reset_template = "DELETE FROM txs WHERE slot > {{#if point.slot}}{{point.slot}}{{else}}-1{{/if}};"
19+
20+
[cursor]
21+
type = "File"
22+
path = "/data/cursor"
23+
24+
[policy]
25+
missing_data = "Skip"
26+
cbor_errors = "Warn"
27+
28+
[metrics]
29+
address = "0.0.0.0:9186"
30+
endpoint = "/metrics"

bootstrap/indexer/indexer.tf renamed to bootstrap/indexer/tx_indexer.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
resource "kubernetes_stateful_set_v1" "indexer" {
1+
resource "kubernetes_stateful_set_v1" "tx_indexer" {
22
wait_for_rollout = false
33

44
metadata {
5-
name = var.instance_name
5+
name = local.tx_instance_name
66
namespace = var.namespace
77
labels = {
8-
"role" = "indexer"
9-
"demeter.run/kind" = "MumakIndexer"
8+
"role" = "TxIndexer"
9+
"demeter.run/kind" = "MumakTxIndexer"
1010
"cardano.demeter.run/network" = var.network
1111
}
1212
}
1313

1414

1515
spec {
1616
replicas = 1
17-
service_name = "mumak-indexer"
17+
service_name = "mumak-tx-indexer"
1818

1919
selector {
2020
match_labels = {
21-
"role" = "indexer"
22-
"demeter.run/instance" = var.instance_name
21+
"role" = "TxIndexer"
22+
"demeter.run/instance" = local.tx_instance_name
2323
"cardano.demeter.run/network" = var.network
2424
}
2525
}
@@ -29,7 +29,7 @@ resource "kubernetes_stateful_set_v1" "indexer" {
2929
name = "data"
3030
namespace = var.namespace
3131
labels = {
32-
"demeter.run/instance" = var.instance_name
32+
"demeter.run/instance" = local.tx_instance_name
3333
}
3434
}
3535
spec {
@@ -47,10 +47,10 @@ resource "kubernetes_stateful_set_v1" "indexer" {
4747
template {
4848

4949
metadata {
50-
name = var.instance_name
50+
name = local.tx_instance_name
5151
labels = {
52-
"role" = "indexer"
53-
"demeter.run/instance" = var.instance_name
52+
"role" = "TxIndexer"
53+
"demeter.run/instance" = local.tx_instance_name
5454
"cardano.demeter.run/network" = var.network
5555
}
5656
}
@@ -147,7 +147,7 @@ resource "kubernetes_stateful_set_v1" "indexer" {
147147
volume {
148148
name = "configs"
149149
config_map {
150-
name = local.configmap_name
150+
name = local.tx_configmap_name
151151
}
152152
}
153153

0 commit comments

Comments
 (0)