Skip to content

Commit 5ea88b3

Browse files
committed
Initial pass at functional Flux chart
1 parent 701ad09 commit 5ea88b3

File tree

11 files changed

+575
-0
lines changed

11 files changed

+575
-0
lines changed

charts/flux-image-gen/.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/

charts/flux-image-gen/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: flux-image-gen
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "4339cc5"

charts/flux-image-gen/templates/NOTES.txt

Whitespace-only changes.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "flux-image-gen.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "flux-image-gen.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "flux-image-gen.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "flux-image-gen.labels" -}}
37+
helm.sh/chart: {{ include "flux-image-gen.chart" . }}
38+
{{ include "flux-image-gen.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "flux-image-gen.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "flux-image-gen.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Selector labels
55+
*/}}
56+
{{- define "flux-image-gen.modelLabels" -}}
57+
app.kubernetes.io/component: {{ . }}-api
58+
{{- end }}
59+
60+
{{/*
61+
Create the name of the service account to use
62+
*/}}
63+
{{- define "flux-image-gen.serviceAccountName" -}}
64+
{{- if .Values.serviceAccount.create }}
65+
{{- default (include "flux-image-gen.fullname" .) .Values.serviceAccount.name }}
66+
{{- else }}
67+
{{- default "default" .Values.serviceAccount.name }}
68+
{{- end }}
69+
{{- end }}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{{- range $model := .Values.models }}
2+
---
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: {{ printf "%s-%s-api" (include "flux-image-gen.fullname" $) $model }}
7+
labels:
8+
{{- include "flux-image-gen.labels" $ | nindent 4 }}
9+
{{- include "flux-image-gen.modelLabels" . | nindent 4 }}
10+
spec:
11+
replicas: {{ $.Values.api.replicaCount }}
12+
{{- with $.Values.api.deploymentStrategy }}
13+
strategy:
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
selector:
17+
matchLabels:
18+
{{- include "flux-image-gen.selectorLabels" $ | nindent 6 }}
19+
{{- include "flux-image-gen.modelLabels" . | nindent 6 }}
20+
template:
21+
metadata:
22+
{{- with $.Values.api.podAnnotations }}
23+
annotations:
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
labels:
27+
{{- include "flux-image-gen.labels" $ | nindent 8 }}
28+
{{- include "flux-image-gen.modelLabels" . | nindent 8 }}
29+
{{- with $.Values.api.podLabels }}
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
spec:
33+
{{- with $.Values.api.imagePullSecrets }}
34+
imagePullSecrets:
35+
{{- toYaml . | nindent 8 }}
36+
{{- end }}
37+
securityContext:
38+
{{- toYaml $.Values.api.podSecurityContext | nindent 8 }}
39+
containers:
40+
- name: {{ $.Chart.Name }}
41+
securityContext:
42+
{{- toYaml $.Values.api.securityContext | nindent 12 }}
43+
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
44+
imagePullPolicy: {{ $.Values.image.pullPolicy }}
45+
ports:
46+
- name: http
47+
containerPort: {{ $.Values.api.service.port }}
48+
protocol: TCP
49+
{{- if $.Values.api.startupProbe }}
50+
startupProbe:
51+
{{- toYaml $.Values.api.startupProbe | nindent 12 }}
52+
{{- end }}
53+
{{- if $.Values.api.livenessProbe }}
54+
livenessProbe:
55+
{{- toYaml $.Values.api.livenessProbe | nindent 12 }}
56+
{{- end }}
57+
{{- if $.Values.api.readinessProbe }}
58+
readinessProbe:
59+
{{- toYaml $.Values.api.readinessProbe | nindent 12 }}
60+
{{- end }}
61+
resources:
62+
{{- toYaml $.Values.api.resources | nindent 12 }}
63+
{{- with $.Values.api.volumeMounts }}
64+
volumeMounts:
65+
{{- toYaml . | nindent 12 }}
66+
{{- end }}
67+
# Make stdout from python visible in k8s logs
68+
tty: true
69+
env:
70+
- name: FLUX_MODEL_NAME
71+
value: {{ $model }}
72+
- name: PYTHONUNBUFFERED
73+
value: "1"
74+
{{- if $.Values.api.huggingfaceToken }}
75+
- name: HUGGING_FACE_HUB_TOKEN
76+
value: {{ quote $.Values.api.huggingfaceToken }}
77+
{{- end }}
78+
{{- with $.Values.api.envFrom }}
79+
envFrom:
80+
{{- toYaml . | nindent 12 }}
81+
{{- end }}
82+
{{- with $.Values.api.volumes }}
83+
volumes:
84+
{{- toYaml . | nindent 8 }}
85+
{{- end }}
86+
{{- with $.Values.api.nodeSelector }}
87+
nodeSelector:
88+
{{- toYaml . | nindent 8 }}
89+
{{- end }}
90+
{{- with $.Values.api.affinity }}
91+
affinity:
92+
{{- toYaml . | nindent 8 }}
93+
{{- end }}
94+
{{- with $.Values.api.tolerations }}
95+
tolerations:
96+
{{- toYaml . | nindent 8 }}
97+
{{- end }}
98+
{{- end -}}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- range $model := .Values.models }}
2+
---
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: {{ printf "%s-%s-api" (include "flux-image-gen.fullname" $) $model }}
7+
labels:
8+
{{- include "flux-image-gen.labels" $ | nindent 4 }}
9+
{{- include "flux-image-gen.modelLabels" . | nindent 4 }}
10+
spec:
11+
type: {{ $.Values.api.service.type }}
12+
ports:
13+
- port: {{ $.Values.api.service.port }}
14+
targetPort: http
15+
protocol: TCP
16+
name: http
17+
selector:
18+
{{- include "flux-image-gen.selectorLabels" $ | nindent 4 }}
19+
{{- include "flux-image-gen.modelLabels" . | nindent 4 }}
20+
{{- end -}}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: "{{ include "flux-image-gen.fullname" . }}-test-connection"
5+
labels:
6+
{{- include "flux-image-gen.labels" . | nindent 4 }}
7+
annotations:
8+
"helm.sh/hook": test
9+
spec:
10+
containers:
11+
- name: wget
12+
image: busybox
13+
command: ['wget']
14+
args: ['{{ include "flux-image-gen.fullname" . }}-ui:{{ .Values.ui.service.port }}']
15+
restartPolicy: Never
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "flux-image-gen.fullname" . }}-ui
6+
labels:
7+
{{- include "flux-image-gen.labels" . | nindent 4 }}
8+
spec:
9+
selector:
10+
matchLabels:
11+
{{- include "flux-image-gen.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
{{- with .Values.ui.podAnnotations }}
15+
annotations:
16+
{{- toYaml . | nindent 8 }}
17+
{{- end }}
18+
labels:
19+
{{- include "flux-image-gen.labels" . | nindent 8 }}
20+
{{- with .Values.ui.podLabels }}
21+
{{- toYaml . | nindent 8 }}
22+
{{- end }}
23+
spec:
24+
{{- with .Values.imagePullSecrets }}
25+
imagePullSecrets:
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
securityContext:
29+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
30+
containers:
31+
- name: {{ $.Chart.Name }}
32+
securityContext:
33+
{{- toYaml .Values.securityContext | nindent 12 }}
34+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
35+
imagePullPolicy: {{ .Values.image.pullPolicy }}
36+
command:
37+
- 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 }}
45+
ports:
46+
- name: http
47+
containerPort: {{ .Values.ui.service.port }}
48+
protocol: TCP
49+
{{- if .Values.ui.startupProbe }}
50+
startupProbe:
51+
{{- toYaml .Values.ui.ui.startupProbe | nindent 12 }}
52+
{{- end }}
53+
{{- if .Values.ui.livenessProbe }}
54+
livenessProbe:
55+
{{- toYaml .Values.ui.livenessProbe | nindent 12 }}
56+
{{- end }}
57+
{{- if .Values.ui.readinessProbe }}
58+
readinessProbe:
59+
{{- toYaml .Values.ui.readinessProbe | nindent 12 }}
60+
{{- end }}
61+
{{- with .Values.ui.volumeMounts }}
62+
volumeMounts:
63+
{{- toYaml . | nindent 12 }}
64+
{{- end }}
65+
# Make stdout from python visible in k8s logs
66+
tty: true
67+
env:
68+
- name: PYTHONUNBUFFERED
69+
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 }}
79+
volumes:
80+
{{- toYaml . | nindent 8 }}
81+
{{- end }}
82+
{{- with .Values.ui.nodeSelector }}
83+
nodeSelector:
84+
{{- toYaml . | nindent 8 }}
85+
{{- end }}
86+
{{- with .Values.ui.affinity }}
87+
affinity:
88+
{{- toYaml . | nindent 8 }}
89+
{{- end }}
90+
{{- with .Values.ui.tolerations }}
91+
tolerations:
92+
{{- toYaml . | nindent 8 }}
93+
{{- end }}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- if .Values.ui.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "flux-image-gen.fullname" . }}
6+
labels:
7+
{{- include "flux-image-gen.labels" . | nindent 4 }}
8+
{{- with .Values.ui.ingress.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- with .Values.ui.ingress.className }}
14+
ingressClassName: {{ . }}
15+
{{- end }}
16+
{{- if .Values.ui.ingress.tls }}
17+
tls:
18+
{{- range .Values.ui.ingress.tls }}
19+
- hosts:
20+
{{- range .hosts }}
21+
- {{ . | quote }}
22+
{{- end }}
23+
secretName: {{ .secretName }}
24+
{{- end }}
25+
{{- end }}
26+
rules:
27+
{{- range .Values.ui.ingress.hosts }}
28+
- host: {{ .host | quote }}
29+
http:
30+
paths:
31+
{{- range .paths }}
32+
- path: {{ .path }}
33+
{{- with .pathType }}
34+
pathType: {{ . }}
35+
{{- end }}
36+
backend:
37+
service:
38+
name: {{ include "flux-image-gen.fullname" $ }}
39+
port:
40+
number: {{ $.Values.ui.service.port }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}

0 commit comments

Comments
 (0)