From afd43d8f95c62a321f081659ca54c0fc4de24042 Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Sat, 4 May 2024 22:51:18 -0400 Subject: [PATCH] Add ai stack --- ollama/ollama-deployment.yaml | 36 +++++++++++++++++++++++++++ ollama/ollama-pvc.yaml | 12 +++++++++ ollama/ollama-service.yaml | 12 +++++++++ open-webui/open-webui-deployment.yaml | 30 ++++++++++++++++++++++ open-webui/open-webui-pvc.yaml | 12 +++++++++ open-webui/open-webui-service.yaml | 13 ++++++++++ 6 files changed, 115 insertions(+) create mode 100644 ollama/ollama-deployment.yaml create mode 100644 ollama/ollama-pvc.yaml create mode 100644 ollama/ollama-service.yaml create mode 100644 open-webui/open-webui-deployment.yaml create mode 100644 open-webui/open-webui-pvc.yaml create mode 100644 open-webui/open-webui-service.yaml diff --git a/ollama/ollama-deployment.yaml b/ollama/ollama-deployment.yaml new file mode 100644 index 0000000..ffb33e4 --- /dev/null +++ b/ollama/ollama-deployment.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ollama-deployment + namespace: ollama-ns +spec: + replicas: 1 + selector: + matchLabels: + app: ollama + template: + metadata: + labels: + app: ollama + spec: + runtimeClassName: nvidia + containers: + - name: ollama + image: ollama/ollama + env: + - name: OLLAMA_HOST + value: 0.0.0.0 + - name: OLLAMA_MODELS + value: "/models" + ports: + - containerPort: 11434 + resources: + limits: + nvidia.com/gpu: 2 + volumeMounts: + - name: ollama-volume + mountPath: "/my-models" + volumes: + - name: ollama-volume + persistentVolumeClaim: + claimName: ollama-pvc diff --git a/ollama/ollama-pvc.yaml b/ollama/ollama-pvc.yaml new file mode 100644 index 0000000..f2d2aa0 --- /dev/null +++ b/ollama/ollama-pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: ollama-pvc + namespace: ollama-ns +spec: + accessModes: + - ReadWriteOnce + storageClassName: longhorn + resources: + requests: + storage: 200Gi diff --git a/ollama/ollama-service.yaml b/ollama/ollama-service.yaml new file mode 100644 index 0000000..d034c21 --- /dev/null +++ b/ollama/ollama-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: ollama-service + namespace: ollama-ns +spec: + type: LoadBalancer + ports: + - port: 11434 + targetPort: 11434 + selector: + app: ollama diff --git a/open-webui/open-webui-deployment.yaml b/open-webui/open-webui-deployment.yaml new file mode 100644 index 0000000..785da3a --- /dev/null +++ b/open-webui/open-webui-deployment.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: open-webui-deployment + namespace: open-webui-ns +spec: + replicas: 1 + selector: + matchLabels: + app: open-webui + template: + metadata: + labels: + app: open-webui + spec: + containers: + - name: open-webui + image: ghcr.io/open-webui/open-webui:main + ports: + - containerPort: 8080 + env: + - name: OLLAMA_BASE_URL + value: "http://ollama-service.ollama-ns.svc.cluster.local:11434" # Assuming the internal service is named 'open-webui-service' + volumeMounts: + - name: config + mountPath: /app/backend/data + volumes: + - name: config + persistentVolumeClaim: + claimName: open-webui-pvc diff --git a/open-webui/open-webui-pvc.yaml b/open-webui/open-webui-pvc.yaml new file mode 100644 index 0000000..762a5fc --- /dev/null +++ b/open-webui/open-webui-pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: open-webui-pvc + namespace: open-webui-ns +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi + storageClassName: longhorn diff --git a/open-webui/open-webui-service.yaml b/open-webui/open-webui-service.yaml new file mode 100644 index 0000000..871ce6a --- /dev/null +++ b/open-webui/open-webui-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: open-webui-service + namespace: open-webui-ns +spec: + type: LoadBalancer + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + selector: + app: open-webui