-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add dify helm chart * add dify chart * Update dify helm chart configuration * newline * fix environment render error * add migration guide
- Loading branch information
Showing
13 changed files
with
1,104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
dependencies: | ||
- name: redis | ||
repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | ||
version: 17.15.6 | ||
- name: postgresql | ||
repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | ||
version: 12.8.5 | ||
- name: minio | ||
repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | ||
version: 12.7.0 | ||
digest: sha256:a8975369493aea53c4c8fa652866a388d7c345cc2ebbe4dacb9d460f40c07e59 | ||
generated: "2024-03-20T16:24:04.160197+08:00" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
apiVersion: v2 | ||
name: dify | ||
description: A Helm chart for Kubernetes | ||
|
||
home: https://github.com/langgenius/dify | ||
|
||
maintainers: | ||
- name: douban | ||
|
||
# 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.0.1 | ||
|
||
# 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. | ||
# It is recommended to use it with quotes. | ||
appVersion: "0.5.10" | ||
|
||
dependencies: | ||
- name: redis | ||
version: ~17.15.6 | ||
repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | ||
condition: redis.embedded | ||
- name: postgresql | ||
version: ~12.8.5 | ||
repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | ||
condition: postgresql.embedded | ||
- name: minio | ||
version: ~12.7.0 | ||
repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | ||
condition: minio.embedded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# dify | ||
|
||
This helm chart is based on docker-compose provided by dify | ||
|
||
this helm is distributed with `Apache License 2.0` | ||
|
||
## install | ||
|
||
create your own values file , save as `values.yaml` | ||
|
||
```yaml | ||
global: | ||
host: "mydify.example.com" | ||
enableTLS: false | ||
|
||
extraEnvs: | ||
- name: SECRET_KEY | ||
value: "generate your own one" | ||
- name: LOG_LEVEL | ||
value: "DEBUG" | ||
- name: VECTOR_STORE | ||
value: "milvus" | ||
|
||
ingress: | ||
enabled: true | ||
className: "nginx" | ||
|
||
minio: | ||
embedded: true | ||
``` | ||
``` | ||
# install it | ||
helm repo add douban https://douban.github.io/charts/ | ||
helm upgrade dify douban/dify -f values.yaml --install --debug | ||
``` | ||
|
||
``` | ||
# run migration | ||
kubectl exec -it dify-pod-name -- flask db upgrade | ||
``` | ||
|
||
always run this command after dify upgrade | ||
|
||
## production use checklist | ||
The minimal configure provided above is sufficient for experiment, however, you need extra work before put it into production, I advice you do all the checklist before provide services. | ||
|
||
### external postgresql | ||
|
||
1. set the `postgresql.embedded` to `false` | ||
2. inject connection info with `global.extraBackendEnvs` | ||
|
||
``` | ||
global: | ||
extraBackendEnvs: | ||
- name: DB_USERNAME | ||
value: "foo" | ||
# it is adviced to use secret to manage you sensitive info including password | ||
- name: DB_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: dify | ||
key: DB_PASSWORD | ||
- name: DB_HOST | ||
value: "my_pg.xxx" | ||
- name: DB_PORT | ||
value: "1234" | ||
- name: DB_DATABASE | ||
value: dify | ||
``` | ||
|
||
### external redis | ||
1. set the `redis.embedded` to `false` | ||
2. inject connection info with `global.extraBackendEnvs` | ||
``` | ||
global: | ||
extraBackendEnvs: | ||
- name: REDIS_HOST | ||
value: "foo" | ||
- name: REDIS_PORT | ||
value: "6379" | ||
- name: REDIS_DB | ||
value: "1" | ||
# it is adviced to use secret to manage you sensitive info including password | ||
- name: REDIS_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: dify | ||
key: REDIS_PASSWORD | ||
- name: CELERY_BROKER_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: dify | ||
key: CELERY_BROKER_URL | ||
``` | ||
|
||
### external s3 bucket | ||
1. set the `minio.embedded` to `false` | ||
2. inject connection info with `global.extraBackendEnvs` | ||
|
||
``` | ||
global: | ||
extraBackendEnvs: | ||
- name: S3_ENDPOINT | ||
value: "https://my-endpoint.s3.com" | ||
- name: S3_BUCKET_NAME | ||
value: "dify" | ||
# it is adviced to use secret to manage you sensitive info including password | ||
- name: S3_ACCESS_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: dify | ||
key: S3_ACCESS_KEY | ||
- name: S3_SECRET_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: dify | ||
key: S3_SECRET_KEY | ||
``` | ||
|
||
### setup vector db | ||
|
||
due to the complexity of vector db, this component is not included, you have to use external vector db, likewise , you can inject environment variable to use it | ||
|
||
``` | ||
global: | ||
extraBackendEnvs: | ||
- name: VECTOR_STORE | ||
value: "milvus" | ||
- name: MILVUS_HOST | ||
value: "my-milvus" | ||
``` | ||
|
||
this is not a complete configuration for vector db, please consult to [dify 文档](https://docs.dify.ai/v/zh-hans/getting-started/install-self-hosted/environments) [document](https://docs.dify.ai/getting-started/install-self-hosted/environments) for more info. | ||
|
||
Please consult to dify document if you have difficult to get dify running. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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 }}{{ .path }} | ||
{{- end }} | ||
{{- end }} | ||
{{- else }} | ||
ingress not enabled, service would be available only inside cluster | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "dify.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 "dify.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 "dify.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "dify.labels" -}} | ||
helm.sh/chart: {{ include "dify.chart" . }} | ||
{{ include "dify.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "dify.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "dify.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "dify.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "dify.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{- define "dify.baseUrl" -}} | ||
{{ if .Values.global.enableTLS }}https://{{ else }}http://{{ end }}{{.Values.global.host}} | ||
{{- end }} | ||
|
||
{{/* | ||
dify environments | ||
commonEnvs are for all containers | ||
commonBackendEnvs are for api and worker containers | ||
*/}} | ||
{{- define "dify.commonEnvs" -}} | ||
- name: EDITION | ||
value: {{ .Values.global.edition }} | ||
{{- range tuple "CONSOLE_API_URL" "CONSOLE_WEB_URL" "SERVICE_API_URL" "APP_API_URL" "APP_WEB_URL" }} | ||
- name: {{ . }} | ||
value: {{ include "dify.baseUrl" $ }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
|
||
{{- define "dify.commonBackendEnvs" -}} | ||
{{- if .Values.redis.embedded }} | ||
- name: CELERY_BROKER_URL | ||
value: redis://:{{ .Values.redis.auth.password }}@{{ include "dify.fullname" . }}-redis-master:6379/1 | ||
- name: REDIS_HOST | ||
value: {{ include "dify.fullname" . }}-redis-master | ||
- name: REDIS_DB | ||
value: "1" | ||
- name: REDIS_PASSWORD | ||
value: {{ .Values.redis.auth.password }} | ||
{{- end }} | ||
{{- if .Values.postgresql.embedded }} | ||
- name: DB_USERNAME | ||
value: postgres | ||
- name: DB_PASSWORD | ||
value: "{{ .Values.postgresql.auth.postgresPassword }}" | ||
- name: DB_HOST | ||
value: {{ include "dify.fullname" . }}-postgresql | ||
- name: DB_PORT | ||
value: "5432" | ||
- name: DB_DATABASE | ||
value: {{ .Values.postgresql.auth.database }} | ||
{{- end }} | ||
- name: STORAGE_TYPE | ||
value: "s3" | ||
|
||
{{- if .Values.minio.embedded }} | ||
- name: S3_ENDPOINT | ||
value: http://{{ include "dify.fullname" . }}-minio:{{ .Values.minio.service.ports.api }} | ||
- name: S3_BUCKET_NAME | ||
value: {{ .Values.minio.defaultBuckets }} | ||
- name: S3_ACCESS_KEY | ||
value: {{ .Values.minio.auth.rootUser }} | ||
- name: S3_SECRET_KEY | ||
value: {{ .Values.minio.auth.rootPassword }} | ||
{{- end }} | ||
{{- end }} |
Oops, something went wrong.