Skip to content

Commit fb4ec58

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

File tree

6 files changed

+109
-34
lines changed

6 files changed

+109
-34
lines changed

bootstrap/cell/main.tf

Lines changed: 8 additions & 5 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 = coalesce(var.postgres_tolerations, local.default_tolerations)
5659
}
5760

5861
module "dbsync_pgbouncer" {

bootstrap/cell/variables.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ variable "storage_size" {
2121
type = string
2222
}
2323

24+
variable "storage_class_name" {
25+
type = string
26+
}
27+
28+
variable "access_mode" {
29+
type = string
30+
}
31+
2432
variable "db_volume_claim" {
2533
type = string
2634
default = null
@@ -66,6 +74,35 @@ variable "postgres_config_name" {
6674
default = null
6775
}
6876

77+
variable "postgres_tolerations" {
78+
type = list(object({
79+
key = string
80+
operator = string
81+
value = string
82+
effect = string
83+
}))
84+
default = [
85+
{
86+
key = "demeter.run/compute-profile"
87+
operator = "Equal"
88+
value = "disk-intensive"
89+
effect = "NoSchedule"
90+
},
91+
{
92+
key = "demeter.run/compute-arch"
93+
operator = "Equal"
94+
value = "x86"
95+
effect = "NoSchedule"
96+
},
97+
{
98+
key = "demeter.run/availability-sla"
99+
operator = "Equal"
100+
value = "consistent"
101+
effect = "NoSchedule"
102+
}
103+
]
104+
}
105+
69106
// PGBouncer
70107
variable "pgbouncer_image_tag" {
71108
default = "1.21.0"

bootstrap/postgres/main.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,32 @@ variable "postgres_settings" {
7474
}
7575
}
7676

77+
variable "postgres_tolerations" {
78+
type = list(object({
79+
key = string
80+
operator = string
81+
value = string
82+
effect = string
83+
}))
84+
default = [
85+
{
86+
key = "demeter.run/compute-profile"
87+
operator = "Equal"
88+
value = "disk-intensive"
89+
effect = "NoSchedule"
90+
},
91+
{
92+
key = "demeter.run/compute-arch"
93+
operator = "Equal"
94+
value = "x86"
95+
effect = "NoSchedule"
96+
},
97+
{
98+
key = "demeter.run/availability-sla"
99+
operator = "Equal"
100+
value = "consistent"
101+
effect = "NoSchedule"
102+
}
103+
]
104+
}
105+

bootstrap/postgres/postgres.tf

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,14 @@ resource "kubernetes_stateful_set_v1" "postgres" {
149149
}
150150
}
151151

152-
toleration {
153-
effect = "NoSchedule"
154-
key = "demeter.run/compute-profile"
155-
operator = "Equal"
156-
value = "disk-intensive"
157-
}
158-
159-
toleration {
160-
effect = "NoSchedule"
161-
key = "demeter.run/compute-arch"
162-
operator = "Equal"
163-
value = "x86"
164-
}
165-
166-
toleration {
167-
effect = "NoSchedule"
168-
key = "demeter.run/availability-sla"
169-
operator = "Equal"
170-
value = "consistent"
152+
dynamic "toleration" {
153+
for_each = var.postgres_tolerations
154+
content {
155+
effect = toleration.value.effect
156+
key = toleration.value.key
157+
operator = toleration.value.operator
158+
value = toleration.value.value
159+
}
171160
}
172161
}
173162
}

bootstrap/pvc/main.tf

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
variable "namespace" {
2-
description = "the namespace where the resources will be created"
2+
description = "The namespace where the resources will be created."
33
}
44

55
variable "volume_name" {
6-
description = "the name of the volume"
6+
description = "The name of the volume. If not specified, the volume will be dynamically provisioned."
7+
type = string
8+
default = null
79
}
810

911
variable "name" {
10-
description = "the name of the pvc"
12+
description = "The name of the PersistentVolumeClaim (PVC)."
1113
}
1214

1315
variable "storage_size" {
14-
description = "the size of the volume"
16+
description = "The size of the volume."
17+
}
18+
19+
variable "storage_class_name" {
20+
description = "The name of the storage class to use."
21+
default = "nvme"
22+
}
23+
24+
variable "access_mode" {
25+
description = "The access mode for the volume."
26+
type = string
27+
default = "ReadWriteMany"
1528
}
1629

1730
resource "kubernetes_persistent_volume_claim" "shared_disk" {
@@ -23,13 +36,15 @@ resource "kubernetes_persistent_volume_claim" "shared_disk" {
2336
}
2437

2538
spec {
26-
access_modes = ["ReadWriteMany"]
39+
access_modes = [var.access_mode]
40+
2741
resources {
2842
requests = {
2943
storage = var.storage_size
3044
}
3145
}
32-
storage_class_name = "nvme"
33-
volume_name = var.volume_name
46+
47+
storage_class_name = var.storage_class_name
48+
volume_name = var.volume_name != null ? var.volume_name : null
3449
}
3550
}

bootstrap/variables.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ variable "pgbouncer_auth_user_password" {
8484
variable "cells" {
8585
type = map(object({
8686
pvc = object({
87-
volume_name = string
88-
storage_size = string
89-
name = optional(string)
87+
volume_name = string
88+
storage_size = string
89+
storage_class_name = string
90+
access_mode = string
91+
name = optional(string)
9092
})
9193
postgres = object({
9294
image_tag = string

0 commit comments

Comments
 (0)