diff --git a/bootstrap/daemon/main.tf b/bootstrap/daemon/main.tf index bf1b10c..a8a5164 100644 --- a/bootstrap/daemon/main.tf +++ b/bootstrap/daemon/main.tf @@ -109,6 +109,10 @@ variable "resources" { cpu = string memory = string }) + storage = object({ + size = string + class = string + }) }) default = { requests = { @@ -119,5 +123,9 @@ variable "resources" { cpu = "500m" memory = "500Mi" } + storage = { + size = "10Gi" + class = "fast" + } } } diff --git a/bootstrap/daemon/deployment.tf b/bootstrap/daemon/sts.tf similarity index 71% rename from bootstrap/daemon/deployment.tf rename to bootstrap/daemon/sts.tf index 86fe718..3110d2b 100644 --- a/bootstrap/daemon/deployment.tf +++ b/bootstrap/daemon/sts.tf @@ -2,7 +2,7 @@ locals { role = "fabric-daemon" } -resource "kubernetes_deployment_v1" "daemon" { +resource "kubernetes_stateful_set_v1" "daemon" { wait_for_rollout = false metadata { @@ -14,7 +14,23 @@ resource "kubernetes_deployment_v1" "daemon" { } spec { - replicas = var.replicas + replicas = var.replicas + service_name = "fabric-daemon" + + volume_claim_template { + metadata { + name = "cache" + } + spec { + access_modes = ["ReadWriteOnce"] + resources { + requests = { + storage = var.resources.storage.size + } + } + storage_class_name = var.resources.storage.class + } + } selector { match_labels = { @@ -39,13 +55,14 @@ resource "kubernetes_deployment_v1" "daemon" { value = "/fabric/daemon.toml" } - port { - container_port = local.port + volume_mount { + name = "cache" + mount_path = "/var/cache" } volume_mount { name = "config" - mount_path = "/fabric" + mount_path = "/fabric/config" } resources {