Skip to content

Commit

Permalink
feat: add support for customization
Browse files Browse the repository at this point in the history
Signed-off-by: Ales Verbic <[email protected]>
  • Loading branch information
verbotenj committed Jan 21, 2025
1 parent 97744dc commit 182ea9b
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 37 deletions.
13 changes: 8 additions & 5 deletions bootstrap/cell/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ locals {
]
}
module "dbsync_pvc" {
source = "../pvc"
namespace = var.namespace
volume_name = var.volume_name
storage_size = var.storage_size
name = local.db_volume_claim
source = "../pvc"
namespace = var.namespace
access_mode = var.access_mode
volume_name = var.volume_name
storage_class_name = var.storage_class_name
storage_size = var.storage_size
name = local.db_volume_claim
}

module "dbsync_postgres" {
Expand All @@ -53,6 +55,7 @@ module "dbsync_postgres" {
postgres_secret_name = var.postgres_secret_name
postgres_resources = var.postgres_resources
is_blockfrost_backend = var.is_blockfrost_backend
postgres_tolerations = coalesce(var.postgres_tolerations, local.default_tolerations)
}

module "dbsync_pgbouncer" {
Expand Down
37 changes: 37 additions & 0 deletions bootstrap/cell/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ variable "storage_size" {
type = string
}

variable "storage_class_name" {
type = string
}

variable "access_mode" {
type = string
}

variable "db_volume_claim" {
type = string
default = null
Expand Down Expand Up @@ -66,6 +74,35 @@ variable "postgres_config_name" {
default = null
}

variable "postgres_tolerations" {
type = list(object({
key = string
operator = string
value = string
effect = string
}))
default = [
{
key = "demeter.run/compute-profile"
operator = "Equal"
value = "disk-intensive"
effect = "NoSchedule"
},
{
key = "demeter.run/compute-arch"
operator = "Equal"
value = "x86"
effect = "NoSchedule"
},
{
key = "demeter.run/availability-sla"
operator = "Equal"
value = "consistent"
effect = "NoSchedule"
}
]
}

// PGBouncer
variable "pgbouncer_image_tag" {
default = "1.21.0"
Expand Down
8 changes: 5 additions & 3 deletions bootstrap/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ module "dbsync_cells" {
salt = each.key

// PVC
volume_name = each.value.pvc.volume_name
storage_size = each.value.pvc.storage_size
db_volume_claim = each.value.pvc.name
access_mode = each.value.pvc.access_mode
db_volume_claim = each.value.pvc.name
storage_class_name = each.value.pvc.storage_class_name
storage_size = each.value.pvc.storage_size
volume_name = each.value.pvc.volume_name

// PG
topology_zone = each.value.postgres.topology_zone
Expand Down
29 changes: 29 additions & 0 deletions bootstrap/postgres/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,32 @@ variable "postgres_settings" {
}
}

variable "postgres_tolerations" {
type = list(object({
key = string
operator = string
value = string
effect = string
}))
default = [
{
key = "demeter.run/compute-profile"
operator = "Equal"
value = "disk-intensive"
effect = "NoSchedule"
},
{
key = "demeter.run/compute-arch"
operator = "Equal"
value = "x86"
effect = "NoSchedule"
},
{
key = "demeter.run/availability-sla"
operator = "Equal"
value = "consistent"
effect = "NoSchedule"
}
]
}

27 changes: 8 additions & 19 deletions bootstrap/postgres/postgres.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,14 @@ resource "kubernetes_stateful_set_v1" "postgres" {
}
}

toleration {
effect = "NoSchedule"
key = "demeter.run/compute-profile"
operator = "Equal"
value = "disk-intensive"
}

toleration {
effect = "NoSchedule"
key = "demeter.run/compute-arch"
operator = "Equal"
value = "x86"
}

toleration {
effect = "NoSchedule"
key = "demeter.run/availability-sla"
operator = "Equal"
value = "consistent"
dynamic "toleration" {
for_each = var.postgres_tolerations
content {
effect = toleration.value.effect
key = toleration.value.key
operator = toleration.value.operator
value = toleration.value.value
}
}
}
}
Expand Down
29 changes: 22 additions & 7 deletions bootstrap/pvc/main.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
variable "namespace" {
description = "the namespace where the resources will be created"
description = "The namespace where the resources will be created."
}

variable "volume_name" {
description = "the name of the volume"
description = "The name of the volume. If not specified, the volume will be dynamically provisioned."
type = string
default = null
}

variable "name" {
description = "the name of the pvc"
description = "The name of the PersistentVolumeClaim (PVC)."
}

variable "storage_size" {
description = "the size of the volume"
description = "The size of the volume."
}

variable "storage_class_name" {
description = "The name of the storage class to use."
default = "nvme"
}

variable "access_mode" {
description = "The access mode for the volume."
type = string
default = "ReadWriteMany"
}

resource "kubernetes_persistent_volume_claim" "shared_disk" {
Expand All @@ -23,13 +36,15 @@ resource "kubernetes_persistent_volume_claim" "shared_disk" {
}

spec {
access_modes = ["ReadWriteMany"]
access_modes = [var.access_mode]

resources {
requests = {
storage = var.storage_size
}
}
storage_class_name = "nvme"
volume_name = var.volume_name

storage_class_name = var.storage_class_name
volume_name = var.volume_name != null ? var.volume_name : null
}
}
8 changes: 5 additions & 3 deletions bootstrap/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ variable "pgbouncer_auth_user_password" {
variable "cells" {
type = map(object({
pvc = object({
volume_name = string
storage_size = string
name = optional(string)
volume_name = string
storage_size = string
storage_class_name = string
access_mode = string
name = optional(string)
})
postgres = object({
image_tag = string
Expand Down

0 comments on commit 182ea9b

Please sign in to comment.