Skip to content

Commit b814882

Browse files
committed
feat: add support for customization
Signed-off-by: Ales Verbic <[email protected]>
1 parent 89743f8 commit b814882

File tree

15 files changed

+325
-130
lines changed

15 files changed

+325
-130
lines changed

bootstrap/cell/main.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ locals {
3434
]
3535
}
3636
module "dbsync_pvc" {
37-
source = "../pvc"
38-
namespace = var.namespace
39-
volume_name = var.volume_name
40-
storage_size = var.storage_size
41-
name = local.db_volume_claim
37+
source = "../pvc"
38+
namespace = var.namespace
39+
access_mode = var.access_mode
40+
volume_name = var.volume_name
41+
storage_class_name = var.storage_class_name
42+
storage_size = var.storage_size
43+
name = local.db_volume_claim
4244
}
4345

4446
module "dbsync_postgres" {
@@ -53,6 +55,7 @@ module "dbsync_postgres" {
5355
postgres_secret_name = var.postgres_secret_name
5456
postgres_resources = var.postgres_resources
5557
is_blockfrost_backend = var.is_blockfrost_backend
58+
postgres_tolerations = var.postgres_tolerations
5659
}
5760

5861
module "dbsync_pgbouncer" {
@@ -67,6 +70,7 @@ module "dbsync_pgbouncer" {
6770
instance_name = "postgres-dbsync-v3-${var.salt}"
6871
postgres_instance_name = local.postgres_host
6972
pgbouncer_reloader_image_tag = var.pgbouncer_reloader_image_tag
73+
pgbouncer_tolerations = var.pgbouncer_tolerations
7074
}
7175

7276
module "dbsync_instances" {
@@ -82,9 +86,7 @@ module "dbsync_instances" {
8286
release = each.value.release
8387
topology_zone = coalesce(each.value.topology_zone, var.topology_zone)
8488
sync_status = each.value.sync_status
85-
empty_args = coalesce(each.value.empty_args, false)
8689
custom_config = coalesce(each.value.custom_config, true)
87-
network_env_var = coalesce(each.value.network_env_var, false)
8890
enable_postgrest = each.value.enable_postgrest
8991
postgres_database = "dbsync-${each.value.network}"
9092
postgres_instance_name = local.postgres_host

bootstrap/cell/variables.tf

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ variable "salt" {
77
description = "Salt used to identify all components as part of the cell. Should be unique between cells."
88
}
99

10-
variable "certs_secret_name" {
11-
type = string
12-
default = "pgbouncer-certs"
13-
}
14-
1510
// PVC
1611
variable "volume_name" {
1712
type = string
@@ -21,6 +16,14 @@ variable "storage_size" {
2116
type = string
2217
}
2318

19+
variable "storage_class_name" {
20+
type = string
21+
}
22+
23+
variable "access_mode" {
24+
type = string
25+
}
26+
2427
variable "db_volume_claim" {
2528
type = string
2629
default = null
@@ -66,11 +69,54 @@ variable "postgres_config_name" {
6669
default = null
6770
}
6871

72+
variable "postgres_tolerations" {
73+
type = list(object({
74+
key = string
75+
operator = string
76+
value = string
77+
effect = string
78+
}))
79+
default = [
80+
{
81+
key = "demeter.run/compute-profile"
82+
operator = "Equal"
83+
value = "disk-intensive"
84+
effect = "NoSchedule"
85+
},
86+
{
87+
key = "demeter.run/compute-arch"
88+
operator = "Equal"
89+
value = "x86"
90+
effect = "NoSchedule"
91+
},
92+
{
93+
key = "demeter.run/availability-sla"
94+
operator = "Equal"
95+
value = "consistent"
96+
effect = "NoSchedule"
97+
}
98+
]
99+
}
100+
69101
// PGBouncer
102+
103+
variable "certs_secret_name" {
104+
type = string
105+
default = "pgbouncer-certs"
106+
}
107+
108+
variable "pgbouncer_cloud_provider" {
109+
type = string
110+
}
111+
70112
variable "pgbouncer_image_tag" {
71113
default = "1.21.0"
72114
}
73115

116+
variable "pgbouncer_load_balancer" {
117+
type = bool
118+
}
119+
74120
variable "pgbouncer_replicas" {
75121
default = 1
76122
}
@@ -83,6 +129,34 @@ variable "pgbouncer_reloader_image_tag" {
83129
type = string
84130
}
85131

132+
variable "pgbouncer_tolerations" {
133+
type = list(object({
134+
effect = string
135+
key = string
136+
operator = string
137+
value = optional(string)
138+
}))
139+
default = [
140+
{
141+
effect = "NoSchedule"
142+
key = "demeter.run/compute-profile"
143+
operator = "Exists"
144+
},
145+
{
146+
effect = "NoSchedule"
147+
key = "demeter.run/compute-arch"
148+
operator = "Equal"
149+
value = "x86"
150+
},
151+
{
152+
effect = "NoSchedule"
153+
key = "demeter.run/availability-sla"
154+
operator = "Equal"
155+
value = "best-effort"
156+
}
157+
]
158+
}
159+
86160
// Instance
87161
variable "instances" {
88162
type = map(object({
@@ -94,10 +168,9 @@ variable "instances" {
94168
release = string
95169
sync_status = string
96170
enable_postgrest = bool
97-
topology_zone = optional(string)
98-
empty_args = optional(bool, false)
171+
args = optional(list(string), [])
99172
custom_config = optional(bool, true)
100-
network_env_var = optional(string, false)
173+
topology_zone = optional(string)
101174
dbsync_resources = optional(object({
102175
requests = map(string)
103176
limits = map(string)
@@ -114,4 +187,3 @@ variable "instances" {
114187
})))
115188
}))
116189
}
117-

bootstrap/configs/preview/config.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"AlonzoGenesisFile": "/genesis/preview/alonzo-genesis.json",
2+
"AlonzoGenesisFile": "/opt/cardano/config/preview/alonzo-genesis.json",
33
"AlonzoGenesisHash": "7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874",
44
"ApplicationName": "cardano-sl",
55
"ApplicationVersion": 0,
6-
"ByronGenesisFile": "/genesis/preview/byron-genesis.json",
6+
"ByronGenesisFile": "/opt/cardano/config/preview/byron-genesis.json",
77
"ByronGenesisHash": "83de1d7302569ad56cf9139a41e2e11346d4cb4a31c00142557b6ab3fa550761",
8-
"ConwayGenesisFile": "/genesis/preview/conway-genesis.json",
9-
"ConwayGenesisHash": "f28f1c1280ea0d32f8cd3143e268650d6c1a8e221522ce4a7d20d62fc09783e1",
8+
"ConwayGenesisFile": "/opt/cardano/config/preview/conway-genesis.json",
9+
"ConwayGenesisHash": "9cc5084f02e27210eacba47af0872e3dba8946ad9460b6072d793e1d2f3987ef",
1010
"EnableP2P": true,
1111
"ExperimentalHardForksEnabled": false,
1212
"ExperimentalProtocolsEnabled": false,
@@ -15,7 +15,7 @@
1515
"LastKnownBlockVersion-Minor": 1,
1616
"Protocol": "Cardano",
1717
"RequiresNetworkMagic": "RequiresMagic",
18-
"ShelleyGenesisFile": "/genesis/preview/shelley-genesis.json",
18+
"ShelleyGenesisFile": "/opt/cardano/config/preview/shelley-genesis.json",
1919
"ShelleyGenesisHash": "363498d1024f84bb39d3fa9593ce391483cb40d479b87233f868d6e57c3a400d",
2020
"TargetNumberOfActivePeers": 20,
2121
"TargetNumberOfEstablishedPeers": 50,
@@ -110,4 +110,4 @@
110110
"scRotation": null
111111
}
112112
]
113-
}
113+
}

bootstrap/instance/dbsync.tf

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,7 @@ resource "kubernetes_deployment_v1" "db_sync" {
152152
requests = var.dbsync_resources.requests
153153
}
154154

155-
args = var.empty_args ? [] : [
156-
"--config /etc/dbsync/db-sync-config.json",
157-
"--socket-path /node-ipc/node.socket",
158-
]
155+
args = var.args
159156

160157
env {
161158
name = "POSTGRES_USER"
@@ -194,7 +191,7 @@ resource "kubernetes_deployment_v1" "db_sync" {
194191

195192
env {
196193
name = "NETWORK"
197-
value = var.network_env_var ? var.network : ""
194+
value = var.network
198195
}
199196

200197
dynamic "env" {

bootstrap/instance/main.tf

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ terraform {
88

99
variable "namespace" {}
1010

11-
1211
variable "dbsync_image" {
1312
type = string
1413
default = "ghcr.io/demeter-run/dbsync"
@@ -17,7 +16,9 @@ variable "dbsync_image_tag" {
1716
default = "132ffd0007054bfadd17b23ed608529447833b99"
1817
}
1918

20-
variable "network" {}
19+
variable "network" {
20+
type = string
21+
}
2122

2223
variable "salt" {
2324
type = string
@@ -101,18 +102,15 @@ variable "availability_sla" {
101102
default = "consistent"
102103
}
103104

104-
variable "empty_args" {
105-
default = false
105+
variable "args" {
106+
type = list(string)
107+
default = []
106108
}
107109

108110
variable "custom_config" {
109111
default = true
110112
}
111113

112-
variable "network_env_var" {
113-
default = false
114-
}
115-
116114
variable "tolerations" {
117115
type = list(object({
118116
effect = string

bootstrap/main.tf

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ module "dbsync_feature" {
2323

2424
// Service
2525
module "dbsync_service" {
26-
depends_on = [kubernetes_namespace.namespace]
27-
source = "./service"
28-
29-
namespace = var.namespace
26+
depends_on = [kubernetes_namespace.namespace]
27+
source = "./service"
28+
cloud_provider = var.cloud_provider
29+
namespace = var.namespace
3030
}
3131

3232
// Cells
@@ -39,9 +39,11 @@ module "dbsync_cells" {
3939
salt = each.key
4040

4141
// PVC
42-
volume_name = each.value.pvc.volume_name
43-
storage_size = each.value.pvc.storage_size
44-
db_volume_claim = each.value.pvc.name
42+
access_mode = each.value.pvc.access_mode
43+
db_volume_claim = each.value.pvc.name
44+
storage_class_name = each.value.pvc.storage_class_name
45+
storage_size = each.value.pvc.storage_size
46+
volume_name = each.value.pvc.volume_name
4547

4648
// PG
4749
topology_zone = each.value.postgres.topology_zone
@@ -50,12 +52,17 @@ module "dbsync_cells" {
5052
postgres_secret_name = var.postgres_secret_name
5153
postgres_resources = each.value.postgres.resources
5254
postgres_config_name = each.value.postgres.config_name
55+
postgres_tolerations = each.value.postgres.tolerations
5356

5457
// PGBouncer
58+
certs_secret_name = each.value.pgbouncer.certs_secret_name
59+
pgbouncer_cloud_provider = var.cloud_provider
5560
pgbouncer_image_tag = var.pgbouncer_image_tag
61+
pgbouncer_load_balancer = each.value.pgbouncer.load_balancer
5662
pgbouncer_replicas = each.value.pgbouncer.replicas
5763
pgbouncer_auth_user_password = var.pgbouncer_auth_user_password
5864
pgbouncer_reloader_image_tag = var.pgbouncer_reloader_image_tag
65+
pgbouncer_tolerations = each.value.pgbouncer.tolerations
5966

6067
// Instances
6168
instances = each.value.instances

bootstrap/pgbouncer/cert.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
locals {
2+
dns_names = flatten(["*.${var.dns_zone}"])
3+
}
4+
5+
resource "kubernetes_manifest" "certificate_cluster_wildcard_tls" {
6+
manifest = {
7+
"apiVersion" = "cert-manager.io/v1"
8+
"kind" = "Certificate"
9+
"metadata" = {
10+
"name" = var.certs_secret_name
11+
"namespace" = var.namespace
12+
}
13+
"spec" = {
14+
"dnsNames" = local.dns_names
15+
16+
"issuerRef" = {
17+
"kind" = "ClusterIssuer"
18+
"name" = var.cluster_issuer
19+
}
20+
"secretName" = var.certs_secret_name
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)