Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Langflow helm chart #26

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ragstack/deploy/kubernetes/helm/langflow/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
29 changes: 29 additions & 0 deletions ragstack/deploy/kubernetes/helm/langflow/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v2
name: langflow
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 1.16.0

dependencies:
- name: postgresql
version: 12.1.0
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
19 changes: 19 additions & 0 deletions ragstack/deploy/kubernetes/helm/langflow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# helm chart

This is the helm chart for RAGStack LangFlow. Postgres is a dependent chart but optional.

## how to install

```
cd ragstack/deploy/kubernetes/helm

helm dependency update ./langflow

kubectl create namespace langflow

helm install --dry-run langflow ./langflow --values ./langflow/values.yaml

helm install --namespace langflow --debug langflow ./langflow --values ./langflow/values.yaml

helm upgrade langflow ./langflow --values ./langflow/values.yaml --namespace langflow --debug
```
22 changes: 22 additions & 0 deletions ragstack/deploy/kubernetes/helm/langflow/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "langflow.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "langflow.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "langflow.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "langflow.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions ragstack/deploy/kubernetes/helm/langflow/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "langflow.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "langflow.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "langflow.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "langflow.labels" -}}
helm.sh/chart: {{ include "langflow.chart" . }}
{{ include "langflow.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "langflow.selectorLabels" -}}
app.kubernetes.io/name: {{ include "langflow.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "langflow.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "langflow.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "langflow.fullname" . }}
labels:
{{- include "langflow.labels" . | nindent 4 }}
spec:
serviceName: "{{ include "langflow.fullname" . }}-service"
replicas: {{ .Values.langflow.replicaCount }}
selector:
matchLabels:
{{- include "langflow.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.langflow.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "langflow.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "langflow.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.langflow.podSecurityContext | nindent 8 }}
volumes:
{{- if .Values.enableTls }}
- name: certs
secret:
secretName: "{{ .Values.tlsSecretName }}"
{{- end }}
{{- if .Values.secretProvider.enabled }}
- name: secrets-store-inline
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: "{{- .Values.secretProvider.name }}"
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.langflow.securityContext | nindent 12 }}
image: "{{ .Values.langflow.image.repository }}:{{ .Values.langflow.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.langflow.image.pullPolicy }}
{{- if .Values.langflow.command }}
command:
{{- toYaml .Values.langflow.command | nindent 12 }}
{{- end }}
{{- if .Values.langflow.args }}
args:
{{- toYaml .Values.langflow.args | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.langflow.backend.port | default 7860 }}
protocol: TCP
volumeMounts:
{{- if .Values.enableTls }}
- name: certs
readOnly: true
mountPath: /certs
{{- end }}
{{- if .Values.secretProvider.enabled }}
- name: secrets-store-inline
mountPath: "/mnt/secrets"
readOnly: true
{{- end }}
{{- if eq .Values.langflow.database.type "sqlite" }}
- name: data
mountPath: /data
{{- end }}
livenessProbe:
httpGet:
path: /health
port: {{ .Values.langflow.backend.port | default 7860 }}
initialDelaySeconds: {{ .Values.langflow.backend.initialDelaySeconds | default 60 }}
periodSeconds: {{ .Values.langflow.backend.periodSeconds | default 15 }}
timeoutSeconds: {{ .Values.langflow.backend.timeoutSeconds | default 5 }}
failureThreshold: {{ .Values.langflow.backend.failureThreshold | default 2 }}
readinessProbe:
httpGet:
path: /health
port: {{ .Values.langflow.backend.port | default 7860 }}
initialDelaySeconds: {{ .Values.langflow.backend.initialDelaySeconds | default 45 }}
periodSeconds: {{ .Values.langflow.backend.periodSeconds | default 15 }}
timeoutSeconds: {{ .Values.langflow.backend.timeoutSeconds | default 5 }}
failureThreshold: {{ .Values.langflow.backend.failureThreshold | default 2 }}
env:
- name: ENVIRONMENT
value: "{{ .Values.environment | default "dev" }}"
- name: DOMAIN
value: "{{ .Values.domain | default "localhost" }}"
{{- if and .Values.langflow.database .Values.langflow.database.secretsEnabled }}
- name: LANGFLOW_DATABASE_URL
valueFrom:
secretKeyRef:
name: db-sql-url
key: db-sql-url.txt
{{- else if and .Values.langflow.database .Values.langflow.database.url }}
value: "{{ .Values.langflow.database.url }}"
{{- end }}
- name: LANGFLOW_HOST
value: "{{ .Values.langflow.host | default "0.0.0.0" }}"
- name: LANGFLOW_BACKEND_ONLY
value: "{{ .Values.langflow.backend.backendOnly | default false }}"
resources:
{{- toYaml .Values.langflow.resources | nindent 12 }}
{{- with .Values.langflow.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.langflow.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.langflow.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.langflow.database.type "sqlite" }}
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.langflow.database.size }}
storageClassName: "langflow-sqlite"
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if .Values.langflow.database.type }}
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: "{{ template "langflow.fullname" . }}-{{ .Values.langflow.database.type }}"
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "langflow.name" . }}
chart: {{ template "langflow.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: {{ .Values.langflow.database.type }}
cluster: {{ template "langflow.fullname" . }}
allowVolumeExpansion: true
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
{{- if .Values.langflow.database.volumes.storageClass }}
provisioner: {{ .Values.langflow.database.volumes.storageClass.provisioner }}
parameters:
{{- if .Values.langflow.database.volumes.storageClass.type }}
type: {{ .Values.langflow.database.volumes.storageClass.type }}
{{- end }}
{{- if .Values.langflow.database.volumes.storageClass.fsType }}
fsType: {{ .Values.langflow.database.volumes.storageClass.fsType }}
{{- end }}
{{- if .Values.langflow.database.volumes.storageClass.extraParams }}
{{ toYaml .Values.langflow.database.volumes.storageClass.extraParams | indent 2 }}
{{- end }}
{{- else if .Values.default_storage }}
provisioner: {{ .Values.default_storage.provisioner }}
parameters:
{{- if .Values.default_storage.type }}
type: {{ .Values.default_storage.type }}
{{- end }}
{{- if .Values.default_storage.fsType }}
fsType: {{ .Values.default_storage.fsType }}
{{- end }}
{{- if .Values.default_storage.extraParams }}
{{ toYaml .Values.default_storage.extraParams | indent 2 }}
{{- end }}
{{- end }}
{{- end }}
Loading