From 1d64d31275c1c81b5c82ab5a3dcef4afd872d0e2 Mon Sep 17 00:00:00 2001 From: Jannik S <69747628+jannikstdl@users.noreply.github.com> Date: Sun, 24 Mar 2024 08:17:38 +0100 Subject: [PATCH 1/6] Updated PVC naming --- kubernetes/manifest/base/webui-pvc.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kubernetes/manifest/base/webui-pvc.yaml b/kubernetes/manifest/base/webui-pvc.yaml index 5c75283ad..97fb761d4 100644 --- a/kubernetes/manifest/base/webui-pvc.yaml +++ b/kubernetes/manifest/base/webui-pvc.yaml @@ -2,8 +2,8 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: labels: - app: ollama-webui - name: ollama-webui-pvc + app: open-webui + name: open-webui-pvc namespace: open-webui spec: accessModes: ["ReadWriteOnce"] From c91c95431d0741b69a10d332067f5d9459818fa3 Mon Sep 17 00:00:00 2001 From: Jannik S <69747628+jannikstdl@users.noreply.github.com> Date: Sun, 24 Mar 2024 08:18:28 +0100 Subject: [PATCH 2/6] Changed allocation in webui-deployment.yaml --- kubernetes/manifest/base/webui-deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/manifest/base/webui-deployment.yaml b/kubernetes/manifest/base/webui-deployment.yaml index 38efd5549..79a0a9a23 100644 --- a/kubernetes/manifest/base/webui-deployment.yaml +++ b/kubernetes/manifest/base/webui-deployment.yaml @@ -35,4 +35,4 @@ spec: volumes: - name: webui-volume persistentVolumeClaim: - claimName: ollama-webui-pvc \ No newline at end of file + claimName: open-webui-pvc \ No newline at end of file From 8962d948cd5fb77dbf0d899fca277055ad832d33 Mon Sep 17 00:00:00 2001 From: Jannik S <69747628+jannikstdl@users.noreply.github.com> Date: Mon, 25 Mar 2024 21:21:32 +0100 Subject: [PATCH 3/6] Check if running on K8s to correctly allocate Ollama Base URL --- backend/config.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/config.py b/backend/config.py index 9236e8a86..20bc7ad29 100644 --- a/backend/config.py +++ b/backend/config.py @@ -209,6 +209,7 @@ OLLAMA_API_BASE_URL = os.environ.get( OLLAMA_BASE_URL = os.environ.get("OLLAMA_BASE_URL", "") +RUNNING_ON_K8S = os.environ.get("KUBERNETES_SERVICE_HOST", "") if OLLAMA_BASE_URL == "" and OLLAMA_API_BASE_URL != "": OLLAMA_BASE_URL = ( @@ -217,9 +218,23 @@ if OLLAMA_BASE_URL == "" and OLLAMA_API_BASE_URL != "": else OLLAMA_API_BASE_URL ) -if ENV == "prod": +if ENV == "prod" and RUNNING_ON_K8S == "": if OLLAMA_BASE_URL == "/ollama": OLLAMA_BASE_URL = "http://host.docker.internal:11434" + else: + OLLAMA_BASE_URL = "http://ollama-service.open-webui.svc.cluster.local:11434" + + + +def is_running_in_kubernetes(): + return 'KUBERNETES_SERVICE_HOST' in os.environ + +# Setze EMV auf True, wenn in Kubernetes +if is_running_in_kubernetes(): + os.environ['EMV'] = 'True' + print("Läuft in Kubernetes, EMV gesetzt auf True.") +else: + print("Läuft nicht in Kubernetes.") OLLAMA_BASE_URLS = os.environ.get("OLLAMA_BASE_URLS", "") From eecc7f3529163dff30aeaa04609323bddedfbe2c Mon Sep 17 00:00:00 2001 From: Jannik S <69747628+jannikstdl@users.noreply.github.com> Date: Mon, 25 Mar 2024 21:32:21 +0100 Subject: [PATCH 4/6] Deleted unused checks --- backend/config.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/backend/config.py b/backend/config.py index 20bc7ad29..6b5431bce 100644 --- a/backend/config.py +++ b/backend/config.py @@ -223,18 +223,6 @@ if ENV == "prod" and RUNNING_ON_K8S == "": OLLAMA_BASE_URL = "http://host.docker.internal:11434" else: OLLAMA_BASE_URL = "http://ollama-service.open-webui.svc.cluster.local:11434" - - - -def is_running_in_kubernetes(): - return 'KUBERNETES_SERVICE_HOST' in os.environ - -# Setze EMV auf True, wenn in Kubernetes -if is_running_in_kubernetes(): - os.environ['EMV'] = 'True' - print("Läuft in Kubernetes, EMV gesetzt auf True.") -else: - print("Läuft nicht in Kubernetes.") OLLAMA_BASE_URLS = os.environ.get("OLLAMA_BASE_URLS", "") From af366cf7320e72022360ad090b18db80cfbb6d0a Mon Sep 17 00:00:00 2001 From: Jannik S <69747628+jannikstdl@users.noreply.github.com> Date: Mon, 25 Mar 2024 21:50:58 +0100 Subject: [PATCH 5/6] fix --- backend/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/config.py b/backend/config.py index 6b5431bce..385c9238a 100644 --- a/backend/config.py +++ b/backend/config.py @@ -218,8 +218,8 @@ if OLLAMA_BASE_URL == "" and OLLAMA_API_BASE_URL != "": else OLLAMA_API_BASE_URL ) -if ENV == "prod" and RUNNING_ON_K8S == "": - if OLLAMA_BASE_URL == "/ollama": +if ENV == "prod": + if OLLAMA_BASE_URL == "/ollama" and RUNNING_ON_K8S == "": OLLAMA_BASE_URL = "http://host.docker.internal:11434" else: OLLAMA_BASE_URL = "http://ollama-service.open-webui.svc.cluster.local:11434" From 7f405c74cd92ad04cc3b069767c6d7680817ffce Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 25 Mar 2024 23:20:16 -0700 Subject: [PATCH 6/6] refac: rename --- backend/config.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/config.py b/backend/config.py index 385c9238a..9647fe848 100644 --- a/backend/config.py +++ b/backend/config.py @@ -208,8 +208,7 @@ OLLAMA_API_BASE_URL = os.environ.get( ) OLLAMA_BASE_URL = os.environ.get("OLLAMA_BASE_URL", "") - -RUNNING_ON_K8S = os.environ.get("KUBERNETES_SERVICE_HOST", "") +KUBERNETES_SERVICE_HOST = os.environ.get("KUBERNETES_SERVICE_HOST", "") if OLLAMA_BASE_URL == "" and OLLAMA_API_BASE_URL != "": OLLAMA_BASE_URL = ( @@ -219,7 +218,7 @@ if OLLAMA_BASE_URL == "" and OLLAMA_API_BASE_URL != "": ) if ENV == "prod": - if OLLAMA_BASE_URL == "/ollama" and RUNNING_ON_K8S == "": + if OLLAMA_BASE_URL == "/ollama" and KUBERNETES_SERVICE_HOST == "": OLLAMA_BASE_URL = "http://host.docker.internal:11434" else: OLLAMA_BASE_URL = "http://ollama-service.open-webui.svc.cluster.local:11434"