Skip to content

Commit cdf678d

Browse files
committed
init
0 parents  commit cdf678d

17 files changed

+320
-0
lines changed

Diff for: README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Prompt Engineers AI - Ollama Deployment
2+
3+
Welcome to the Prompt Engineers AI - Ollama Deployment repository. This document provides instructions on how to deploy the Ollama application using Docker Compose.
4+
5+
## Prerequisites
6+
7+
Before proceeding with the deployment, ensure you have the following installed on your system:
8+
9+
- Docker
10+
- Docker Compose
11+
- kubectl
12+
- helm
13+
14+
## Docker: Getting Started
15+
16+
1. Clone the repository to your local machine:
17+
18+
git clone https://github.com/your-repository-url
19+
20+
2. Start the Docker Compose deployment:
21+
22+
```bash
23+
bash scripts/ollama.sh
24+
```
25+
26+
## Kubernetes: Getting Started (Under Development)
27+
28+
1. Install on cluster
29+
30+
```bash
31+
bash scripts/deploy.sh
32+
```
33+
34+
2. Pull model
35+
36+
```bash
37+
bash scripts/pull.sh
38+
```

Diff for: docker-compose.ollama.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3'
2+
services:
3+
ollama:
4+
image: ollama/ollama
5+
container_name: ollama
6+
ports:
7+
- "11434:11434"
8+
volumes:
9+
- ollama:/root/.ollama
10+
volumes:
11+
ollama:
12+
13+
############################################################
14+
## Pull Model
15+
############################################################
16+
# curl -X POST http://localhost:11434/api/pull -d '{
17+
# "name": "llama2:7b"
18+
# }'
19+
20+
############################################################
21+
## Query the model
22+
############################################################
23+
# curl -X POST http://localhost:11434/api/generate -d '{
24+
# "model": "llama2",
25+
# "prompt":"Why is the sky blue?"
26+
# }'

Diff for: k8s/.helmignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

Diff for: k8s/Chart.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v2
2+
name: ollama
3+
description: A Helm chart for Kubernetes
4+
version: 0.1.0

Diff for: k8s/templates/_helpers.tpl

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "k8s.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "k8s.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "k8s.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "k8s.labels" -}}
37+
helm.sh/chart: {{ include "k8s.chart" . }}
38+
{{ include "k8s.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "k8s.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "k8s.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "k8s.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "k8s.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

Diff for: k8s/templates/deployment.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: ollama
5+
labels:
6+
app: ollama
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
app: ollama
12+
template:
13+
metadata:
14+
labels:
15+
app: ollama
16+
spec:
17+
containers:
18+
- name: {{ .Release.Name }}-container
19+
image: {{ .Values.image.repository }}
20+
ports:
21+
- containerPort: 11434
22+
volumeMounts:
23+
- name: {{ .Release.Name }}-volume
24+
mountPath: /root/.ollama
25+
volumes:
26+
- name: {{ .Release.Name }}-volume
27+
persistentVolumeClaim:
28+
claimName: {{ .Release.Name }}-pvc

Diff for: k8s/templates/hpa.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "k8s.fullname" . }}
6+
labels:
7+
{{- include "k8s.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "k8s.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
25+
- type: Resource
26+
resource:
27+
name: memory
28+
target:
29+
type: Utilization
30+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
31+
{{- end }}
32+
{{- end }}

Diff for: k8s/templates/ingress.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: {{ .Release.Name }}-ingress
5+
namespace: ollama
6+
annotations:
7+
kubernetes.io/ingress.class: nginx
8+
spec:
9+
rules:
10+
- host: ollama.promptengineers.ai
11+
http:
12+
paths:
13+
- backend:
14+
service:
15+
name: ollama
16+
port:
17+
number: {{ .Values.service.port }}
18+
path: /
19+
pathType: Prefix

Diff for: k8s/templates/pvc.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.persistence.enabled }}
2+
apiVersion: v1
3+
kind: PersistentVolumeClaim
4+
metadata:
5+
name: {{ .Release.Name }}-pvc
6+
spec:
7+
accessModes:
8+
- ReadWriteOnce
9+
resources:
10+
requests:
11+
storage: {{ .Values.persistence.size }}
12+
{{- end }}

Diff for: k8s/templates/service.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: ollama
5+
labels:
6+
app: ollama
7+
spec:
8+
selector:
9+
app: ollama
10+
ports:
11+
- name: http
12+
protocol: TCP
13+
port: {{ .Values.service.port }}
14+
targetPort: {{ .Values.service.port }}

Diff for: k8s/values.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
replicaCount: 1
2+
3+
fullnameOverride: ""
4+
5+
image:
6+
repository: ollama/ollama
7+
pullPolicy: IfNotPresent
8+
9+
service:
10+
type: ClusterIP
11+
port: 11434
12+
13+
persistence:
14+
enabled: true
15+
size: 4Gi
16+
17+
autoscaling:
18+
enabled: false
19+
minReplicas: 1
20+
maxReplicas: 2
21+
targetCPUUtilizationPercentage: 80
22+
# targetMemoryUtilizationPercentage: 80
23+
24+
# ... (other configurations)
25+
26+
ingress:
27+
enabled: true
28+
className: ""
29+
annotations: {}
30+
hosts:
31+
- host: llama.promptengineers.ai
32+
paths:
33+
- path: /
34+
pathType: Prefix
35+
tls: []

Diff for: scripts/delete.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
SERVER="https://ollama.promptengineers.ai"
4+
5+
curl -X DELETE $SERVER/api/delete -d '{
6+
"name": "llama2:7b"
7+
}'

Diff for: scripts/deploy.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
helm -n ollama install ollama k8s

Diff for: scripts/ollama.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker-compose -f docker-compose.ollama.yml up --build

Diff for: scripts/pull.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
curl -X POST https://ollama.promptengineers.ai/api/pull -d '{
4+
"name": "llama2"
5+
}'

Diff for: scripts/query.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
curl -X POST https://ollama.promptengineers.ai/api/generate -d '{
4+
"model": "llama2",
5+
"prompt":"Who won the 2001 world series?"
6+
}'

Diff for: scripts/upgrade.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
helm upgrade -i --debug --wait --atomic ollama ./k8s

0 commit comments

Comments
 (0)