Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm Setup #70

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions deploy/helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
25 changes: 25 additions & 0 deletions deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v2
name: llamagpt
description: A Helm chart for Kubernetes
icon: https://i.imgur.com/LI59cui.png

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.0.1"
66 changes: 66 additions & 0 deletions deploy/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "llamagpt.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "llamagpt.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "llamagpt.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "llamagpt.labels" -}}
helm.sh/chart: {{ include "llamagpt.chart" . }}
{{ include "llamagpt.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "llamagpt.selectorLabels" -}}
app.kubernetes.io/name: {{ include "llamagpt.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "llamagpt.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "llamagpt.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "llamagpt.api.openAi.host" -}}
{{- default (printf "%s-api:%v" (include "llamagpt.fullname" .) .Values.api.service.port) .Values.api.openAi.host }}
{{- end }}
16 changes: 16 additions & 0 deletions deploy/helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

kind: ConfigMap
apiVersion: v1
metadata:
name: {{ template "llamagpt.fullname" . }}-configmap
labels:
{{- include "llamagpt.labels" . | nindent 4 }}
data:
DEFAULT_MODEL: {{ .Values.api.defaultModel }}
OPENAI_API_HOST: http://{{ template "llamagpt.api.openAi.host" . }}
OPENAI_API_KEY: {{ .Values.api.openAi.key }}
WAIT_HOSTS: {{ template "llamagpt.api.openAi.host" . }}
WAIT_TIMEOUT: {{ quote .Values.api.openAi.waitTimeout }}

---
66 changes: 66 additions & 0 deletions deploy/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
service: {{ template "llamagpt.fullname" . }}-api
{{- include "llamagpt.labels" . | nindent 4 }}
name: {{ template "llamagpt.fullname" . }}-api
spec:
replicas: {{ .Values.api.replicas }}
selector:
matchLabels:
service: {{ template "llamagpt.fullname" . }}-api
template:
metadata:
labels:
service: {{ template "llamagpt.fullname" . }}-api
{{- include "llamagpt.labels" . | nindent 4 }}
spec:
containers:
- name: {{ template "llamagpt.fullname" . }}-api
image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag }}"
env:
- name: MODEL
valueFrom:
configMapKeyRef:
name: {{ template "llamagpt.fullname" . }}-configmap
key: DEFAULT_MODEL
resources:
requests:
memory: {{ .Values.api.resources.memory }}
restartPolicy: {{ .Values.api.restartPolicy }}

---

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
service: {{ template "llamagpt.fullname" . }}-ui
{{- include "llamagpt.labels" . | nindent 4 }}
name: {{ template "llamagpt.fullname" . }}-ui
spec:
replicas: {{ .Values.ui.replicas }}
selector:
matchLabels:
service: {{ template "llamagpt.fullname" . }}-ui
template:
metadata:
labels:
service: {{ template "llamagpt.fullname" . }}-ui
{{- include "llamagpt.labels" . | nindent 4 }}
spec:
containers:
- name: {{ template "llamagpt.fullname" . }}-ui
image: "{{ .Values.ui.image.repository }}:{{ .Values.ui.image.tag }}"
envFrom:
- configMapRef:
name: {{ template "llamagpt.fullname" . }}-configmap
ports:
- containerPort: {{ int .Values.ui.service.internalPort }}
resources: {}
restartPolicy: {{ .Values.ui.restartPolicy }}

---
40 changes: 40 additions & 0 deletions deploy/helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---

apiVersion: v1
kind: Service
metadata:
labels:
service: {{ template "llamagpt.fullname" . }}
{{- include "llamagpt.labels" . | nindent 4 }}
name: {{ template "llamagpt.fullname" . }}-api
spec:
ports:
- name: api
port: {{ .Values.api.service.port }}
targetPort: {{ .Values.api.service.targetPort }}
selector:
service: {{ template "llamagpt.fullname" . }}-api
status:
loadBalancer: {}

---

apiVersion: v1
kind: Service
metadata:
labels:
service: {{ template "llamagpt.fullname" . }}-ui
{{- include "llamagpt.labels" . | nindent 4 }}
name: {{ template "llamagpt.fullname" . }}-ui
spec:
ports:
- name: ui
port: {{ .Values.ui.service.port }}
targetPort: {{ .Values.ui.service.targetPort }}
selector:
service: {{ template "llamagpt.fullname" . }}-ui
type: {{ .Values.ui.service.type }}
status:
loadBalancer: {}

---
15 changes: 15 additions & 0 deletions deploy/helm/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "llamagpt.fullname" . }}-test-connection"
labels:
{{- include "llamagpt.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ template "llamagpt.fullname" . }}-ui:{{ .Values.ui.service.port }}']
restartPolicy: Never
37 changes: 37 additions & 0 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Default values for llamagpt.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

ui:
replicaCount: 1
service:
type: ClusterIP
port: 3000
targetPort: 3000
internalPort: 3000
image:
repository: ghcr.io/getumbrel/llama-gpt-ui
tag: 1.0.1
pullPolicy: IfNotPresent
affinity: {}
restartPolicy: Always

api:
defaultModel: /models/llama-2-7b-chat.bin
replicaCount: 1
service:
type: ClusterIP
port: 8000
targetPort: 8000
image:
repository: ghcr.io/getumbrel/llama-gpt-api
tag: 1.0.1
pullPolicy: IfNotPresent
affinity: {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, you have this empty affinity: {} default, but I don't see it implemented in either of the deployment template specs. It would be great to get that added, maybe tolerations too, so that people can choose to schedule this api component on higher performance nodes if they want to. That's my usecase anyway.
Thanks for adding this BTW.

restartPolicy: Always
resources:
memory: 5Gi
openAi:
host:
key: sk-XXXXXXXXXXXXXXXXXXXX
waitTimeout: 600