Skip to content

Commit fecd477

Browse files
committed
Chart refactoring
1 parent 5ea88b3 commit fecd477

File tree

11 files changed

+86
-38
lines changed

11 files changed

+86
-38
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ __pycache__/
88
**/.ruff_cache
99

1010
# Ignore local dev helpers
11-
test-values.y[a]ml
11+
**/dev-values.yml
1212
**venv*/
1313

1414
# Helm chart stuff

charts/flux-image-gen/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ version: 0.1.0
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "4339cc5"
24+
appVersion: "02aeef3"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
models:
2+
- flux-dev
3+
- flux-schnell
4+
api:
5+
# Run in dev mode so that we skip
6+
# the image gen step and can therefore
7+
# test in a kind cluster
8+
commandOverride:
9+
- fastapi
10+
- dev
11+
- stackhpc-app/api_server.py
12+
- --host
13+
- "0.0.0.0"

charts/flux-image-gen/templates/_helpers.tpl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,20 @@ app.kubernetes.io/instance: {{ .Release.Name }}
5151
{{- end }}
5252

5353
{{/*
54-
Selector labels
54+
Model selector labels
5555
*/}}
5656
{{- define "flux-image-gen.modelLabels" -}}
5757
app.kubernetes.io/component: {{ . }}-api
5858
{{- end }}
5959

60+
{{/*
61+
UI selector labels
62+
*/}}
63+
{{- define "flux-image-gen.uiLabels" -}}
64+
app.kubernetes.io/component: {{ .Release.Name }}-ui
65+
{{- end }}
66+
67+
6068
{{/*
6169
Create the name of the service account to use
6270
*/}}

charts/flux-image-gen/templates/api/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ spec:
4242
{{- toYaml $.Values.api.securityContext | nindent 12 }}
4343
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
4444
imagePullPolicy: {{ $.Values.image.pullPolicy }}
45+
{{- with $.Values.api.commandOverride }}
46+
{{- if . }}
47+
command:
48+
{{- . | toYaml | nindent 12 }}
49+
{{- end }}
50+
{{- end }}
4551
ports:
4652
- name: http
4753
containerPort: {{ $.Values.api.service.port }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: gradio-client-test
5+
annotations:
6+
"helm.sh/hook": test
7+
spec:
8+
template:
9+
spec:
10+
containers:
11+
- name: gradio-client
12+
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
13+
command:
14+
- python
15+
- stackhpc-app/test_client.py
16+
env:
17+
- name: GRADIO_HOST
18+
value: {{ printf "http://%s-ui.%s.svc:%v" (include "flux-image-gen.fullname" .) .Release.Namespace .Values.ui.service.port }}
19+
- name: FLUX_MODEL
20+
value: {{ .Values.models | first }}
21+
restartPolicy: Never
22+
backoffLimit: 3

charts/flux-image-gen/templates/tests/test-connection.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ .Release.Name }}-ui-config
6+
labels:
7+
{{- include "flux-image-gen.labels" . | nindent 4 }}
8+
data:
9+
gradio_config.yaml: |
10+
models:
11+
{{- range $model := .Values.models }}
12+
- name: {{ . }}
13+
address: {{ printf "http://%s.%s.svc:%v" ( printf "%s-%s-api" (include "flux-image-gen.fullname" $) . ) $.Release.Namespace $.Values.api.service.port }}
14+
{{- end -}}

charts/flux-image-gen/templates/ui/deployment.yaml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ spec:
99
selector:
1010
matchLabels:
1111
{{- include "flux-image-gen.selectorLabels" . | nindent 6 }}
12+
{{- include "flux-image-gen.uiLabels" . | nindent 6 }}
1213
template:
1314
metadata:
1415
{{- with .Values.ui.podAnnotations }}
@@ -17,6 +18,7 @@ spec:
1718
{{- end }}
1819
labels:
1920
{{- include "flux-image-gen.labels" . | nindent 8 }}
21+
{{- include "flux-image-gen.uiLabels" . | nindent 8 }}
2022
{{- with .Values.ui.podLabels }}
2123
{{- toYaml . | nindent 8 }}
2224
{{- end }}
@@ -35,13 +37,7 @@ spec:
3537
imagePullPolicy: {{ .Values.image.pullPolicy }}
3638
command:
3739
- python
38-
- gradio_ui.py
39-
args:
40-
- --models
41-
- {{ .Values.models | join "," }}
42-
{{- if .Values.ui.extraArgs }}
43-
{{- .Values.ui.extraArgs | toYaml | nindent 10 }}
44-
{{- end }}
40+
- stackhpc-app/gradio_ui.py
4541
ports:
4642
- name: http
4743
containerPort: {{ .Values.ui.service.port }}
@@ -58,26 +54,29 @@ spec:
5854
readinessProbe:
5955
{{- toYaml .Values.ui.readinessProbe | nindent 12 }}
6056
{{- end }}
61-
{{- with .Values.ui.volumeMounts }}
6257
volumeMounts:
58+
- name: app-config
59+
mountPath: /etc/gradio-app/
60+
{{- with .Values.ui.volumeMounts }}
61+
{{- if . -}}
6362
{{- toYaml . | nindent 12 }}
63+
{{- end -}}
6464
{{- end }}
6565
# Make stdout from python visible in k8s logs
6666
tty: true
6767
env:
6868
- name: PYTHONUNBUFFERED
6969
value: "1"
70-
- name: HELM_RELEASE_NAME
71-
value: {{ include "flux-image-gen.fullname" . }}
72-
- name: HELM_RELEASE_NAMESPACE
73-
value: {{ .Release.Namespace }}
74-
{{- with .Values.ui.envFrom }}
75-
envFrom:
76-
{{- toYaml . | nindent 12 }}
77-
{{- end }}
78-
{{- with .Values.ui.volumes }}
70+
- name: GRADIO_SERVER_NAME
71+
value: 0.0.0.0
7972
volumes:
73+
- name: app-config
74+
configMap:
75+
name: {{ .Release.Name }}-ui-config
76+
{{- with .Values.ui.volumes }}
77+
{{- if . -}}
8078
{{- toYaml . | nindent 8 }}
79+
{{- end -}}
8180
{{- end }}
8281
{{- with .Values.ui.nodeSelector }}
8382
nodeSelector:

charts/flux-image-gen/templates/ui/service.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
name: {{ include "flux-image-gen.fullname" . }}-ui
66
labels:
77
{{- include "flux-image-gen.labels" $ | nindent 4 }}
8+
{{- include "flux-image-gen.uiLabels" . | nindent 4 }}
89
spec:
910
type: {{ .Values.ui.service.type }}
1011
ports:
@@ -14,3 +15,4 @@ spec:
1415
name: http
1516
selector:
1617
{{- include "flux-image-gen.selectorLabels" . | nindent 4 }}
18+
{{- include "flux-image-gen.uiLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)