Added auto-suspend, added wol proxy for ollama
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
locals {
|
||||
comfyui_version = "frontend${var.tag}"
|
||||
}
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
resource "kubernetes_namespace" "comfyui" {
|
||||
metadata {
|
||||
name = "comfyui"
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_service_account" "comfyui" {
|
||||
|
||||
metadata {
|
||||
name = "comfyui-sa"
|
||||
namespace = kubernetes_namespace.comfyui.metadata[0].name
|
||||
}
|
||||
|
||||
automount_service_account_token = false
|
||||
}
|
||||
|
||||
resource "kubernetes_deployment" "comfyui" {
|
||||
metadata {
|
||||
name = "comfyui"
|
||||
namespace = kubernetes_namespace.comfyui.metadata[0].name
|
||||
labels = {
|
||||
comfyui = "comfyui"
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
replicas = 1
|
||||
|
||||
selector {
|
||||
match_labels = {
|
||||
comfyui = "comfyui"
|
||||
}
|
||||
}
|
||||
|
||||
strategy {
|
||||
type = "RollingUpdate"
|
||||
}
|
||||
|
||||
template {
|
||||
metadata {
|
||||
labels = {
|
||||
comfyui = "comfyui"
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
service_account_name = kubernetes_service_account.comfyui.metadata[0].name
|
||||
automount_service_account_token = false
|
||||
|
||||
container {
|
||||
name = "comfyui"
|
||||
image = "a13labs/comfyui:${local.comfyui_version}"
|
||||
|
||||
|
||||
security_context {
|
||||
allow_privilege_escalation = false
|
||||
}
|
||||
|
||||
port {
|
||||
name = "frontend"
|
||||
container_port = 5173
|
||||
protocol = "TCP"
|
||||
}
|
||||
|
||||
env {
|
||||
name = "DEV_SERVER_COMFYUI_URL"
|
||||
value = coalesce(var.backend, "http://localhost:8188")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_service" "comfyui" {
|
||||
metadata {
|
||||
name = "frontend"
|
||||
namespace = kubernetes_namespace.comfyui.metadata[0].name
|
||||
}
|
||||
|
||||
spec {
|
||||
selector = {
|
||||
comfyui = "comfyui"
|
||||
}
|
||||
|
||||
port {
|
||||
name = "frontend"
|
||||
port = 5173
|
||||
target_port = 5173
|
||||
}
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
metadata[0].annotations
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
terraform {
|
||||
required_version = "~>1.8"
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "2.36.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
variable "tag" {
|
||||
description = "The version of app to install"
|
||||
type = string
|
||||
default = "v0.0.1"
|
||||
}
|
||||
|
||||
variable "backend" {
|
||||
description = "The backend to use for ComfyUI"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,146 +3,3 @@ resource "kubernetes_namespace" "openwebui" {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
resource "kubernetes_service_account" "ollama_proxy" {
|
||||
|
||||
count = var.ollama_proxy.enabled ? 1 : 0
|
||||
metadata {
|
||||
name = "ollama-proxy-sa"
|
||||
namespace = kubernetes_namespace.openwebui.metadata[0].name
|
||||
}
|
||||
|
||||
automount_service_account_token = false
|
||||
}
|
||||
|
||||
resource "kubernetes_deployment" "ollama_proxy" {
|
||||
|
||||
count = var.ollama_proxy.enabled ? 1 : 0
|
||||
metadata {
|
||||
name = "ollama-proxy"
|
||||
namespace = kubernetes_namespace.openwebui.metadata[0].name
|
||||
labels = {
|
||||
app = "ollama-proxy"
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
replicas = 1
|
||||
selector {
|
||||
match_labels = {
|
||||
app = "ollama-proxy"
|
||||
}
|
||||
}
|
||||
|
||||
strategy {
|
||||
type = "Recreate"
|
||||
}
|
||||
|
||||
template {
|
||||
metadata {
|
||||
labels = {
|
||||
app = "ollama-proxy"
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
service_account_name = kubernetes_service_account.openwebui.metadata[0].name
|
||||
automount_service_account_token = false
|
||||
|
||||
host_network = true
|
||||
container {
|
||||
name = "app"
|
||||
image = "a13labs/wol_proxy:v0.4.0"
|
||||
image_pull_policy = "Always"
|
||||
|
||||
security_context {
|
||||
capabilities {
|
||||
add = ["NET_RAW"]
|
||||
}
|
||||
}
|
||||
|
||||
port {
|
||||
name = "http"
|
||||
container_port = var.ollama_proxy.port
|
||||
}
|
||||
|
||||
env {
|
||||
name = "UPSTREAM_MAC"
|
||||
value = var.ollama_proxy.mac
|
||||
}
|
||||
|
||||
env {
|
||||
name = "UPSTREAM_IP"
|
||||
value = var.ollama_proxy.ip
|
||||
}
|
||||
|
||||
env {
|
||||
name = "UPSTREAM_PORT"
|
||||
value = var.ollama_proxy.port
|
||||
}
|
||||
|
||||
env {
|
||||
name = "UPSTREAM_SCHEME"
|
||||
value = var.ollama_proxy.scheme
|
||||
}
|
||||
|
||||
env {
|
||||
name = "PROXY_PORT"
|
||||
value = var.ollama_proxy.port
|
||||
}
|
||||
|
||||
readiness_probe {
|
||||
tcp_socket {
|
||||
port = 11434
|
||||
}
|
||||
initial_delay_seconds = 5
|
||||
period_seconds = 10
|
||||
failure_threshold = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,3 +20,17 @@ variable "issuer" {
|
||||
default = "internal-ca"
|
||||
}
|
||||
|
||||
variable "ollama_proxy" {
|
||||
description = "Configuration for the Ollama proxy"
|
||||
type = object({
|
||||
enabled = bool
|
||||
mac = optional(string, "")
|
||||
ip = optional(string, "")
|
||||
port = optional(string, "11434")
|
||||
scheme = optional(string, "http")
|
||||
})
|
||||
default = {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
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 = {
|
||||
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
|
||||
|
||||
container {
|
||||
name = "app"
|
||||
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 = {
|
||||
app = "openwebui"
|
||||
}
|
||||
|
||||
port {
|
||||
name = "http"
|
||||
port = 8080
|
||||
target_port = 8080
|
||||
}
|
||||
|
||||
cluster_ip = "None"
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
metadata[0].annotations
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user