2025-06-22 18:43:55 +02:00
|
|
|
resource "kubernetes_service_account" "openwebui" {
|
|
|
|
|
|
|
|
|
|
metadata {
|
|
|
|
|
name = "openwebui-sa"
|
|
|
|
|
namespace = kubernetes_namespace.openwebui.metadata[0].name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
automount_service_account_token = false
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-25 16:37:05 +01:00
|
|
|
|
|
|
|
|
resource "kubernetes_secret" "openwebui" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "openwebui-secret"
|
|
|
|
|
namespace = kubernetes_namespace.openwebui.metadata[0].name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
|
"WEBUI_SECRET_KEY" = base64encode(var.secret_key)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type = "Opaque"
|
|
|
|
|
|
|
|
|
|
}
|
2025-06-22 18:43:55 +02:00
|
|
|
resource "kubernetes_deployment" "openwebui" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "openwebui"
|
|
|
|
|
namespace = kubernetes_namespace.openwebui.metadata[0].name
|
|
|
|
|
labels = {
|
|
|
|
|
app = "openwebui"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
replicas = 1
|
|
|
|
|
|
|
|
|
|
selector {
|
|
|
|
|
match_labels = {
|
|
|
|
|
app = "openwebui"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strategy {
|
|
|
|
|
type = "RollingUpdate"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template {
|
|
|
|
|
metadata {
|
|
|
|
|
labels = {
|
|
|
|
|
app = "openwebui"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
service_account_name = kubernetes_service_account.openwebui.metadata[0].name
|
|
|
|
|
automount_service_account_token = false
|
|
|
|
|
|
2025-12-25 16:37:05 +01:00
|
|
|
# We need an init container rsync the /app/backend from the original image to the hostPath volume, so that we don't overwrite user data on restarts
|
|
|
|
|
# also fix permissions
|
|
|
|
|
init_container {
|
|
|
|
|
name = "startup"
|
|
|
|
|
image = "ghcr.io/open-webui/open-webui:${var.tag}"
|
|
|
|
|
command = ["sh", "-c", "apt-get update && apt-get install -y --no-install-recommends rsync && rm -rf /target_app/* && rsync -avz --delete /app/backend/* /target_app/ --exclude data && chown -R 1000:1000 /target_app /target_data"]
|
|
|
|
|
security_context {
|
|
|
|
|
run_as_user = 0
|
|
|
|
|
run_as_group = 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
volume_mount {
|
|
|
|
|
name = "openwebui-app"
|
|
|
|
|
mount_path = "/target_app"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
volume_mount {
|
|
|
|
|
name = "openwebui-data"
|
|
|
|
|
mount_path = "/target_data"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-22 18:43:55 +02:00
|
|
|
container {
|
2025-12-25 16:37:05 +01:00
|
|
|
name = "app"
|
|
|
|
|
image = "ghcr.io/open-webui/open-webui:${var.tag}"
|
|
|
|
|
image_pull_policy = "Always"
|
2025-06-22 18:43:55 +02:00
|
|
|
|
|
|
|
|
security_context {
|
|
|
|
|
allow_privilege_escalation = false
|
2025-12-25 16:37:05 +01:00
|
|
|
run_as_non_root = true
|
|
|
|
|
run_as_user = 1000
|
|
|
|
|
run_as_group = 1000
|
2025-06-22 18:43:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
port {
|
|
|
|
|
name = "http"
|
|
|
|
|
container_port = 8080
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-25 16:37:05 +01:00
|
|
|
env {
|
|
|
|
|
name = "WEBUI_SECRET_KEY"
|
|
|
|
|
value_from {
|
|
|
|
|
secret_key_ref {
|
|
|
|
|
name = kubernetes_secret.openwebui.metadata[0].name
|
|
|
|
|
key = "WEBUI_SECRET_KEY"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
env {
|
|
|
|
|
name = "JWT_EXPIRES_IN"
|
|
|
|
|
value = var.jwt_expires_in
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
env {
|
|
|
|
|
name = "GLOBAL_LOG_LEVEL"
|
|
|
|
|
value = var.log_level
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-30 23:24:44 +02:00
|
|
|
env {
|
|
|
|
|
name = "AIOHTTP_CLIENT_TIMEOUT"
|
|
|
|
|
value = var.aiohttp_client_timeout
|
|
|
|
|
}
|
2025-12-25 16:37:05 +01:00
|
|
|
|
2025-06-22 18:43:55 +02:00
|
|
|
readiness_probe {
|
|
|
|
|
tcp_socket {
|
|
|
|
|
port = 8080
|
|
|
|
|
}
|
|
|
|
|
initial_delay_seconds = 5
|
|
|
|
|
period_seconds = 10
|
|
|
|
|
failure_threshold = 10
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-25 16:37:05 +01:00
|
|
|
volume_mount {
|
|
|
|
|
name = "openwebui-app"
|
|
|
|
|
mount_path = "/app/backend"
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-22 18:43:55 +02:00
|
|
|
volume_mount {
|
|
|
|
|
name = "openwebui-data"
|
|
|
|
|
mount_path = "/app/backend/data"
|
|
|
|
|
}
|
2025-12-25 16:37:05 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
volume {
|
|
|
|
|
name = "openwebui-app"
|
|
|
|
|
host_path {
|
|
|
|
|
path = local.openwebui_app
|
|
|
|
|
}
|
2025-06-22 18:43:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
volume {
|
|
|
|
|
name = "openwebui-data"
|
|
|
|
|
host_path {
|
|
|
|
|
path = local.openwebui_data
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_service" "openwebui" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "http"
|
|
|
|
|
namespace = kubernetes_namespace.openwebui.metadata[0].name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
selector = {
|
|
|
|
|
app = "openwebui"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
port {
|
|
|
|
|
name = "http"
|
|
|
|
|
port = 8080
|
|
|
|
|
target_port = 8080
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-20 21:34:33 +02:00
|
|
|
type = "ClusterIP"
|
2025-06-22 18:43:55 +02:00
|
|
|
cluster_ip = "None"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
|
ignore_changes = [
|
|
|
|
|
metadata[0].annotations
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|