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

support dify 1.0.0+ #108

Merged
merged 6 commits into from
Mar 20, 2025
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
4 changes: 2 additions & 2 deletions charts/dify/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.1
version: 0.6.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.11"
appVersion: "1.1.0"

dependencies:
- name: redis
Expand Down
30 changes: 30 additions & 0 deletions charts/dify/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ commonBackendEnvs are for api and worker containers
{{- if .Values.redis.embedded }}
- name: CELERY_BROKER_URL
value: redis://:{{ .Values.redis.auth.password }}@{{ include "dify.fullname" . }}-redis-master:6379/1
- name: REDIS_PORT
value: "6379"
- name: REDIS_HOST
value: {{ include "dify.fullname" . }}-redis-master
- name: REDIS_DB
Expand Down Expand Up @@ -125,4 +127,32 @@ commonBackendEnvs are for api and worker containers
- name: S3_SECRET_KEY
value: {{ .Values.minio.auth.rootPassword }}
{{- end }}

{{- if .Values.pluginDaemon.enabled }}
- name: PLUGIN_DAEMON_URL
value: "http://{{ include "dify.fullname" . }}-plugin-daemon:{{ .Values.pluginDaemon.service.port }}"
- name: MARKETPLACE_API_URL
value: 'https://marketplace.dify.ai'
- name: PLUGIN_DAEMON_KEY
{{- if .Values.pluginDaemon.serverKeySecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.pluginDaemon.serverKeySecret }}
key: plugin-daemon-key
{{- else if .Values.pluginDaemon.serverKey }}
value: {{ .Values.pluginDaemon.serverKey | quote }}
{{- else }}
{{- end }}
- name: PLUGIN_DIFY_INNER_API_KEY
{{- if .Values.pluginDaemon.difyInnerApiKeySecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.pluginDaemon.difyInnerApiKeySecret }}
key: plugin-dify-inner-api-key
{{- else if .Values.pluginDaemon.difyInnerApiKey }}
value: {{ .Values.pluginDaemon.difyInnerApiKey | quote }}
{{- else }}
{{- end }}

{{- end }}
{{- end }}
113 changes: 113 additions & 0 deletions charts/dify/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,116 @@ spec:
- name: config-volume
configMap:
name: {{ include "dify.fullname" . }}-sandbox-config


{{- if .Values.pluginDaemon.enabled }}
# pluginDaemon
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "dify.fullname" . }}-plugin-daemon
labels:
{{- include "dify.labels" . | nindent 4 }}
app.kubernetes.io/component: plugin-daemon
{{- include "dify.global.labels" . | nindent 4 }}
spec:
{{- if hasKey .Values.pluginDaemon "autoscaling" }}
{{- if and (hasKey .Values.pluginDaemon "autoscaling") (not .Values.pluginDaemon.autoscaling.enabled) }}
replicas: {{ .Values.pluginDaemon.replicaCount | default 1 }}
{{- end }}
{{- else }}
replicas: 1
{{- end }}
selector:
matchLabels:
{{- include "dify.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: plugin-daemon
template:
metadata:
{{- with .Values.pluginDaemon.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "dify.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: plugin-daemon
{{- include "dify.global.labels" . | nindent 8 }}
spec:
{{- with .Values.pluginDaemon.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "dify.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.pluginDaemon.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-plugin-daemon
securityContext:
{{- toYaml .Values.pluginDaemon.securityContext | nindent 12 }}
image: "{{ .Values.pluginDaemon.image.repository }}:{{ .Values.pluginDaemon.image.tag | default "latest" }}"
imagePullPolicy: {{ .Values.pluginDaemon.image.pullPolicy }}
env:
- name: DIFY_INNER_API_URL
value: "http://{{ include "dify.fullname" . }}-api-svc:{{ .Values.api.service.port }}"
- name: PLUGIN_WORKING_PATH
value: "/app/storage/cwd"
- name: SERVER_KEY
{{- if .Values.pluginDaemon.serverKeySecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.pluginDaemon.serverKeySecret }}
key: plugin-daemon-key
{{- else if .Values.pluginDaemon.serverKey }}
value: {{ .Values.pluginDaemon.serverKey | quote }}
{{- else }}
{{- end }}
- name: DIFY_INNER_API_KEY
{{- if .Values.pluginDaemon.difyInnerApiKeySecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.pluginDaemon.difyInnerApiKeySecret }}
key: plugin-dify-inner-api-key
{{- else if .Values.pluginDaemon.difyInnerApiKey }}
value: {{ .Values.pluginDaemon.difyInnerApiKey | quote }}
{{- else }}
{{- end }}
{{- include "dify.commonEnvs" . | nindent 12 }}
{{- include "dify.commonBackendEnvs" . | nindent 12 }}
{{- with .Values.global.extraEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.global.extraBackendEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.pluginDaemon.envs }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: plugin-daemon-storage
mountPath: /app/storage
ports:
- name: http
containerPort: {{ .Values.pluginDaemon.containerPort }}
protocol: TCP
volumes:
- name: plugin-daemon-storage
{{- if .Values.pluginDaemon.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "dify.fullname" . }}-plugin-daemon-pvc
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.pluginDaemon.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.pluginDaemon.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.pluginDaemon.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/dify/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.pluginDaemon.enabled }}
{{- if .Values.pluginDaemon.persistence.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "dify.fullname" . }}-plugin-daemon-pvc
labels:
{{- include "dify.labels" . | nindent 4 }}
app.kubernetes.io/component: plugin-daemon
spec:
accessModes:
- {{ .Values.pluginDaemon.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.pluginDaemon.persistence.size | quote }}
{{- if .Values.pluginDaemon.persistence.storageClass }}
storageClassName: {{ .Values.pluginDaemon.persistence.storageClass }}
{{- end }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions charts/dify/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,24 @@ spec:
selector:
{{- include "dify.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: sandbox

{{- if .Values.pluginDaemon.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "dify.fullname" . }}-plugin-daemon
labels:
{{- include "dify.labels" . | nindent 4 }}
app.kubernetes.io/component: plugin-daemon
spec:
type: {{ .Values.pluginDaemon.service.type }}
ports:
- port: {{ .Values.pluginDaemon.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "dify.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: plugin-daemon
{{- end }}
66 changes: 62 additions & 4 deletions charts/dify/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ global:
port: ""
enableTLS: false
image:
tag: ""
tag: "1.1.0"
edition: "SELF_HOSTED"
storageType: "s3"
# the following extra configs would be injected into:
# * frontend
# * api
# * worker
# * plugin_daemon
extraEnvs: []

# the following extra configs would be injected into:
# * api
# * worker
# * plugin_daemon
extraBackendEnvs:
# SECRET_KEY is a must, check https://docs.dify.ai/getting-started/install-self-hosted/environments#secret_key for detail
# read more on the readme page for secret ref
Expand All @@ -40,7 +42,6 @@ global:
# secretKeyRef:
# name: dify
# key: SECRET_KEY

# Provide extra labels for all deployments and related pods of this chart
labels: {}

Expand Down Expand Up @@ -70,7 +71,11 @@ frontend:
# Overrides the image tag whose default is the chart appVersion.
tag: ""

envs: []
envs:
- name: MARKETPLACE_API_URL
value: 'https://marketplace.dify.ai'
- name: MARKETPLACE_URL
value: 'https://marketplace.dify.ai'
imagePullSecrets: []

podAnnotations: {}
Expand Down Expand Up @@ -296,7 +301,7 @@ sandbox:
repository: langgenius/dify-sandbox
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "0.2.0"
tag: "0.2.10"
config:
# python_requirements: |
# numpy==1.20.3
Expand Down Expand Up @@ -373,6 +378,59 @@ sandbox:
successThreshold: 1
failureThreshold: 2

# 新增plugin_daemon服务
pluginDaemon:
enabled: true
replicaCount: 1
# please change to avoid abuse
serverKey: "lYkiYYT6owG+71oLerGzA7GXCgOT++6ovaezWAjpCjf+Sjc3ZtU+qUEi"
# prefer to use secret
serverKeySecret: ""
# please change to avoid abuse
difyInnerApiKey: "QaHbTe77CtuXmsfyhR7+vRjI/+XbV1AaFy691iy+kGDv2Jvy0/eAh8Y1"
# prefer to use secret
difyInnerApiKeySecret: ""
image:
repository: langgenius/dify-plugin-daemon
pullPolicy: IfNotPresent
tag: "0.0.5-local"

envs:
- name: SERVER_PORT
value: "5002"
- name: MAX_PLUGIN_PACKAGE_SIZE
value: "52428800"
- name: PPROF_ENABLED
value: "false"
- name: FORCE_VERIFYING_SIGNATURE
value: "true"
- name: DB_DATABASE
value: "dify_plugin"
- name: PLUGIN_REMOTE_INSTALLING_HOST
value: "0.0.0.0"
- name: PLUGIN_REMOTE_INSTALLING_PORT
value: "5003"

service:
type: ClusterIP
port: 5002

containerPort: 5002

resources: {}

nodeSelector: {}

tolerations: []

affinity: {}

persistence:
enabled: true
# 使用默认的 storageClass,如果需要指定其他 storageClass,取消下面的注释并修改值
# storageClass: "rook-ceph-block"
accessMode: ReadWriteOnce
size: 20Gi
##### dependencies #####

redis:
Expand Down
Loading