From 54cdc0259ac7a35ec3b1a5f1541b75a67c5a5ab5 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sat, 7 Mar 2026 21:57:22 +0000 Subject: [PATCH] add iSCSI persistent volume for plotting-book SQLite database Create a 1Gi PVC using iscsi-truenas StorageClass, mount at /data, and set DB_PATH=/data/database.sqlite for persistent storage. --- stacks/plotting-book/main.tf | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/stacks/plotting-book/main.tf b/stacks/plotting-book/main.tf index 745f169e..a8bed72f 100644 --- a/stacks/plotting-book/main.tf +++ b/stacks/plotting-book/main.tf @@ -32,6 +32,22 @@ module "tls_secret" { tls_secret_name = var.tls_secret_name } +resource "kubernetes_persistent_volume_claim" "plotting-book-data" { + metadata { + name = "plotting-book-data" + namespace = kubernetes_namespace.plotting-book.metadata[0].name + } + spec { + access_modes = ["ReadWriteOnce"] + storage_class_name = "iscsi-truenas" + resources { + requests = { + storage = "1Gi" + } + } + } +} + resource "kubernetes_deployment" "plotting-book" { metadata { name = "plotting-book" @@ -60,6 +76,12 @@ resource "kubernetes_deployment" "plotting-book" { } } spec { + volume { + name = "data" + persistent_volume_claim { + claim_name = kubernetes_persistent_volume_claim.plotting-book-data.metadata[0].name + } + } container { image = "ancamilea/book-plotter:latest" # image = "viktorbarzin/book-plotter:7" @@ -81,6 +103,14 @@ resource "kubernetes_deployment" "plotting-book" { name = "GOOGLE_CALLBACK_URL" value = "https://plotting-book.viktorbarzin.me/api/auth/google/callback" } + env { + name = "DB_PATH" + value = "/data/database.sqlite" + } + volume_mount { + name = "data" + mount_path = "/data" + } port { container_port = 3001 }