change the variable type to make it automatic with the image name

This commit is contained in:
2024-12-04 09:22:55 +00:00
parent 27e1ed922a
commit 5baf51a9f2
2 changed files with 104 additions and 10 deletions
+9 -5
View File
@@ -35,9 +35,11 @@ variable "kubernetes" {
liveness_tcp_socket = optional(number)
liveness_http_get = optional(string)
liveness_http_get_path = optional(string)
database = optional(map(object({
image = optional(string)
})))
database = optional(map(string))
# database = optional(map(object({
# image = optional(string, "docker.io/library/postgres:latest")
# })), null)
redis = optional(map(string))
enabled = optional(bool, true)
requirements = optional(map(string), {
limits-cpu = "800m"
@@ -327,7 +329,9 @@ resource "kubernetes_deployment_v1" "automatic" {
resource "kubernetes_deployment_v1" "database-automatic" {
for_each = { for key, value in var.kubernetes : key => value if value.enabled == true }
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
metadata {
namespace = coalesce(each.value.namespace, each.key)
name = "${coalesce(each.value.namespace, each.key)}-db"
@@ -358,7 +362,7 @@ resource "kubernetes_deployment_v1" "database-automatic" {
spec {
container {
image = "docker.io/library/postgres:14"
image = try(each.value.database.image, "docker.io/library/postgres:latest")
name = "${coalesce(each.value.name, each.key)}-db"
port {
+95 -5
View File
@@ -26,11 +26,10 @@ kubernetes = {
namespace = "onitama"
image = "ghcr.io/jackadamson/onitama:latest"
service_port = 8080
database = {
# username = "username"
# database = "database"
# password = "password"
redis = {
image = "hello"
}
database = {}
requirements = {
limits-cpu = "50m"
limits-memory = "50Mi"
@@ -103,11 +102,15 @@ kubernetes = {
}
}
nginx = {
enabled = false
enabled = true
namespace = "testnginx"
#image = "localhost:31795/django-python"
image = "nginx:latest"
database = {
# "image" = "mysql:latest"
}
#pvc_size = "10Mi"
# mount_path = "/code"
# service_port = 80
@@ -310,6 +313,93 @@ kubernetes = {
}
}
}
paper = {
enabled = false
namespace = "paper"
image = "ghcr.io/paperless-ngx/paperless-ngx:latest"
service_port = 8000
database = {}
requirements = {
limits-cpu = "50m"
limits-memory = "50Mi"
requests-cpu = "25m"
requests-memory = "25Mi"
}
environment = {
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"
}
}
}
PAPERLESS_URL = {
value = "https://paper.tryton.geeraert.eu"
}
PAPERLESS_DBHOST = {
value_from = {
secret_key_ref = {
name = "mysecret"
key = "POSTGRES_DB"
}
}
}
PAPERLESS_ADMIN_USER = {
value = "admin"
}
PAPERLESS_ADMIN_PASSWORD = {
value = "admin"
}
PAPERLESS_OCR_USER_ARGS = {
value = "{'invalidate_digital_signatures': true}"
}
}
pvc = {
paperless-data = {
name = "paperless-data"
pvc_size = "2Mi"
mount_path = "/usr/src/paperless/data"
}
media = {
name = "media"
pvc_size = "2Mi"
mount_path = "/usr/src/paperless/media"
}
export = {
name = "export"
pvc_size = "2Mi"
mount_path = "/usr/src/paperless/export"
}
consume = {
name = "consume"
pvc_size = "2Mi"
mount_path = "/usr/src/paperless/consume"
}
}
}
}