diff --git a/modules/ollama/jobspec.nomad.hcl b/modules/ollama/jobspec.nomad.hcl index b55675e..f7a4b15 100644 --- a/modules/ollama/jobspec.nomad.hcl +++ b/modules/ollama/jobspec.nomad.hcl @@ -1,9 +1,14 @@ job "ollama" { + group "ollama" { network { + mode = "bridge" port "api" { - static = 11434 + to = 11434 + } + port "envoy_metrics" { + to = 9102 } } @@ -23,7 +28,6 @@ job "ollama" { config { image = "ollama/ollama:latest" runtime = "nvidia" - ports = ["api"] volumes = [ "alloc/data/:/root/.ollama" @@ -43,7 +47,127 @@ job "ollama" { service { provider = "consul" - port = "api" + port = "11434" + + meta { + envoy_metrics_port = "${NOMAD_HOST_PORT_envoy_metrics}" + } + + connect { + sidecar_service { + proxy { + expose { + path { + path = "/metrics" + protocol = "http" + local_path_port = 9102 + listener_port = "envoy_metrics" + } + } + transparent_proxy {} + } + } + } + } + } + + group "open-webui" { + + network { + mode = "bridge" + port "http" { + to = 8080 + } + port "envoy_metrics" { + to = 9102 + } + } + + ephemeral_disk { + migrate = true + size = 200 + } + + task "open-webui" { + driver = "docker" + + config { + image = "ghcr.io/open-webui/open-webui:main" + force_pull = true + + volumes = [ + "alloc/data/:/app/backend/data" + ] + } + + env { + OLLAMA_BASE_URL = "http://ollama-ollama.virtual.consul" + } + + resources { + cpu = 100 + memory = 1024 + } + } + + service { + provider = "consul" + port = 8080 + + meta { + envoy_metrics_port = "${NOMAD_HOST_PORT_envoy_metrics}" + } + + connect { + sidecar_service { + proxy { + expose { + path { + path = "/metrics" + protocol = "http" + local_path_port = 9102 + listener_port = "envoy_metrics" + } + } + transparent_proxy {} + } + } + } + } + } + + group "open-webui-ingress-group" { + + network { + mode = "bridge" + port "inbound" { + to = 8080 + } + } + + service { + port = "inbound" + tags = [ + "traefik.enable=true", + + "traefik.http.routers.openwebui.rule=Host(`eos.brmartin.co.uk`)", + "traefik.http.routers.openwebui.entrypoints=websecure" + ] + + connect { + gateway { + ingress { + listener { + port = 8080 + protocol = "http" + service { + name = "ollama-open-webui" + hosts = ["*"] + } + } + } + } + } } } }