Skip to content

Commit c101ce8

Browse files
authored
Merge pull request #92 from andrewrothstein/feature/add-k8s-helm-chart
A helm chart for BricksLLM fun in Kubernetes
2 parents 25627cc + 0bbcd74 commit c101ce8

14 files changed

Lines changed: 492 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
version: '3'
3+
tasks:
4+
default:
5+
cmds:
6+
- |
7+
helm upgrade \
8+
--create-namespace \
9+
-n bricksllm \
10+
--install \
11+
bricksllm \
12+
./bricksllm
13+
delete:
14+
cmds:
15+
- helm delete -n bricksllm bricksllm
16+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
charts/*.tgz
Lines changed: 23 additions & 0 deletions
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/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencies:
2+
- name: redis
3+
repository: oci://registry-1.docker.io/bitnamicharts
4+
version: 20.2.1
5+
- name: postgresql
6+
repository: oci://registry-1.docker.io/bitnamicharts
7+
version: 16.1.1
8+
digest: sha256:d380aeee84575489c7b48727ff37b9e47747e8c7e855655fc815455243421660
9+
generated: "2024-11-04T22:16:50.627919824Z"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: v2
3+
name: bricksllm
4+
description: A Helm chart for deploying BricksLLM and its dependencies
5+
6+
type: application
7+
8+
version: 0.1.0
9+
10+
# bricksllm version
11+
appVersion: "1.37.0"
12+
13+
dependencies:
14+
- condition: redis.enabled
15+
name: redis
16+
repository: oci://registry-1.docker.io/bitnamicharts
17+
version: ~20
18+
- conditions: postgresql.enabled
19+
name: postgresql
20+
repository: oci://registry-1.docker.io/bitnamicharts
21+
version: ~16

kubernetes/helm-charts/bricksllm/templates/NOTES.txt

Whitespace-only changes.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "bricksllm.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 "bricksllm.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 "bricksllm.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "bricksllm.labels" -}}
37+
helm.sh/chart: {{ include "bricksllm.chart" . }}
38+
{{ include "bricksllm.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 "bricksllm.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "bricksllm.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 "bricksllm.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "bricksllm.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{{ $fullname := include "bricksllm.fullname" . -}}
2+
---
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: {{ $fullname }}
7+
labels:
8+
{{- include "bricksllm.labels" . | nindent 4 }}
9+
spec:
10+
{{- if not .Values.autoscaling.enabled }}
11+
replicas: {{ .Values.replicaCount }}
12+
{{- end }}
13+
selector:
14+
matchLabels:
15+
{{- include "bricksllm.selectorLabels" . | nindent 6 }}
16+
template:
17+
metadata:
18+
{{- with .Values.podAnnotations }}
19+
annotations:
20+
{{- toYaml . | nindent 8 }}
21+
{{- end }}
22+
labels:
23+
{{- include "bricksllm.labels" . | nindent 8 }}
24+
{{- with .Values.podLabels }}
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
spec:
28+
{{- with .Values.imagePullSecrets }}
29+
imagePullSecrets:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
serviceAccountName: {{ include "bricksllm.serviceAccountName" . }}
33+
securityContext:
34+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
35+
containers:
36+
- name: {{ .Chart.Name }}
37+
securityContext:
38+
{{- toYaml .Values.securityContext | nindent 12 }}
39+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
40+
env:
41+
- name: POSTGRESQL_HOSTS
42+
value: '{{ $fullname }}-postgresql'
43+
- name: POSTGRESQL_USERNAME
44+
value: postgres
45+
- name: POSTGRESQL_PASSWORD
46+
valueFrom:
47+
secretKeyRef:
48+
name: '{{ $fullname }}-postgresql'
49+
key: postgres-password
50+
- name: REDIS_HOSTS
51+
value: '{{ $fullname }}-redis-master'
52+
- name: REDIS_PASSWORD
53+
valueFrom:
54+
secretKeyRef:
55+
name: '{{ $fullname }}-redis'
56+
key: redis-password
57+
imagePullPolicy: {{ .Values.image.pullPolicy }}
58+
ports:
59+
{{- range $n, $p := .Values.services.ports }}
60+
- name: {{ $n }}
61+
containerPort: {{ $p }}
62+
protocol: TCP
63+
{{- end }}
64+
{{- with .Values.livenessProbe }}
65+
livenessProbe:
66+
{{- toYaml . | nindent 12 }}
67+
{{- end }}
68+
{{- with .Values.readinesProbe }}
69+
readinessProbe:
70+
{{- toYaml . | nindent 12 }}
71+
{{- end }}
72+
{{- with .Values.resources }}
73+
resources:
74+
{{- toYaml . | nindent 12 }}
75+
{{- end }}
76+
{{- with .Values.volumeMounts }}
77+
volumeMounts:
78+
{{- toYaml . | nindent 12 }}
79+
{{- end }}
80+
{{- with .Values.volumes }}
81+
volumes:
82+
{{- toYaml . | nindent 8 }}
83+
{{- end }}
84+
{{- with .Values.nodeSelector }}
85+
nodeSelector:
86+
{{- toYaml . | nindent 8 }}
87+
{{- end }}
88+
{{- with .Values.affinity }}
89+
affinity:
90+
{{- toYaml . | nindent 8 }}
91+
{{- end }}
92+
{{- with .Values.tolerations }}
93+
tolerations:
94+
{{- toYaml . | nindent 8 }}
95+
{{- end }}
Lines changed: 32 additions & 0 deletions
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 "bricksllm.fullname" . }}
6+
labels:
7+
{{- include "bricksllm.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "bricksllm.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 }}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{- $fullname := include "bricksllm.fullname" . }}
2+
{{- $labels := include "bricksllm.labels" . }}
3+
{{- range $name, $v := .Values.ingresses }}
4+
{{- if $v.enabled }}
5+
---
6+
apiVersion: networking.k8s.io/v1
7+
kind: Ingress
8+
metadata:
9+
name: {{ $fullname }}-{{ $name }}
10+
labels:
11+
{{- $labels | nindent 4 }}
12+
{{- with $v.annotations }}
13+
annotations:
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
spec:
17+
{{- with $v.className }}
18+
ingressClassName: {{ . }}
19+
{{- end }}
20+
{{- if $v.tls }}
21+
tls:
22+
{{- range $v.tls }}
23+
- hosts:
24+
{{- range .hosts }}
25+
- {{ . | quote }}
26+
{{- end }}
27+
{{- with .secretName }}
28+
secretName: {{ . }}
29+
{{- end }}
30+
{{- end }}
31+
{{- end }}
32+
rules:
33+
{{- range $v.hosts }}
34+
- host: {{ .host | quote }}
35+
http:
36+
paths:
37+
{{- range .paths }}
38+
- path: {{ .path }}
39+
{{- with .pathType }}
40+
pathType: {{ . }}
41+
{{- end }}
42+
backend:
43+
service:
44+
name: {{ $fullname }}
45+
port:
46+
name: {{ $name | quote }}
47+
{{- end }}
48+
{{- end }}
49+
{{- end }}
50+
{{- end }}

0 commit comments

Comments
 (0)