find a way by refactoring pvc

This commit is contained in:
2024-12-11 21:33:02 +00:00
parent 283d841739
commit 3458dd3dc6
2 changed files with 148 additions and 79 deletions
+12 -4
View File
@@ -13,11 +13,13 @@ variable "kubernetes" {
image = string image = string
pvc = optional(map(object({ pvc = optional(map(object({
name = string name = string
pvc = optional(bool)
configmap = optional(bool)
pvc_size = string pvc_size = string
mount_path = string mount_path = string
# database = optional(bool,false) # database = optional(bool,false)
}))) })))
secret = optional(map(string)) #secret = optional(map(string))
environment = optional(map(object({ environment = optional(map(object({
name = optional(string) name = optional(string)
value = optional(string) value = optional(string)
@@ -380,12 +382,18 @@ resource "kubernetes_deployment_v1" "automatic" {
dynamic "volume" { dynamic "volume" {
for_each = each.value.pvc != null ? each.value.pvc : {} for_each = each.value.pvc != null ? each.value.pvc : {}
content { content {
name = "${volume.value.name}-pvc" name = "${volume.value.name}-pvc"
persistent_volume_claim {
claim_name = "${volume.value.name}-pvc" dynamic "persistent_volume_claim" {
for_each = volume.value.pvc ? [1] : []
content {
claim_name = "${volume.value.name}-pvc"
}
} }
} }
} }
+136 -75
View File
@@ -26,85 +26,33 @@ kubernetes = {
namespace = "onitama" namespace = "onitama"
image = "ghcr.io/jackadamson/onitama:latest" image = "ghcr.io/jackadamson/onitama:latest"
service_port = 8080 service_port = 8080
redis = {
image = "hello"
}
database = {}
requirements = { requirements = {
limits-cpu = "50m" limits-cpu = "50m"
limits-memory = "50Mi" limits-memory = "50Mi"
requests-cpu = "25m" requests-cpu = "25m"
requests-memory = "25Mi" requests-memory = "25Mi"
} }
pvc = {
first = {
name = "nginx"
pvc = true
pvc_size = "1Mi"
mount_path = "/code"
}
}
# secret_ref = ["secret1", "secret2"]
environment = { environment = {
# MY_VAR = {
# value_from = {
# secret_key_ref = {
# name = "mysecret"
# key = "latest"
# }
# }
# }
POSTGRES_DB = {
value_from = {
secret_key_ref = {
name = "mysecret"
key = "POSTGRES_DB"
}
}
}
POSTGRES_USER = {
value_from = {
secret_key_ref = {
name = "mysecret"
key = "POSTGRES_USER"
}
}
}
POSTGRES_PASSWORD = {
value_from = {
secret_key_ref = {
name = "mysecret"
key = "POSTGRES_PASSWORD"
}
}
}
# POSTGRES_DB = {
# value = "db"
# }
# POSTGRES_USER = {
# value = "user"
# }
# POSTGRES_PASSWORD = {
# value = "password"
# }
PORT = { PORT = {
value = "80" value = "80"
} }
} }
pvc = {
onitamadeux = {
name = "onitamadeux"
pvc_size = "2Mi"
mount_path = "/deuxcode"
}
onitama = {
name = "onitama"
pvc_size = "1Mi"
mount_path = "/code"
}
# database = {
# name = "databaseonitama"
# pvc_size = "1Mi"
# mount_path = "/sql"
# database = true
# }
}
} }
nginx = { nginx = {
enabled = true enabled = false
namespace = "testnginx" namespace = "testnginx"
#image = "localhost:31795/django-python" #image = "localhost:31795/django-python"
image = "nginx:latest" image = "nginx:latest"
@@ -315,16 +263,19 @@ kubernetes = {
} }
paper = { paper = {
enabled = false enabled = true
namespace = "paper" namespace = "paper"
image = "ghcr.io/paperless-ngx/paperless-ngx:latest" image = "ghcr.io/paperless-ngx/paperless-ngx:latest"
service_port = 8000 service_port = 8000
database = {} database = {
image = "docker.io/library/postgres:15" }
redis = {
image = "docker.io/library/redis:7" }
requirements = { requirements = {
limits-cpu = "50m" limits-cpu = "800Mi"
limits-memory = "50Mi" limits-memory = "800Mi"
requests-cpu = "25m" requests-cpu = "800Mi"
requests-memory = "25Mi" requests-memory = "800Mi"
} }
environment = { environment = {
POSTGRES_DB = { POSTGRES_DB = {
@@ -358,39 +309,64 @@ kubernetes = {
value_from = { value_from = {
secret_key_ref = { secret_key_ref = {
name = "mysecret" name = "mysecret"
key = "POSTGRES_DB" key = "POSTGRES_HOST"
} }
} }
} }
PAPERLESS_REDIS = {
value = "redis://paper-redis-svc:6379"
}
PAPERLESS_ADMIN_USER = { PAPERLESS_ADMIN_USER = {
value = "admin" value_from = {
secret_key_ref = {
name = "mysecret"
key = "POSTGRES_USER"
}
}
} }
PAPERLESS_ADMIN_PASSWORD = { PAPERLESS_ADMIN_PASSWORD = {
value = "admin" value_from = {
secret_key_ref = {
name = "mysecret"
key = "POSTGRES_PASSWORD"
}
}
} }
# PAPERLESS_ADMIN_USER = {
# value = "admin"
# }
# PAPERLESS_ADMIN_PASSWORD = {
# value = "admin"
# }
PAPERLESS_OCR_USER_ARGS = { PAPERLESS_OCR_USER_ARGS = {
value = "{'invalidate_digital_signatures': true}" value = "{'invalidate_digital_signatures': true}"
} }
} }
pvc = { pvc = {
paperless-data = { paperless-data = {
pvc = true
name = "paperless-data" name = "paperless-data"
pvc_size = "2Mi" pvc_size = "2Mi"
mount_path = "/usr/src/paperless/data" mount_path = "/usr/src/paperless/data"
} }
media = { media = {
pvc = false
name = "media" name = "media"
pvc_size = "2Mi" pvc_size = "2Mi"
mount_path = "/usr/src/paperless/media" mount_path = "/usr/src/paperless/media"
} }
export = { export = {
pvc = true
name = "export" name = "export"
pvc_size = "2Mi" pvc_size = "2Mi"
mount_path = "/usr/src/paperless/export" mount_path = "/usr/src/paperless/export"
} }
consume = { consume = {
pvc = true
name = "consume" name = "consume"
pvc_size = "2Mi" pvc_size = "2Mi"
mount_path = "/usr/src/paperless/consume" mount_path = "/usr/src/paperless/consume"
@@ -400,6 +376,91 @@ kubernetes = {
#}
next = {
enabled = false
namespace = "next"
image = "nextcloud:29.0.3-apache"
service_port = 80
secret = {
POSTGRES_DB = "nextcloud"
POSTGRES_PASSWORD = "nextcloud"
POSTGRES_USER = "nextcloud"
PI_USER_USERNAME = "pi"
PI_USER_PASSWORD = "test"
POSTGRES_HOST = "next-db-svc"
}
database = {
image = "docker.io/library/postgres:14" }
redis = {
image = "docker.io/library/redis:7" }
requirements = {
limits-cpu = "800Mi"
limits-memory = "800Mi"
requests-cpu = "800Mi"
requests-memory = "800Mi"
}
environment = {
POSTGRES_DB = {
value_from = {
secret_key_ref = {
name = "nextcloud-credentials"
key = "POSTGRES_DB"
}
}
}
POSTGRES_USER = {
value_from = {
secret_key_ref = {
name = "nextcloud-credentials"
key = "POSTGRES_USER"
}
}
}
POSTGRES_PASSWORD = {
value_from = {
secret_key_ref = {
name = "nextcloud-credentials"
key = "POSTGRES_PASSWORD"
}
}
}
POSTGRES_HOST = {
value_from = {
secret_key_ref = {
name = "nextcloud-credentials"
key = "POSTGRES_HOST"
}
}
}
REDIS_HOST = {
value = "redis://next-redis-svc:6379"
}
NEXTCLOUD_ADMIN_USER = {
value = "admin"
}
NEXTCLOUD_ADMIN_PASSWORD = {
value_from = {
secret_key_ref = {
name = "nextcloud-credentials"
key = "PI_USER_PASSWORD"
}
}
}
}
pvc = {
nextcloud-webserver = {
name = "nextcloud-webserver"
pvc_size = "2Mi"
mount_path = "/var/www/html"
}
}
}
} }