Skip to content

Commit 101070c

Browse files
committed
Add helm chart
Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent 0b07e34 commit 101070c

23 files changed

Lines changed: 1501 additions & 6 deletions

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ python-version
4444
testenv/
4545
ptest/
4646
/node_modules/
47-
/package.json
48-
/package-lock.json
4947

50-
.claude/
48+
.claude/
49+
values-dev.yaml
50+
values-prod.yaml

Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Multi-stage Dockerfile for AlphaTrion Server
2+
# Stage 1: Build stage with uv for fast dependency installation
3+
FROM python:3.12-slim AS builder
4+
5+
# Install uv for faster pip operations
6+
RUN pip install --no-cache-dir uv
7+
8+
# Set working directory
9+
WORKDIR /app
10+
11+
# Copy dependency files and source code for installation
12+
COPY pyproject.toml ./
13+
COPY alphatrion/ ./alphatrion/
14+
15+
# Install dependencies and package using uv (non-editable for Docker)
16+
RUN uv pip install --system --no-cache .
17+
18+
# Stage 2: Runtime stage
19+
FROM python:3.12-slim
20+
21+
# Install runtime dependencies
22+
RUN apt-get update && \
23+
apt-get install -y --no-install-recommends \
24+
libpq5 \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Create non-root user
28+
RUN useradd -m -u 1000 alphatrion
29+
30+
# Set working directory
31+
WORKDIR /app
32+
33+
# Copy installed packages from builder
34+
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
35+
COPY --from=builder /usr/local/bin /usr/local/bin
36+
37+
# Copy application code
38+
COPY --chown=alphatrion:alphatrion alphatrion/ ./alphatrion/
39+
COPY --chown=alphatrion:alphatrion migrations/ ./migrations/
40+
COPY --chown=alphatrion:alphatrion alembic.ini ./
41+
42+
# Switch to non-root user
43+
USER alphatrion
44+
45+
# Expose port
46+
EXPOSE 8000
47+
48+
# Healthcheck
49+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
50+
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
51+
52+
# Run the application
53+
CMD ["alphatrion", "server", "--host", "0.0.0.0", "--port", "8000"]

dashboard/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ COPY . .
77
RUN npm run build
88

99
FROM nginx:alpine
10-
COPY --from=build /app/dist /usr/share/nginx/html
10+
COPY --from=build /app/static /usr/share/nginx/html
1111
COPY nginx.conf /etc/nginx/conf.d/default.conf
1212
EXPOSE 80
1313
CMD ["nginx", "-g", "daemon off;"]

helm-charts/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Helm dependency charts
2+
*/charts/
3+
*.tgz
4+
5+
# Helm lock file
6+
*/Chart.lock

helm-charts/QUICKSTART.md

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
# AlphaTrion Helm Chart - Quick Start Guide
2+
3+
This guide will help you quickly deploy AlphaTrion on Kubernetes using Helm.
4+
5+
## Prerequisites
6+
7+
- Kubernetes cluster (1.19+)
8+
- Helm 3.0+
9+
- kubectl configured to access your cluster
10+
- **PostgreSQL database** (external, version 12 or later)
11+
12+
## Quick Install (Local Development)
13+
14+
### 1. Build Docker Images
15+
16+
```bash
17+
# Build backend image
18+
docker build -t alphatrion-server:latest .
19+
20+
# Build dashboard image
21+
docker build -t alphatrion-dashboard:latest ./dashboard
22+
```
23+
24+
### 2. Load Images to Kubernetes (if using minikube/kind)
25+
26+
```bash
27+
# For minikube
28+
minikube image load alphatrion-server:latest
29+
minikube image load alphatrion-dashboard:latest
30+
31+
# For kind
32+
kind load docker-image alphatrion-server:latest
33+
kind load docker-image alphatrion-dashboard:latest
34+
```
35+
36+
### 3. Setup PostgreSQL Database
37+
38+
You need an external PostgreSQL database. For local development, you can quickly spin one up:
39+
40+
```bash
41+
# Using Docker
42+
docker run -d --name alphatrion-postgres \
43+
-e POSTGRES_DB=alphatrion \
44+
-e POSTGRES_USER=alphatrion \
45+
-e POSTGRES_PASSWORD=alphatr1on \
46+
-p 5432:5432 \
47+
postgres:16-alpine
48+
49+
# Or using Kubernetes
50+
kubectl run postgres --image=postgres:16-alpine \
51+
--env="POSTGRES_DB=alphatrion" \
52+
--env="POSTGRES_USER=alphatrion" \
53+
--env="POSTGRES_PASSWORD=alphatr1on" \
54+
--port=5432
55+
56+
kubectl expose pod postgres --port=5432 --target-port=5432
57+
```
58+
59+
### 4. Install Helm Chart
60+
61+
```bash
62+
# Install with PostgreSQL connection
63+
helm install alphatrion ./helm-charts/alphatrion \
64+
-f ./helm-charts/alphatrion/values-dev.yaml \
65+
--set postgresql.host=postgres \
66+
--set postgresql.password=alphatr1on
67+
```
68+
69+
**Note:** If using Docker PostgreSQL from your host, use `host.docker.internal` or your host IP instead of `postgres`.
70+
71+
### 5. Wait for Pods to Start
72+
73+
```bash
74+
kubectl get pods -l app.kubernetes.io/name=alphatrion -w
75+
```
76+
77+
### 6. Initialize AlphaTrion
78+
79+
```bash
80+
kubectl exec -it deploy/alphatrion-server -- alphatrion init \
81+
--username admin \
82+
--email admin@example.com
83+
```
84+
85+
Save the `USER_ID` and `TEAM_ID` from the output.
86+
87+
### 7. Access the Dashboard
88+
89+
```bash
90+
kubectl port-forward svc/alphatrion-dashboard 8080:80
91+
```
92+
93+
Visit http://localhost:8080 in your browser.
94+
95+
## Common Operations
96+
97+
### View Logs
98+
99+
```bash
100+
# Backend logs
101+
kubectl logs -l app.kubernetes.io/component=server -f
102+
103+
# Dashboard logs
104+
kubectl logs -l app.kubernetes.io/component=dashboard -f
105+
106+
# Migration logs
107+
kubectl logs job/alphatrion-migration
108+
```
109+
110+
### Access Backend API
111+
112+
```bash
113+
kubectl port-forward svc/alphatrion-server 8000:8000
114+
curl http://localhost:8000/health
115+
```
116+
117+
### Access PostgreSQL
118+
119+
```bash
120+
# If using Kubernetes PostgreSQL pod
121+
kubectl port-forward pod/postgres 5432:5432
122+
psql -h localhost -U alphatrion -d alphatrion
123+
# Password: alphatr1on (dev default)
124+
125+
# If using Docker PostgreSQL
126+
psql -h localhost -U alphatrion -d alphatrion
127+
# Password: alphatr1on (dev default)
128+
```
129+
130+
### Upgrade Release
131+
132+
```bash
133+
helm upgrade alphatrion ./helm-charts/alphatrion -f ./helm-charts/alphatrion/values-dev.yaml
134+
```
135+
136+
### Uninstall
137+
138+
```bash
139+
helm uninstall alphatrion
140+
141+
# Optionally delete PostgreSQL (if you created it for dev)
142+
kubectl delete pod postgres
143+
kubectl delete svc postgres
144+
145+
# Or if using Docker
146+
docker stop alphatrion-postgres
147+
docker rm alphatrion-postgres
148+
```
149+
150+
## Production Deployment
151+
152+
For production, use `values-prod.yaml` and customize it:
153+
154+
1. Update image repositories to your registry
155+
2. Configure your production PostgreSQL connection
156+
3. Enable ClickHouse for tracing
157+
4. Enable Docker Registry for artifacts
158+
5. Configure Ingress with TLS
159+
6. Set up proper secrets management
160+
161+
```bash
162+
# Copy and customize production values
163+
cp helm-charts/alphatrion/values-prod.yaml my-prod-values.yaml
164+
# Edit my-prod-values.yaml with your PostgreSQL host and other settings
165+
166+
# Create secret for PostgreSQL password
167+
kubectl create secret generic alphatrion-postgres-credentials \
168+
--from-literal=password=your-secure-password
169+
170+
# Install
171+
helm install alphatrion ./helm-charts/alphatrion -f my-prod-values.yaml
172+
```
173+
174+
## Troubleshooting
175+
176+
### Pods Not Starting
177+
178+
```bash
179+
# Check pod status
180+
kubectl get pods -l app.kubernetes.io/name=alphatrion
181+
182+
# Describe pod for events
183+
kubectl describe pod <pod-name>
184+
185+
# Check logs
186+
kubectl logs <pod-name>
187+
```
188+
189+
### Database Connection Issues
190+
191+
```bash
192+
# Check if PostgreSQL is ready
193+
kubectl get pods -l app.kubernetes.io/name=postgresql
194+
195+
# Check migration job logs
196+
kubectl logs job/alphatrion-migration
197+
198+
# Test database connection
199+
kubectl exec -it deploy/alphatrion-server -- sh -c 'python -c "import os; print(os.getenv(\"ALPHATRION_METADATA_DB_URL\"))"'
200+
```
201+
202+
### Migration Failures
203+
204+
```bash
205+
# View migration logs
206+
kubectl logs job/alphatrion-migration
207+
208+
# If you need to re-run migrations
209+
kubectl delete job alphatrion-migration
210+
helm upgrade alphatrion ./helm-charts/alphatrion
211+
```
212+
213+
## Using AlphaTrion in Your Application
214+
215+
After initialization, use AlphaTrion in your Python code:
216+
217+
```python
218+
import alphatrion as alpha
219+
220+
# Initialize with your USER_ID from the init command
221+
alpha.init(user_id='<YOUR_USER_ID>')
222+
223+
# Create an experiment
224+
experiment = alpha.create_experiment(
225+
name="my-experiment",
226+
description="My first experiment"
227+
)
228+
229+
# Track your GenAI application
230+
# ... your code here ...
231+
```
232+
233+
## Next Steps
234+
235+
- Read the full [README.md](alphatrion/README.md) for detailed configuration options
236+
- Check the [values.yaml](alphatrion/values.yaml) for all available settings
237+
- Review [values-dev.yaml](alphatrion/values-dev.yaml) and [values-prod.yaml](alphatrion/values-prod.yaml) for environment-specific examples
238+
239+
## Support
240+
241+
- Documentation: https://github.com/InftyAI/alphatrion
242+
- Issues: https://github.com/InftyAI/alphatrion/issues

helm-charts/alphatrion/.helmignore

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/

helm-charts/alphatrion/Chart.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v2
2+
name: alphatrion
3+
description: A Helm chart for deploying AlphaTrion - An open-source framework for GenAI applications
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.1"
7+
home: https://github.com/InftyAI/alphatrion
8+
maintainers:
9+
- name: InftyAI
10+
url: https://github.com/InftyAI

0 commit comments

Comments
 (0)