diff --git a/.gitignore b/.gitignore index 6b0713e..358bf83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # Helm chart automated files /charts/*/charts .idea +.vscode diff --git a/charts/dify/Chart.yaml b/charts/dify/Chart.yaml index ac43146..c7a2422 100644 --- a/charts/dify/Chart.yaml +++ b/charts/dify/Chart.yaml @@ -20,13 +20,13 @@ 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.3.6 +version: 0.4.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. # It is recommended to use it with quotes. -appVersion: "0.6.9" +appVersion: "0.6.11" dependencies: - name: redis diff --git a/charts/dify/README.md b/charts/dify/README.md index 4db348c..4047c7f 100644 --- a/charts/dify/README.md +++ b/charts/dify/README.md @@ -34,47 +34,55 @@ minio: embedded: true ``` -``` +```sh # install it helm repo add douban https://douban.github.io/charts/ helm upgrade dify douban/dify -f values.yaml --install --debug ``` + **Must** run db migration after installation, or the instance would not work. -``` + +```sh # run migration kubectl exec -it dify-pod-name -- flask db upgrade ``` ## Upgrade + To upgrade app, change the value of `global.image.tag` to the desired version -``` + +```yaml global: image: tag: "0.6.3" ``` -Then upgrade the app with helm command -``` +Then upgrade the app with helm command + +```sh helm upgrade dify douban/dify -f values.yaml --debug ``` **Must** run db migration after upgrade. -``` + +```sh # run migration kubectl exec -it dify-pod-name -- flask db upgrade ``` ## Production use checklist + The minimal configure provided above is sufficient for experiment but **without any persistance**, all your data would be lost if you restarted the postgresql pod or minio pod!! You **must do** the following extra work before put it into production!! - ### Protect Sensitive info with secret + Environment variable like `SECRET_KEY` could be harmful if leaked, it is adviced to protect them using secret or csi volume. -The example of using secret is like -``` +The example of using secret is like + +```yaml global: extraBackendEnvs: - name: SECRET_KEY @@ -84,14 +92,14 @@ global: key: SECRET_KEY ``` -Read more: https://kubernetes.io/docs/concepts/security/secrets-good-practices/ +Read more: ### External postgresql 1. set the `postgresql.embedded` to `false` 2. inject connection info with `global.extraBackendEnvs` -``` +```yaml global: extraBackendEnvs: - name: DB_USERNAME @@ -111,9 +119,11 @@ global: ``` ### External redis + 1. set the `redis.embedded` to `false` 2. inject connection info with `global.extraBackendEnvs` -``` + +```yaml global: extraBackendEnvs: - name: REDIS_HOST @@ -135,12 +145,16 @@ global: key: CELERY_BROKER_URL ``` -### External s3 bucket +### External bucket + +#### Amazon S3 + 1. set the `minio.embedded` to `false` 2. inject connection info with `global.extraBackendEnvs` -``` +```yaml global: + storageType: "s3" extraBackendEnvs: - name: S3_ENDPOINT value: "https://my-endpoint.s3.com" @@ -159,11 +173,29 @@ global: key: S3_SECRET_KEY ``` +#### Google Cloud Storage + +1. set the `minio.embedded` to `false` +2. inject connection info with `global.extraBackendEnvs` + +```yaml +global: + storageType: "google-storage" + extraBackendEnvs: + - name: GOOGLE_STORAGE_BUCKET_NAME + value: "bucket-name" + - name: GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64 + valueFrom: + secretKeyRef: + name: dify-secret + key: GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64 +``` + ### 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 -``` +```yaml global: extraBackendEnvs: - name: VECTOR_STORE diff --git a/charts/dify/templates/_helpers.tpl b/charts/dify/templates/_helpers.tpl index a38a642..16035e0 100644 --- a/charts/dify/templates/_helpers.tpl +++ b/charts/dify/templates/_helpers.tpl @@ -68,7 +68,7 @@ Create the name of the service account to use {{/* dify environments commonEnvs are for all containers -commonBackendEnvs are for api and worker containers +commonBackendEnvs are for api and worker containers */}} {{- define "dify.commonEnvs" -}} - name: EDITION @@ -81,6 +81,8 @@ commonBackendEnvs are for api and worker containers {{- define "dify.commonBackendEnvs" -}} +- name: STORAGE_TYPE + value: {{ .Values.global.storageType }} {{- if .Values.redis.embedded }} - name: CELERY_BROKER_URL value: redis://:{{ .Values.redis.auth.password }}@{{ include "dify.fullname" . }}-redis-master:6379/1 @@ -103,8 +105,6 @@ commonBackendEnvs are for api and worker containers - name: DB_DATABASE value: {{ .Values.postgresql.auth.database }} {{- end }} -- name: STORAGE_TYPE - value: "s3" {{- if .Values.minio.embedded }} - name: S3_ENDPOINT diff --git a/charts/dify/values.yaml b/charts/dify/values.yaml index 68fe2be..82d5910 100644 --- a/charts/dify/values.yaml +++ b/charts/dify/values.yaml @@ -19,6 +19,7 @@ global: image: tag: "" edition: "SELF_HOSTED" + storageType: "s3" # the following extra configs would be injected into: # * frontend # * api