Skip to content

Commit de74643

Browse files
wip
1 parent e21b6d9 commit de74643

File tree

20 files changed

+1352
-819
lines changed

20 files changed

+1352
-819
lines changed

.github/workflows/test.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Unit Tests
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
unit-tests:
10+
name: Run Helm Unit Tests
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Helm
19+
uses: azure/setup-helm@v3
20+
with:
21+
version: v3.13.2
22+
23+
- name: Install helm-unittest plugin
24+
run: |
25+
helm plugin install https://github.com/helm-unittest/helm-unittest.git --version v1.0.0
26+
27+
- name: Update dependencies
28+
run: helm dependency update charts/sourcebot/
29+
30+
- name: Run unit tests
31+
run: |
32+
helm unittest charts/sourcebot/ --color --output-type JUnit --output-file test-results.xml
33+
34+
- name: Publish Test Results
35+
uses: EnricoMi/publish-unit-test-result-action@v2
36+
if: always()
37+
with:
38+
files: test-results.xml
39+
check_name: "Helm Unit Test Results"
40+
comment_title: "Helm Unit Test Results"

.github/workflows/validate.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Validate Helm Chart
2+
on:
3+
pull_request:
4+
paths:
5+
- 'charts/**'
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
validate:
12+
name: Validate Helm Chart
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Helm
21+
uses: azure/setup-helm@v3
22+
with:
23+
version: v3.13.2
24+
25+
- name: Install helm-docs
26+
run: |
27+
cd /tmp
28+
curl -L https://github.com/norwoodj/helm-docs/releases/download/v1.14.2/helm-docs_1.14.2_Linux_x86_64.tar.gz | tar xz
29+
sudo mv helm-docs /usr/local/bin/
30+
31+
- name: Update dependencies
32+
run: helm dependency update charts/
33+
34+
- name: Run helm lint
35+
run: helm lint charts/
36+
37+
- name: Validate helm-docs
38+
run: |
39+
helm-docs charts/
40+
if [[ $(git diff --stat) != '' ]]; then
41+
echo 'Chart documentation is out of date. Please run helm-docs and commit the changes.'
42+
echo 'Git diff:'
43+
git diff
44+
exit 1
45+
fi
46+

README.md

Lines changed: 270 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,270 @@
1-
# sourcebot-k8s
2-
Kubernetes config and Helm chart for Sourcebot
1+
# Sourcebot Helm Chart
2+
3+
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v4.7.3](https://img.shields.io/badge/AppVersion-v4.7.3-informational?style=flat-square)
4+
5+
The open source Sourcegraph alternative. Sourcebot gives you a powerful interface to search through all your repos and branches across multiple code hosts.
6+
7+
**Homepage:** <https://sourcebot.dev/>
8+
9+
## TL;DR
10+
11+
```bash
12+
# Create a secret with your credentials
13+
kubectl create secret generic sourcebot \
14+
--from-literal=postgresql-password=your-secure-password \
15+
--from-literal=redis-password=your-secure-password
16+
17+
# Add the Helm repository
18+
helm repo add sourcebot https://sourcebot-dev.github.io/sourcebot-helm-chart
19+
helm repo update
20+
21+
# Install Sourcebot
22+
helm install sourcebot sourcebot/sourcebot \
23+
--set postgresql.auth.existingSecret=sourcebot \
24+
--set redis.auth.existingSecret=sourcebot
25+
```
26+
27+
## Introduction
28+
29+
This chart bootstraps a Sourcebot deployment on a Kubernetes cluster using the Helm package manager.
30+
31+
By default, this chart deploys:
32+
- Sourcebot application
33+
- PostgreSQL database (via Bitnami subchart)
34+
- Redis/Valkey cache (via Bitnami subchart)
35+
36+
## Prerequisites
37+
38+
- Kubernetes 1.19+
39+
- Helm 3.x
40+
- PV provisioner support in the underlying infrastructure (for PostgreSQL and Sourcebot data persistence)
41+
42+
## Installing the Chart
43+
44+
### Quick Start
45+
46+
See the [minimal installation example](./examples/minimal-installation/) for a complete quick start guide.
47+
48+
### Step-by-Step Installation
49+
50+
1. **Create a Secret** with your database and Redis passwords:
51+
52+
```bash
53+
kubectl create secret generic sourcebot \
54+
--from-literal=postgresql-password=your-secure-password \
55+
--from-literal=redis-password=your-secure-password
56+
```
57+
58+
2. **Add the Helm Repository**:
59+
60+
```bash
61+
helm repo add sourcebot https://sourcebot-dev.github.io/sourcebot-helm-chart
62+
helm repo update
63+
```
64+
65+
3. **Install the Chart**:
66+
67+
```bash
68+
helm install sourcebot sourcebot/sourcebot \
69+
--set postgresql.auth.existingSecret=sourcebot \
70+
--set redis.auth.existingSecret=sourcebot
71+
```
72+
73+
Or using a values file:
74+
75+
```bash
76+
helm install sourcebot sourcebot/sourcebot -f values.yaml
77+
```
78+
79+
## Configuration
80+
81+
### Database Configuration
82+
83+
By default, PostgreSQL is deployed as a subchart. The chart automatically configures the connection using component-based environment variables (`DATABASE_HOST`, `DATABASE_USERNAME`, `DATABASE_PASSWORD`, etc.), which are assembled into `DATABASE_URL` by the application's entrypoint script.
84+
85+
#### Using the Deployed PostgreSQL Subchart
86+
87+
```yaml
88+
postgresql:
89+
deploy: true # Default
90+
auth:
91+
username: sourcebot
92+
database: sourcebot
93+
existingSecret: sourcebot
94+
secretKeys:
95+
userPasswordKey: postgresql-password
96+
adminPasswordKey: postgresql-password
97+
primary:
98+
persistence:
99+
enabled: true
100+
size: 8Gi
101+
```
102+
103+
#### Using an External PostgreSQL Instance
104+
105+
```yaml
106+
postgresql:
107+
deploy: false
108+
host: your-postgres-host.example.com
109+
port: 5432
110+
auth:
111+
username: sourcebot
112+
database: sourcebot
113+
existingSecret: sourcebot
114+
secretKeys:
115+
userPasswordKey: postgresql-password
116+
```
117+
118+
### Redis Configuration
119+
120+
Similar to PostgreSQL, Redis/Valkey can be deployed as a subchart or configured to use an external instance.
121+
122+
#### Using the Deployed Redis Subchart
123+
124+
```yaml
125+
redis:
126+
deploy: true # Default
127+
auth:
128+
username: default
129+
existingSecret: sourcebot
130+
existingSecretPasswordKey: redis-password
131+
```
132+
133+
#### Using an External Redis Instance
134+
135+
```yaml
136+
redis:
137+
deploy: false
138+
host: your-redis-host.example.com
139+
port: 6379
140+
auth:
141+
username: default
142+
existingSecret: sourcebot
143+
existingSecretPasswordKey: redis-password
144+
```
145+
146+
### Sourcebot Configuration
147+
148+
Configure your code repositories and other settings:
149+
150+
```yaml
151+
sourcebot:
152+
config:
153+
$schema: https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json
154+
connections:
155+
github-repos:
156+
type: github
157+
token:
158+
env: GITHUB_TOKEN
159+
repos:
160+
- owner/repo1
161+
- owner/repo2
162+
settings:
163+
reindexIntervalMs: 86400000 # 24 hours
164+
```
165+
166+
### Persistence Configuration
167+
168+
By default, Sourcebot uses persistent storage to retain repository data and search indexes across pod restarts:
169+
170+
```yaml
171+
sourcebot:
172+
persistence:
173+
enabled: true # Default
174+
size: 10Gi
175+
storageClass: "" # Uses cluster default
176+
accessModes:
177+
- ReadWriteOnce
178+
```
179+
180+
To use an existing PersistentVolumeClaim:
181+
182+
```yaml
183+
sourcebot:
184+
persistence:
185+
enabled: true
186+
existingClaim: my-existing-pvc
187+
```
188+
189+
To disable persistence (not recommended for production):
190+
191+
```yaml
192+
sourcebot:
193+
persistence:
194+
enabled: false
195+
```
196+
197+
### Ingress Configuration
198+
199+
Enable ingress to expose Sourcebot:
200+
201+
```yaml
202+
sourcebot:
203+
ingress:
204+
enabled: true
205+
className: nginx
206+
annotations:
207+
cert-manager.io/cluster-issuer: letsencrypt-prod
208+
hosts:
209+
- host: sourcebot.example.com
210+
paths:
211+
- path: /
212+
pathType: Prefix
213+
tls:
214+
- hosts:
215+
- sourcebot.example.com
216+
secretName: sourcebot-tls
217+
```
218+
219+
### Resource Limits
220+
221+
Set appropriate resource limits for production:
222+
223+
```yaml
224+
sourcebot:
225+
resources:
226+
requests:
227+
cpu: 1000m
228+
memory: 2Gi
229+
limits:
230+
cpu: 2000m
231+
memory: 4Gi
232+
```
233+
234+
## Examples
235+
236+
Check out the [examples directory](./examples/) for complete configuration examples:
237+
238+
- [Minimal Installation](./examples/minimal-installation/) - Basic setup with subcharts
239+
- More examples coming soon!
240+
241+
## Upgrading
242+
243+
### To a New Version
244+
245+
```bash
246+
helm upgrade sourcebot sourcebot/sourcebot -f values.yaml
247+
```
248+
249+
### Major Version Upgrades
250+
251+
Always check the [CHANGELOG](../../CHANGELOG.md) for breaking changes before upgrading between major versions.
252+
253+
## Uninstalling
254+
255+
To uninstall/delete the `sourcebot` deployment:
256+
257+
```bash
258+
helm uninstall sourcebot
259+
```
260+
261+
This removes all Kubernetes components associated with the chart but **preserves PersistentVolumeClaims (PVCs) by default**. This includes:
262+
- `sourcebot-data` - Sourcebot repository data and search indexes
263+
- `data-sourcebot-postgresql-0` - PostgreSQL data (if deployed)
264+
- `valkey-data-sourcebot-redis-*` - Redis data (if deployed)
265+
266+
To also remove all PVCs (⚠️ **this will delete all your data**):
267+
268+
```bash
269+
kubectl delete pvc -l app.kubernetes.io/instance=sourcebot
270+
```

charts/Chart.lock

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
dependencies:
22
- name: postgresql
3-
repository: https://charts.bitnami.com/bitnami
4-
version: 16.7.27
5-
digest: sha256:ab3541612e8857c2d08d46f83cab79fa87b6ae6148e2d64d7d2b06729a520ce1
6-
generated: "2025-09-25T12:57:56.528976+01:00"
3+
repository: oci://registry-1.docker.io/bitnamicharts
4+
version: 16.4.9
5+
- name: valkey
6+
repository: oci://registry-1.docker.io/bitnamicharts
7+
version: 2.2.4
8+
digest: sha256:28d343e1aa714ee58c72ef16adba0ba062f34adb9b4003a3eb2b0d9bef4684cc
9+
generated: "2025-10-20T14:50:50.647988-07:00"

0 commit comments

Comments
 (0)