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
              }
            }
          }
        }
      }
    }
  }
}
