Skip to content

Commit 5670eb8

Browse files
authored
Update helm chart (#184)
* add helm chart Signed-off-by: kerthcet <kerthcet@gmail.com> * add helm chart Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent d284a3d commit 5670eb8

12 files changed

Lines changed: 1433 additions & 10 deletions

helm-charts/QUICKSTART.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This guide will help you quickly deploy AlphaTrion on Kubernetes using Helm.
88
- Helm 3.0+
99
- kubectl configured to access your cluster
1010
- **PostgreSQL database** (external, version 12 or later)
11+
- **ClickHouse database** (optional, for tracing - see [Quick ClickHouse Setup](#optional-clickhouse-setup))
1112

1213
## Quick Install (Local Development)
1314

@@ -92,6 +93,50 @@ kubectl port-forward svc/alphatrion-dashboard 8080:80
9293

9394
Visit http://localhost:8080 in your browser.
9495

96+
## Optional: ClickHouse Setup
97+
98+
If you want to enable tracing support with ClickHouse, you have two options:
99+
100+
### Option A: Single Node (Development/Testing)
101+
102+
```bash
103+
# 1. Create gp3 storage class (AWS only)
104+
kubectl apply -f ./helm-charts/clickhouse/storageclass-gp3.yaml
105+
106+
# 2. Deploy single-node ClickHouse
107+
kubectl apply -f ./helm-charts/clickhouse/clickhouse-statefulset.yaml
108+
109+
# 3. Verify
110+
kubectl get pods -n alphatrion -l app=clickhouse
111+
kubectl exec -n alphatrion clickhouse-0 -- clickhouse-client --query "SELECT version()"
112+
```
113+
114+
### Option B: High Availability (Production)
115+
116+
For production workloads with automatic failover and data replication:
117+
118+
```bash
119+
# 1. Create gp3 storage class (AWS only)
120+
kubectl apply -f ./helm-charts/clickhouse/storageclass-gp3.yaml
121+
122+
# 2. Deploy HA cluster (3 replicas + 3 keeper nodes)
123+
./helm-charts/clickhouse/deploy-ha.sh
124+
125+
# Or manually:
126+
kubectl apply -f ./helm-charts/clickhouse/clickhouse-ha.yaml
127+
```
128+
129+
See [HA Setup Guide](./clickhouse/HA-SETUP.md) for detailed instructions and migration guide.
130+
131+
### Connect AlphaTrion to ClickHouse
132+
133+
```bash
134+
helm upgrade alphatrion ./helm-charts/alphatrion \
135+
-f ./helm-charts/alphatrion/values-with-clickhouse.yaml
136+
```
137+
138+
For more details, see the [ClickHouse deployment guide](./clickhouse/README.md).
139+
95140
## Common Operations
96141

97142
### View Logs

helm-charts/alphatrion/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ AlphaTrion requires an external PostgreSQL database. Configure the connection de
9595
| `postgresql.username` | PostgreSQL username | `alphatrion` |
9696
| `postgresql.password` | PostgreSQL password | `""` |
9797
| `postgresql.existingSecret` | Existing secret for PostgreSQL password (recommended) | `""` |
98-
| `postgresql.initTables` | Automatically initialize database tables | `true` |
98+
| `postgresql.initTables` | Automatically initialize database tables | `false` |
9999

100100
### Ingress Configuration
101101

helm-charts/alphatrion/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ ClickHouse secret name
165165
{{- if .Values.clickhouse.existingSecret }}
166166
{{- .Values.clickhouse.existingSecret }}
167167
{{- else }}
168-
{{- printf "%s-clickhouse" (include "alphatrion.fullname" .) }}
168+
{{- include "alphatrion.server.fullname" . }}
169169
{{- end }}
170170
{{- end }}
171171

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{{- if .Values.clickhouse.enabled }}
2+
{{- if .Values.clickhouse.clusterName }}
3+
apiVersion: batch/v1
4+
kind: Job
5+
metadata:
6+
name: {{ include "alphatrion.fullname" . }}-clickhouse-migration
7+
labels:
8+
{{- include "alphatrion.labels" . | nindent 4 }}
9+
app.kubernetes.io/component: clickhouse-migration
10+
annotations:
11+
"helm.sh/hook": pre-install,pre-upgrade
12+
"helm.sh/hook-weight": "-4"
13+
"helm.sh/hook-delete-policy": before-hook-creation
14+
spec:
15+
backoffLimit: 3
16+
template:
17+
metadata:
18+
labels:
19+
{{- include "alphatrion.selectorLabels" . | nindent 8 }}
20+
app.kubernetes.io/component: clickhouse-migration
21+
spec:
22+
restartPolicy: Never
23+
containers:
24+
- name: clickhouse-migration
25+
image: clickhouse/clickhouse-server:24.3-alpine
26+
command:
27+
- sh
28+
- -c
29+
- |
30+
set -e
31+
echo "=========================================="
32+
echo "ClickHouse Cluster Table Migration"
33+
echo "=========================================="
34+
echo ""
35+
echo "Cluster: {{ .Values.clickhouse.clusterName }}"
36+
echo "Database: {{ .Values.clickhouse.database }}"
37+
echo ""
38+
39+
# Wait for ClickHouse to be ready
40+
echo "Waiting for ClickHouse to be ready..."
41+
until clickhouse-client --host {{ .Values.clickhouse.host }} --port 9000 \
42+
--user {{ .Values.clickhouse.username }} --password "$CLICKHOUSE_PASSWORD" \
43+
--query "SELECT 1" > /dev/null 2>&1; do
44+
echo " Waiting for ClickHouse..."
45+
sleep 2
46+
done
47+
echo "✓ ClickHouse is ready"
48+
echo ""
49+
50+
# Check if cluster exists
51+
echo "Checking if cluster '{{ .Values.clickhouse.clusterName }}' exists..."
52+
CLUSTER_EXISTS=$(clickhouse-client --host {{ .Values.clickhouse.host }} --port 9000 \
53+
--user {{ .Values.clickhouse.username }} --password "$CLICKHOUSE_PASSWORD" \
54+
--query "SELECT count() FROM system.clusters WHERE cluster='{{ .Values.clickhouse.clusterName }}'" 2>/dev/null || echo "0")
55+
56+
if [ "$CLUSTER_EXISTS" -eq "0" ]; then
57+
echo "✗ Cluster '{{ .Values.clickhouse.clusterName }}' not found!"
58+
echo " Please configure ClickHouse cluster first."
59+
exit 1
60+
fi
61+
echo "✓ Cluster exists"
62+
echo ""
63+
64+
# Drop old non-replicated table if exists
65+
echo "Dropping old non-replicated tables (if any)..."
66+
clickhouse-client --host {{ .Values.clickhouse.host }} --port 9000 \
67+
--user {{ .Values.clickhouse.username }} --password "$CLICKHOUSE_PASSWORD" \
68+
--query "DROP TABLE IF EXISTS {{ .Values.clickhouse.database }}.otel_spans ON CLUSTER {{ .Values.clickhouse.clusterName }} SYNC" \
69+
2>/dev/null || echo " No existing table to drop"
70+
echo "✓ Old tables dropped"
71+
echo ""
72+
73+
# Create replicated table on cluster
74+
echo "Creating replicated table on cluster..."
75+
clickhouse-client --host {{ .Values.clickhouse.host }} --port 9000 \
76+
--user {{ .Values.clickhouse.username }} --password "$CLICKHOUSE_PASSWORD" \
77+
--multiquery <<'EOF'
78+
CREATE TABLE IF NOT EXISTS {{ .Values.clickhouse.database }}.otel_spans ON CLUSTER {{ .Values.clickhouse.clusterName }} (
79+
Timestamp DateTime64(9) CODEC(Delta, ZSTD(1)),
80+
TraceId String CODEC(ZSTD(1)),
81+
SpanId String CODEC(ZSTD(1)),
82+
ParentSpanId String CODEC(ZSTD(1)),
83+
SpanName LowCardinality(String) CODEC(ZSTD(1)),
84+
SpanKind LowCardinality(String) CODEC(ZSTD(1)),
85+
SemanticKind LowCardinality(String) CODEC(ZSTD(1)),
86+
ServiceName LowCardinality(String) CODEC(ZSTD(1)),
87+
Duration UInt64 CODEC(ZSTD(1)),
88+
StatusCode LowCardinality(String) CODEC(ZSTD(1)),
89+
StatusMessage String CODEC(ZSTD(1)),
90+
TeamId String CODEC(ZSTD(1)),
91+
RunId String CODEC(ZSTD(1)),
92+
ExperimentId String CODEC(ZSTD(1)),
93+
SpanAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
94+
ResourceAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
95+
Events Nested(
96+
Timestamp DateTime64(9),
97+
Name LowCardinality(String),
98+
Attributes Map(LowCardinality(String), String)
99+
) CODEC(ZSTD(1)),
100+
Links Nested(
101+
TraceId String,
102+
SpanId String,
103+
Attributes Map(LowCardinality(String), String)
104+
) CODEC(ZSTD(1)),
105+
INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1,
106+
INDEX idx_span_id SpanId TYPE bloom_filter(0.001) GRANULARITY 1,
107+
INDEX idx_run_id RunId TYPE bloom_filter(0.001) GRANULARITY 1,
108+
INDEX idx_team_id TeamId TYPE bloom_filter(0.001) GRANULARITY 1,
109+
INDEX idx_semantic_kind SemanticKind TYPE set(0) GRANULARITY 1,
110+
INDEX idx_attr_keys mapKeys(SpanAttributes) TYPE bloom_filter(0.01) GRANULARITY 1
111+
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/otel_spans', '{replica}')
112+
PARTITION BY toDate(Timestamp)
113+
ORDER BY (ServiceName, toUnixTimestamp(Timestamp))
114+
SETTINGS index_granularity = 8192;
115+
EOF
116+
117+
echo "✓ Replicated table created"
118+
echo ""
119+
120+
# Verify table exists locally
121+
echo "Verifying table creation..."
122+
TABLE_COUNT=$(clickhouse-client --host {{ .Values.clickhouse.host }} --port 9000 \
123+
--user {{ .Values.clickhouse.username }} --password "$CLICKHOUSE_PASSWORD" \
124+
--query "SELECT count() FROM system.tables WHERE database = '{{ .Values.clickhouse.database }}' AND name = 'otel_spans'")
125+
126+
if [ "$TABLE_COUNT" -eq "1" ]; then
127+
echo "✓ Table 'otel_spans' verified"
128+
else
129+
echo "✗ Table verification failed!"
130+
exit 1
131+
fi
132+
133+
echo ""
134+
echo "=========================================="
135+
echo "✓ Migration completed successfully!"
136+
echo "=========================================="
137+
env:
138+
- name: CLICKHOUSE_PASSWORD
139+
valueFrom:
140+
secretKeyRef:
141+
name: {{ include "alphatrion.clickhouse.secretName" . }}
142+
key: clickhouse-password
143+
{{- end }}
144+
{{- end }}

helm-charts/alphatrion/templates/dashboard-deployment.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ spec:
4646
{{- end }}
4747
image: "{{ .Values.dashboard.image.repository }}:{{ .Values.dashboard.image.tag }}"
4848
imagePullPolicy: {{ .Values.dashboard.image.pullPolicy }}
49+
50+
# TODO: Remove after quantinuum-nvidia collaboration is done.
51+
env:
52+
- name: ALPHATRION_DASHBOARD_USER_ID
53+
value: {{ .Values.dashboard.userId | quote }}
54+
{{- if .Values.dashboard.teamId }}
55+
- name: ALPHATRION_DASHBOARD_TEAM_ID
56+
value: {{ .Values.dashboard.teamId | quote }}
57+
{{- end }}
58+
4959
ports:
5060
- name: http
5161
containerPort: 8080

helm-charts/alphatrion/templates/server-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ spec:
6666
valueFrom:
6767
secretKeyRef:
6868
name: {{ include "alphatrion.clickhouse.secretName" . }}
69-
key: password
69+
key: clickhouse-password
7070
{{- end }}
7171

7272
envFrom:

helm-charts/alphatrion/values.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,26 @@ postgresql:
9797
# Use existing secret for password (key should be 'password')
9898
existingSecret: ""
9999
# Automatically initialize database tables on first run
100-
initTables: true
100+
initTables: false
101101

102102
# ClickHouse configuration (optional - for tracing)
103103
clickhouse:
104104
enabled: false
105-
host: ""
105+
host: "clickhouse.alphatrion.svc.cluster.local"
106106
port: 8123
107-
database: alphatrion_tracing
108-
username: default
109-
password: ""
107+
database: alphatrion_traces
108+
username: alphatrion
109+
password: "alphatrion"
110110
# Use existing secret for password (key should be 'password')
111111
existingSecret: ""
112112
# Automatically initialize tables
113-
initTables: true
113+
initTables: false
114114
# Enable batch operations for better performance
115115
enableBatch: true
116+
# Cluster name for HA ClickHouse (triggers migration job for ReplicatedMergeTree)
117+
# Leave empty for single-node setup (manual table creation required)
118+
# Migration job will create replicated tables across the cluster
119+
clusterName: ""
116120

117121
# Docker Registry configuration (optional - for artifact storage)
118122
registry:
@@ -180,7 +184,7 @@ affinity: {}
180184

181185
# Migration job configuration
182186
migration:
183-
enabled: true
187+
enabled: false
184188
resources:
185189
requests:
186190
cpu: 100m

0 commit comments

Comments
 (0)