Files
a13labs.infra/terraform/modules/apps/open-webui/main.tf
T
alexandre.pires 01bf71f8d2 feat(cert-manager): Add Cloudns issuer and DNS-01 challenge support
- Introduced a new Cloudns issuer configuration for cert-manager.
- Created separate tasks for DNS-01 and HTTP-01 challenge issuers.
- Updated cert-manager tasks to include Cloudns provider and manage secrets.
- Refactored existing LetsEncrypt issuer registration to use new task structure.
- Added necessary Kubernetes resources for Cloudns integration, including RBAC and certificates.
- Updated Terraform configurations to support new DNS records and service changes.
- Adjusted deployment strategies for CoreDNS and Open WebUI applications.
2025-06-07 20:39:38 +02:00

149 lines
2.9 KiB
Terraform

resource "kubernetes_namespace" "openwebui" {
metadata {
name = "openwebui"
}
}
resource "kubernetes_service_account" "openwebui" {
metadata {
name = "openwebui-sa"
namespace = kubernetes_namespace.openwebui.metadata[0].name
}
automount_service_account_token = false
}
resource "kubernetes_deployment" "openwebui" {
metadata {
name = "openwebui"
namespace = kubernetes_namespace.openwebui.metadata[0].name
labels = {
openwebui = "openwebui"
}
}
spec {
replicas = 1
selector {
match_labels = {
openwebui = "openwebui"
}
}
strategy {
type = "RollingUpdate"
}
template {
metadata {
labels = {
openwebui = "openwebui"
}
}
spec {
service_account_name = kubernetes_service_account.openwebui.metadata[0].name
automount_service_account_token = false
container {
name = "openwebui-container"
image = "ghcr.io/open-webui/open-webui:${var.tag}"
security_context {
allow_privilege_escalation = false
}
port {
name = "http"
container_port = 8080
}
readiness_probe {
tcp_socket {
port = 8080
}
initial_delay_seconds = 5
period_seconds = 10
failure_threshold = 10
}
volume_mount {
name = "openwebui-data"
mount_path = "/app/backend/data"
}
}
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 = {
openwebui = "openwebui"
}
port {
name = "http"
port = 8080
target_port = 8080
}
cluster_ip = "None"
}
lifecycle {
ignore_changes = [
metadata[0].annotations
]
}
}
resource "kubernetes_ingress_v1" "openwebui" {
metadata {
name = "ingress"
namespace = kubernetes_namespace.openwebui.metadata[0].name
annotations = {
"kubernetes.io/ingress.class" = "public"
"cert-manager.io/cluster-issuer" = "letsencrypt-prod"
"kubernetes.io/tls-acme" = "true"
"nginx.ingress.kubernetes.io/ssl-redirect" = "true"
}
}
spec {
tls {
hosts = [var.fqdn]
secret_name = "openwebui-tls"
}
rule {
host = var.fqdn
http {
path {
backend {
service {
name = "http"
port {
number = 8080
}
}
}
}
}
}
}
}