Skip to content

Commit 2c7bba6

Browse files
authored
Feat/self hosted (#10)
* Update API environment variables and ingress rules Renamed environment variables in swanlab-next deployment for clarity (API_VERIFIER_URL and API_INTERNAL_URL). Modified traefik ingress rules to require 'X-Requested-By: swanlab-next' header and added a new route for /api/house. * Refactor ingress TLS config and add schema validation Replaces 'tls' with 'tlsSecret' in ingress configuration and templates for clarity. Adds a comprehensive JSON schema for Helm values to enforce validation. Updates deployment to set persistentVolumeClaimRetentionPolicy for swanlab-house. Improves documentation and configuration options for Traefik initContainers. * Refactor house service schema and values structure Updated the house service schema in values.schema.json to explicitly define all properties instead of using allOf with standardService. Adjusted values.yaml to move logImage and fbImage under a dedicated section with a TODO for future removal. Also relaxed schema restrictions for traefik and providers to allow additional properties. * Update Helm chart for SwanLab 2.5.0 release Bump chart version to 0.1.5 and appVersion to 2.5.0. Add ttlSecondsAfterFinished to S3 init job. Support API_DISPLAY_HOST env in swanlab-next deployment. Remove X-Requested-By header requirement from Traefik ingress rules. Add port field to integrations documentation in values.yaml. * Rename apiHost to loginHost in Helm chart config Replaces the 'apiHost' environment variable and schema property with 'loginHost' for clarity in the Swanlab Next deployment. Updates deployment template, values.yaml, and values.schema.json accordingly. * Replace replicaCount with replicas in Helm chart values Updated deployment templates and values files to use 'replicas' instead of 'replicaCount' for service configuration. Removed 'replicaCount' from values.yaml and values.schema.json to standardize replica configuration across all services. * Add retainPVC option for house service PVC retention Introduces a retainPVC boolean to control persistent volume claim retention for the swanlab-house service. Updates deployment template, values schema, and values file to support conditional PVC retention on deletion or scaling.
1 parent c7109a8 commit 2c7bba6

11 files changed

Lines changed: 331 additions & 38 deletions

File tree

.idea/dictionaries/project.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/self-hosted/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ description: A Helm chart for deploying SwanLab, an open-source ML experiment tr
55
icon: https://raw.githubusercontent.com/SwanHubX/charts/main/assets/icon.png
66
home: https://swanlab.cn
77
type: application
8-
version: 0.1.4
9-
appVersion: "2.4"
8+
version: 0.1.5
9+
appVersion: 2.5.0
1010
keywords:
1111
- swanlab
1212
- ml-ops

charts/self-hosted/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ Application Ingress Host
5353
Application Ingress TLS Secret Name
5454
*/}}
5555
{{- define "swanlab.tls" -}}
56-
{{- .Values.ingress.tls | default "" | trim -}}
56+
{{- .Values.ingress.tlsSecret | default "" | trim -}}
5757
{{- end -}}
5858

charts/self-hosted/templates/s3/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ kind: Job
9494
metadata:
9595
name: {{ include "swanlab.s3.fullname" . }}-init-buckets
9696
spec:
97+
ttlSecondsAfterFinished: 3600
9798
completions: 1
9899
template:
99100
spec:

charts/self-hosted/templates/swanlab-cloud/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
labels:
66
{{- include "swanlab.cloud.labels" . | nindent 4 }}
77
spec:
8-
replicas: {{ default 0 .Values.service.cloud.replicaCount }}
8+
replicas: {{ default 0 .Values.service.cloud.replicas }}
99
selector:
1010
matchLabels:
1111
{{- include "swanlab.cloud.selectorLabels" . | nindent 6 }}

charts/self-hosted/templates/swanlab-house/deployment.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ spec:
1212
spec:
1313
accessModes:
1414
- ReadWriteOnce
15-
storageClassName: {{.Values.service.house.persistence.storageClass}}
15+
storageClassName: {{.Values.service.house.persistence.storageClass }}
1616
resources:
1717
requests:
18-
storage: {{.Values.service.house.persistence.storageSize}}
19-
replicas: {{ default 0 .Values.service.house.replicaCount }}
18+
storage: {{.Values.service.house.persistence.storageSize }}
19+
persistentVolumeClaimRetentionPolicy:
20+
{{- if .Values.service.house.retainPVC }}
21+
whenDeleted: Delete
22+
whenScaled: Delete
23+
{{- end }}
24+
replicas: {{ default 0 .Values.service.house.replicas }}
2025
selector:
2126
matchLabels:
2227
{{- include "swanlab.house.selectorLabels" . | nindent 6 }}

charts/self-hosted/templates/swanlab-next/deployment.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
labels:
66
{{- include "swanlab.next.labels" . | nindent 4 }}
77
spec:
8-
replicas: {{ default 0 .Values.service.next.replicaCount }}
8+
replicas: {{ default 0 .Values.service.next.replicas }}
99
selector:
1010
matchLabels:
1111
{{- include "swanlab.next.selectorLabels" . | nindent 6 }}
@@ -99,10 +99,14 @@ spec:
9999
value: "http://{{ include "swanlab.cloud.fullname" . }}:{{include "swanlab.cloud.port" . }}"
100100
- name: API_URL
101101
value: "http://{{ include "swanlab.traefik.fullname" . }}:80/api"
102-
- name: VERIFIER_URL
102+
- name: API_VERIFIER_URL
103103
value: {{ include "swanlab.server.identify" . | quote }}
104-
- name: INTERNAL_API_URL
104+
- name: API_INTERNAL_URL
105105
value: "http://{{ include "swanlab.traefik.fullname" . }}:80/api"
106+
{{- if .Values.env.loginHost }}
107+
- name: API_DISPLAY_HOST
108+
value: {{ .Values.env.loginHost | quote }}
109+
{{- end }}
106110
{{- if .Values.service.next.resources }}
107111
resources:
108112
{{- toYaml .Values.service.next.resources | nindent 12 }}

charts/self-hosted/templates/swanlab-server/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
labels:
66
{{- include "swanlab.server.labels" . | nindent 4 }}
77
spec:
8-
replicas: {{ default 0 .Values.service.server.replicaCount }}
8+
replicas: {{ default 0 .Values.service.server.replicas }}
99
selector:
1010
matchLabels:
1111
{{- include "swanlab.server.selectorLabels" . | nindent 6 }}

charts/self-hosted/templates/traefik/ingress.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,24 @@ spec:
1717
entryPoints:
1818
- web
1919
routes:
20+
{{/* - match: PathPrefix(`/api`) && Header(`X-Requested-By`, `swanlab-next`)*/}}
2021
- match: PathPrefix(`/api`)
2122
kind: Rule
2223
middlewares:
2324
- name: {{ $identify }}
2425
services:
2526
- name: {{ $server }}
2627
port: {{ $serverPort }}
27-
28+
{{/* - match: PathPrefix(`/api/house`) && Header(`X-Requested-By`, `swanlab-next`)*/}}
29+
- match: PathPrefix(`/api/house`)
30+
kind: Rule
31+
middlewares:
32+
- name: {{ $identify }}
33+
services:
34+
- name: {{ $house }}
35+
port: {{ $housePort }}
2836
---
29-
{{- $tls := .Values.ingress.tls }}
37+
{{- $tls := .Values.ingress.tlsSecret }}
3038
{{- $host := .Values.ingress.host }}
3139

3240
apiVersion: traefik.io/v1alpha1
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "SwanLab Self-Hosted Values",
4+
"description": "Schema for SwanLab Self-Hosted Helm Chart",
5+
"type": "object",
6+
"additionalProperties": false,
7+
"properties": {
8+
"nameOverride": {
9+
"type": "string"
10+
},
11+
"fullnameOverride": {
12+
"type": "string"
13+
},
14+
"imagePullSecrets": {
15+
"type": "array",
16+
"items": {
17+
"type": "object",
18+
"required": ["name"],
19+
"properties": {
20+
"name": { "type": "string" }
21+
}
22+
}
23+
},
24+
"helper": {
25+
"type": "object",
26+
"additionalProperties": false,
27+
"properties": {
28+
"repository": { "type": "string" },
29+
"tag": { "type": "string" },
30+
"pullPolicy": {
31+
"type": "string",
32+
"enum": ["IfNotPresent", "Always", "Never"]
33+
}
34+
}
35+
},
36+
"service": {
37+
"type": "object",
38+
"additionalProperties": false,
39+
"properties": {
40+
"server": { "$ref": "#/definitions/standardService" },
41+
"house": {
42+
"type": "object",
43+
"additionalProperties": false,
44+
"description": "House service has standard fields PLUS extra images and persistence",
45+
"properties": {
46+
"fullnameOverride": { "type": "string" },
47+
"replicas": { "type": "integer" },
48+
"image": { "$ref": "#/definitions/imageConfig" },
49+
"customLabels": { "type": "object" },
50+
"customAnnotations": { "type": "object" },
51+
"customTolerations": { "type": "array" },
52+
"customNodeSelector": { "type": "object" },
53+
"resources": { "type": "object" },
54+
55+
"logImage": { "$ref": "#/definitions/imageConfig" },
56+
"fbImage": { "$ref": "#/definitions/imageConfig" },
57+
"persistence": { "$ref": "#/definitions/persistenceConfig" },
58+
"retainPVC": { "type": "boolean" }
59+
}
60+
},
61+
"cloud": { "$ref": "#/definitions/standardService" },
62+
"next": { "$ref": "#/definitions/standardService" }
63+
}
64+
},
65+
"env": {
66+
"type": "object",
67+
"additionalProperties": false,
68+
"properties": {
69+
"loginHost": { "type": "string" }
70+
}
71+
},
72+
"dependencies": {
73+
"type": "object",
74+
"additionalProperties": false,
75+
"properties": {
76+
"postgres": {
77+
"type": "object",
78+
"additionalProperties": false,
79+
"properties": {
80+
"fullnameOverride": { "type": "string" },
81+
"image": { "$ref": "#/definitions/imageConfig" },
82+
"username": { "type": "string" },
83+
"password": { "type": "string" },
84+
"persistence": { "$ref": "#/definitions/persistenceConfig" },
85+
"customLabels": { "type": "object" },
86+
"customAnnotations": { "type": "object" },
87+
"customTolerations": { "type": "array" },
88+
"customNodeSelector": { "type": "object" },
89+
"resources": { "type": "object" }
90+
}
91+
},
92+
"redis": {
93+
"type": "object",
94+
"additionalProperties": false,
95+
"properties": {
96+
"fullnameOverride": { "type": "string" },
97+
"image": { "$ref": "#/definitions/imageConfig" },
98+
"persistence": { "$ref": "#/definitions/persistenceConfig" },
99+
"customLabels": { "type": "object" },
100+
"customAnnotations": { "type": "object" },
101+
"customTolerations": { "type": "array" },
102+
"customNodeSelector": { "type": "object" },
103+
"resources": { "type": "object" }
104+
}
105+
},
106+
"clickhouse": {
107+
"type": "object",
108+
"additionalProperties": false,
109+
"properties": {
110+
"fullnameOverride": { "type": "string" },
111+
"image": { "$ref": "#/definitions/imageConfig" },
112+
"username": { "type": "string" },
113+
"password": { "type": "string" },
114+
"persistence": { "$ref": "#/definitions/persistenceConfig" },
115+
"customLabels": { "type": "object" },
116+
"customAnnotations": { "type": "object" },
117+
"customTolerations": { "type": "array" },
118+
"customNodeSelector": { "type": "object" },
119+
"resources": { "type": "object" }
120+
}
121+
},
122+
"s3": {
123+
"type": "object",
124+
"additionalProperties": false,
125+
"properties": {
126+
"fullnameOverride": { "type": "string" },
127+
"image": { "$ref": "#/definitions/imageConfig" },
128+
"mcImage": { "$ref": "#/definitions/imageConfig" },
129+
"accessKey": { "type": "string" },
130+
"secretKey": { "type": "string" },
131+
"persistence": { "$ref": "#/definitions/persistenceConfig" },
132+
"customLabels": { "type": "object" },
133+
"customAnnotations": { "type": "object" },
134+
"customTolerations": { "type": "array" },
135+
"customNodeSelector": { "type": "object" },
136+
"resources": { "type": "object" }
137+
}
138+
}
139+
}
140+
},
141+
"integrations": {
142+
"type": "object",
143+
"additionalProperties": false,
144+
"properties": {
145+
"postgres": { "$ref": "#/definitions/integrationConfig" },
146+
"redis": { "$ref": "#/definitions/integrationConfig" },
147+
"clickhouse": { "$ref": "#/definitions/integrationConfig" },
148+
"s3": { "$ref": "#/definitions/integrationConfig" }
149+
}
150+
},
151+
"ingress": {
152+
"type": "object",
153+
"additionalProperties": false,
154+
"properties": {
155+
"tlsSecret": { "type": "string" },
156+
"host": { "type": "string" },
157+
"test": {
158+
"type": "object",
159+
"additionalProperties": false,
160+
"properties": {
161+
"image": {
162+
"type": "object",
163+
"additionalProperties": false,
164+
"properties": {
165+
"registry": { "type": "string" },
166+
"repository": { "type": "string" },
167+
"tag": { "type": "string" },
168+
"pullPolicy": {
169+
"type": "string",
170+
"enum": ["IfNotPresent", "Always", "Never"]
171+
}
172+
}
173+
},
174+
"imagePullSecrets": { "type": "array" }
175+
}
176+
},
177+
"global": {
178+
"type": "object"
179+
},
180+
"traefik": {
181+
"type": "object",
182+
"description": "Traefik configuration. We allow additional properties here because Traefik has many native fields.",
183+
"properties": {
184+
"image": {
185+
"type": "object",
186+
"properties": {
187+
"registry": { "type": "string" },
188+
"repository": { "type": "string" },
189+
"tag": { "type": "string" }
190+
}
191+
},
192+
"service": {
193+
"type": "object",
194+
"properties": {
195+
"type": { "type": "string" }
196+
}
197+
},
198+
"deployment": {
199+
"type": "object",
200+
"properties": {
201+
"replicas": { "type": "integer" },
202+
"initContainers": {
203+
"type": "array",
204+
"items": {
205+
"type": "object",
206+
"required": ["name", "image"],
207+
"properties": {
208+
"name": { "type": "string" },
209+
"image": { "type": "string" },
210+
"env": { "type": "array" },
211+
"volumeMounts": { "type": "array" }
212+
}
213+
}
214+
}
215+
}
216+
},
217+
"providers": {
218+
"type": "object"
219+
}
220+
}
221+
}
222+
}
223+
}
224+
},
225+
"definitions": {
226+
"imageConfig": {
227+
"type": "object",
228+
"additionalProperties": false,
229+
"properties": {
230+
"repository": { "type": "string" },
231+
"tag": { "type": "string" },
232+
"pullPolicy": {
233+
"type": "string",
234+
"enum": ["IfNotPresent", "Always", "Never"]
235+
}
236+
}
237+
},
238+
"persistenceConfig": {
239+
"type": "object",
240+
"additionalProperties": false,
241+
"properties": {
242+
"storageClass": { "type": "string" },
243+
"storageSize": { "type": "string" },
244+
"existingClaim": { "type": "string" }
245+
}
246+
},
247+
"standardService": {
248+
"type": "object",
249+
"additionalProperties": false,
250+
"properties": {
251+
"fullnameOverride": { "type": "string" },
252+
"replicas": { "type": "integer" },
253+
"image": { "$ref": "#/definitions/imageConfig" },
254+
"customLabels": { "type": "object" },
255+
"customAnnotations": { "type": "object" },
256+
"customTolerations": { "type": "array" },
257+
"customNodeSelector": { "type": "object" },
258+
"resources": { "type": "object" }
259+
}
260+
},
261+
"integrationConfig": {
262+
"type": "object",
263+
"additionalProperties": false,
264+
"properties": {
265+
"enabled": { "type": "boolean" },
266+
"existingSecret": { "type": "string" }
267+
}
268+
}
269+
}
270+
}

0 commit comments

Comments
 (0)