Skip to content

Commit f9985c3

Browse files
chore: Dynamic tolerations (#55)
1 parent 9e56210 commit f9985c3

File tree

10 files changed

+111
-58
lines changed

10 files changed

+111
-58
lines changed

bootstrap/cell/main.tf

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@ locals {
66
dbsync_image = "ghcr.io/demeter-run/dbsync"
77
db_volume_claim = coalesce(var.db_volume_claim, "pvc-${var.salt}")
88
postgres_config_name = coalesce(var.postgres_config_name, "postgres-config-${var.salt}")
9+
default_tolerations = [
10+
{
11+
effect = "NoSchedule"
12+
key = "demeter.run/workload"
13+
operator = "Equal"
14+
value = "mem-intensive"
15+
},
16+
{
17+
effect = "NoSchedule"
18+
key = "demeter.run/compute-profile"
19+
operator = "Equal"
20+
value = "mem-intensive"
21+
},
22+
{
23+
effect = "NoSchedule"
24+
key = "demeter.run/compute-arch"
25+
operator = "Equal"
26+
value = "arm64"
27+
},
28+
{
29+
effect = "NoSchedule"
30+
key = "demeter.run/availability-sla"
31+
operator = "Equal"
32+
value = "consistent"
33+
}
34+
]
935
}
1036
module "dbsync_pvc" {
1137
source = "../pvc"
@@ -47,22 +73,18 @@ module "dbsync_instances" {
4773
source = "../instance"
4874
for_each = var.instances
4975

50-
namespace = var.namespace
51-
network = each.value.network
52-
salt = coalesce(each.value.salt, var.salt)
53-
dbsync_image = coalesce(each.value.dbsync_image, local.dbsync_image)
54-
dbsync_image_tag = each.value.dbsync_image_tag
55-
node_n2n_tcp_endpoint = each.value.node_n2n_tcp_endpoint
56-
release = each.value.release
57-
topology_zone = coalesce(each.value.topology_zone, var.topology_zone)
58-
sync_status = each.value.sync_status
59-
compute_arch = coalesce(each.value.compute_arch, "arm64")
60-
compute_profile = coalesce(each.value.compute_profile, "mem-intensive")
61-
availability_sla = coalesce(each.value.availability_sla, "consistent")
62-
empty_args = coalesce(each.value.empty_args, false)
63-
custom_config = coalesce(each.value.custom_config, true)
64-
network_env_var = coalesce(each.value.network_env_var, false)
65-
76+
namespace = var.namespace
77+
network = each.value.network
78+
salt = coalesce(each.value.salt, var.salt)
79+
dbsync_image = coalesce(each.value.dbsync_image, local.dbsync_image)
80+
dbsync_image_tag = each.value.dbsync_image_tag
81+
node_n2n_tcp_endpoint = each.value.node_n2n_tcp_endpoint
82+
release = each.value.release
83+
topology_zone = coalesce(each.value.topology_zone, var.topology_zone)
84+
sync_status = each.value.sync_status
85+
empty_args = coalesce(each.value.empty_args, false)
86+
custom_config = coalesce(each.value.custom_config, true)
87+
network_env_var = coalesce(each.value.network_env_var, false)
6688
enable_postgrest = each.value.enable_postgrest
6789
postgres_database = "dbsync-${each.value.network}"
6890
postgres_instance_name = local.postgres_host
@@ -82,4 +104,5 @@ module "dbsync_instances" {
82104
storage_class = "fast"
83105
size = "10Gi"
84106
})
107+
tolerations = coalesce(each.value.tolerations, local.default_tolerations)
85108
}

bootstrap/cell/variables.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ variable "instances" {
9494
release = string
9595
sync_status = string
9696
enable_postgrest = bool
97-
availability_sla = optional(string)
98-
compute_profile = optional(string)
99-
compute_arch = optional(string)
10097
topology_zone = optional(string)
10198
empty_args = optional(bool, false)
10299
custom_config = optional(bool, true)
@@ -109,6 +106,12 @@ variable "instances" {
109106
storage_class = string
110107
size = string
111108
}))
109+
tolerations = optional(list(object({
110+
effect = string
111+
key = string
112+
operator = string
113+
value = optional(string)
114+
})))
112115
}))
113116
}
114117

bootstrap/configs/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
kubernetes = {
4-
source = "hashicorp/kubernetes"
4+
source = "hashicorp/kubernetes"
55
}
66
}
77
}

bootstrap/configs/prime-testnet/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"ByronGenesisHash": "acd3e7c4cc071ae176fa253e654f0dd4e759892b16e958d8bd3c393f5c6c66d2",
77
"ShelleyGenesisHash": "0b67b0cb16e973478888efb1c7f69fca8e80489369afed94624a588e94a94f2b",
88
"AlonzoGenesisHash": "0f715ff78fcab739c6cb2cc1073eb87d0ffe3514218bfa0337d416f6fbaf7886",
9-
"ConwayGenesisHash": "d43d3f38e01848bddf67e66fe29fbd236aca252de58c7f2c1904c67107c17842",
9+
"ConwayGenesisHash": "47d7c396e8a58db4ae61dfbc1d47f9e9b786defb1d5b1a76c850a436e9017aff",
1010
"SocketPath": "db/node.socket",
1111
"ApplicationName":"cardano-sl",
1212
"ApplicationVersion":0,
@@ -108,4 +108,4 @@
108108
"TraceLedgerPeers": true,
109109
"TracePeerSelectionCounters": true,
110110
"TracePeerStateActions": true
111-
}
111+
}

bootstrap/configs/prime-testnet/db-sync-config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
]
1616
],
1717
"minSeverity":"Info",
18+
"insertOptions": {
19+
"offchainPoolData": "enable"
20+
},
1821
"options":{
1922
"cfokey":{
2023
"value":"Release-1.0.0"
2124
},
2225
"mapBackends":{
23-
26+
2427
},
2528
"mapSeverity":{
2629
"db-sync-node":"Info",

bootstrap/configs/vector-testnet/config.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"AlonzoGenesisFile": "/genesis/alonzo-genesis.json",
2+
"AlonzoGenesisFile": "/config/vector_testnet/alonzo-genesis.json",
33
"AlonzoGenesisHash": "694a30a4be097b10989dde200b273c52df0c4d2e2981cee3537bed7122302291",
4-
"ByronGenesisFile": "/genesis/byron-genesis.json",
4+
"ByronGenesisFile": "/config/vector_testnet/byron-genesis.json",
55
"ByronGenesisHash": "765ffc6574cd68ee743479e7cc2855d9f4066dda5d65fe56b9762e03d193ed0b",
6-
"ConwayGenesisFile": "/genesis/conway-genesis.json",
6+
"ConwayGenesisFile": "/config/vector_testnet/conway-genesis.json",
77
"ConwayGenesisHash": "2629ff28ff9539312851b626212dc45be41784c450ab396c0b1da40b2429b78e",
88
"EnableP2P": false,
99
"ExperimentalProtocolsEnabled": true,
@@ -12,7 +12,7 @@
1212
"LastKnownBlockVersion-Minor": 0,
1313
"Protocol": "Cardano",
1414
"RequiresNetworkMagic": "RequiresMagic",
15-
"ShelleyGenesisFile": "/genesis/shelley-genesis.json",
15+
"ShelleyGenesisFile": "/config/vector_testnet/shelley-genesis.json",
1616
"ShelleyGenesisHash": "8189bc6863f6ac448fca1e08c4e8ade54b05b7b0cfcd3b84a7932324ef782a98",
1717
"TargetNumberOfActivePeers": 20,
1818
"TargetNumberOfEstablishedPeers": 50,
@@ -74,7 +74,7 @@
7474
],
7575
"hasEKG": 12788,
7676
"hasPrometheus": [
77-
"0.0.0.0",
77+
"127.0.0.1",
7878
12798
7979
],
8080
"minSeverity": "Debug",
@@ -109,4 +109,4 @@
109109
"scRotation": null
110110
}
111111
]
112-
}
112+
}

bootstrap/configs/vector-testnet/db-sync-config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
"stdout"
3131
]
3232
],
33+
"insertOptions": {
34+
"offchainPoolData": "enable"
35+
},
3336
"options": {
3437
"cfokey": {
3538
"value": "Release-1.0.0"

bootstrap/instance/dbsync.tf

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -266,33 +266,15 @@ resource "kubernetes_deployment_v1" "db_sync" {
266266
}
267267
}
268268

269+
dynamic "toleration" {
270+
for_each = var.tolerations
269271

270-
toleration {
271-
key = "demeter.run/workload"
272-
operator = "Equal"
273-
value = "mem-intensive"
274-
effect = "NoSchedule"
275-
}
276-
277-
toleration {
278-
effect = "NoSchedule"
279-
key = "demeter.run/compute-profile"
280-
operator = "Equal"
281-
value = var.compute_profile
282-
}
283-
284-
toleration {
285-
effect = "NoSchedule"
286-
key = "demeter.run/compute-arch"
287-
operator = "Equal"
288-
value = var.compute_arch
289-
}
290-
291-
toleration {
292-
effect = "NoSchedule"
293-
key = "demeter.run/availability-sla"
294-
operator = "Equal"
295-
value = var.availability_sla
272+
content {
273+
effect = toleration.value.effect
274+
key = toleration.value.key
275+
operator = toleration.value.operator
276+
value = toleration.value.value
277+
}
296278
}
297279
}
298280
}

bootstrap/instance/main.tf

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ variable "namespace" {}
1010

1111

1212
variable "dbsync_image" {
13-
type = string
13+
type = string
1414
default = "ghcr.io/demeter-run/dbsync"
1515
}
1616
variable "dbsync_image_tag" {
@@ -113,6 +113,41 @@ variable "network_env_var" {
113113
default = false
114114
}
115115

116+
variable "tolerations" {
117+
type = list(object({
118+
effect = string
119+
key = string
120+
operator = string
121+
value = optional(string)
122+
}))
123+
default = [
124+
{
125+
key = "demeter.run/workload"
126+
operator = "Equal"
127+
value = "mem-intensive"
128+
effect = "NoSchedule"
129+
},
130+
{
131+
effect = "NoSchedule"
132+
key = "demeter.run/compute-profile"
133+
operator = "Equal"
134+
value = "mem-intensive"
135+
},
136+
{
137+
effect = "NoSchedule"
138+
key = "demeter.run/compute-arch"
139+
operator = "Equal"
140+
value = "arm64"
141+
},
142+
{
143+
effect = "NoSchedule"
144+
key = "demeter.run/availability-sla"
145+
operator = "Equal"
146+
value = "consistent"
147+
}
148+
]
149+
}
150+
116151
module "configs" {
117152
source = "../configs"
118153
network = var.network

bootstrap/variables.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ variable "cells" {
116116
release = string
117117
sync_status = string
118118
enable_postgrest = bool
119-
compute_arch = optional(string)
120-
compute_profile = optional(string)
121119
empty_args = optional(bool, false)
122120
custom_config = optional(bool, true)
123121
network_env_var = optional(string, false)
@@ -130,6 +128,12 @@ variable "cells" {
130128
storage_class = string
131129
size = string
132130
}))
131+
tolerations = optional(list(object({
132+
effect = string
133+
key = string
134+
operator = string
135+
value = optional(string)
136+
})))
133137
}))
134138
}))
135139
}

0 commit comments

Comments
 (0)