基于helm-dify 0.23.0 版本初始化

This commit is contained in:
2025-03-21 10:00:02 +08:00
parent d773ead144
commit 67b42e3e1c
196 changed files with 26165 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
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 if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dify.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 "dify.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dify.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
{{- if .Values.proxy.enabled }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dify.name" . }},app.kubernetes.io/instance={{ .Release.Name }},component=proxy" -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 }}
{{- end }}
+198
View File
@@ -0,0 +1,198 @@
{{/*
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 a default fully qualified api name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dify.api.fullname" -}}
{{ template "dify.fullname" . }}-api
{{- end -}}
{{/*
Create a default fully qualified worker name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dify.worker.fullname" -}}
{{ template "dify.fullname" . }}-worker
{{- end -}}
{{/*
Create a default fully qualified web name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dify.web.fullname" -}}
{{ template "dify.fullname" . }}-web
{{- end -}}
{{/*
Create a default fully qualified web name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dify.sandbox.fullname" -}}
{{ template "dify.fullname" . }}-sandbox
{{- end -}}
{{/*
Create a default fully qualified web name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dify.ssrfProxy.fullname" -}}
{{ template "dify.fullname" . }}-ssrf-proxy
{{- end -}}
{{/*
Create a default fully qualified nginx name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dify.nginx.fullname" -}}
{{ template "dify.fullname" . }}-proxy
{{- end -}}
{{/*
Create a default fully qualified plugin-daemon name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dify.pluginDaemon.fullname" -}}
{{ template "dify.fullname" . }}-plugin-daemon
{{- 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 }}
{{/* labels defiend by user*/}}
{{- define "dify.ud.labels" -}}
{{- if .Values.labels }}
{{- toYaml .Values.labels }}
{{- end -}}
{{- end -}}
{{/* annotations defiend by user*/}}
{{- define "dify.ud.annotations" -}}
{{- if .Values.annotations }}
{{- toYaml .Values.annotations }}
{{- end -}}
{{- 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 for the Dify API
*/}}
{{- define "dify.api.serviceAccountName" -}}
{{- if .Values.api.serviceAccount.create -}}
{{ default (include "dify.api.fullname" .) .Values.api.serviceAccount.name | trunc 63 | trimSuffix "-" }}
{{- else -}}
{{ default "default" .Values.api.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account to use for the Proxy
*/}}
{{- define "dify.proxy.serviceAccountName" -}}
{{- if .Values.proxy.serviceAccount.create -}}
{{ default (include "dify.nginx.fullname" .) .Values.proxy.serviceAccount.name | trunc 63 | trimSuffix "-" }}
{{- else -}}
{{ default "default" .Values.proxy.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account to use for the Sandbox
*/}}
{{- define "dify.sandbox.serviceAccountName" -}}
{{- if .Values.sandbox.serviceAccount.create -}}
{{ default (include "dify.sandbox.fullname" .) .Values.sandbox.serviceAccount.name | trunc 63 | trimSuffix "-" }}
{{- else -}}
{{ default "default" .Values.sandbox.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account to use for the ssrfProxy
*/}}
{{- define "dify.ssrfProxy.serviceAccountName" -}}
{{- if .Values.ssrfProxy.serviceAccount.create -}}
{{ default (include "dify.ssrfProxy.fullname" .) .Values.ssrfProxy.serviceAccount.name | trunc 63 | trimSuffix "-" }}
{{- else -}}
{{ default "default" .Values.ssrfProxy.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account to use for the Web
*/}}
{{- define "dify.web.serviceAccountName" -}}
{{- if .Values.web.serviceAccount.create -}}
{{ default (include "dify.web.fullname" .) .Values.web.serviceAccount.name | trunc 63 | trimSuffix "-" }}
{{- else -}}
{{ default "default" .Values.web.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account to use for the Dify Worker
*/}}
{{- define "dify.worker.serviceAccountName" -}}
{{- if .Values.worker.serviceAccount.create -}}
{{ default (include "dify.worker.fullname" .) .Values.worker.serviceAccount.name | trunc 63 | trimSuffix "-" }}
{{- else -}}
{{ default "default" .Values.worker.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account to use for the Dify Plugin Daemon
*/}}
{{- define "dify.pluginDaemon.serviceAccountName" -}}
{{- if .Values.pluginDaemon.serviceAccount.create -}}
{{ default (include "dify.pluginDaemon.fullname" .) .Values.pluginDaemon.serviceAccount.name | trunc 63 | trimSuffix "-" }}
{{- else -}}
{{ default "default" .Values.pluginDaemon.serviceAccount.name }}
{{- end -}}
{{- end -}}
+6
View File
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dify.api.fullname" . }}
data:
{{- include "dify.api.config" . | nindent 2 }}
+162
View File
@@ -0,0 +1,162 @@
{{- if and .Values.api.enabled}}
{{- $usePvc := not (or .Values.externalS3.enabled .Values.externalOSS.enabled .Values.externalAzureBlobStorage.enabled .Values.externalGCS.enabled .Values.externalCOS.enabled) -}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{ include "dify.ud.annotations" . | indent 4 }}
descriptions: api
labels:
{{- include "dify.labels" . | nindent 4 }}
component: api
# app: {{ template "dify.api.fullname" . }}
{{ include "dify.ud.labels" . | indent 4 }}
name: {{ template "dify.api.fullname" . }}
spec:
replicas: {{ .Values.api.replicas }}
selector:
matchLabels:
{{- include "dify.selectorLabels" . | nindent 6 }}
component: api
{{/*
# Required labels for istio
# app: {{ template "dify.api.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
template:
metadata:
annotations:
checksum/api-config: {{ include (print $.Template.BasePath "/api-config.yaml") . | sha256sum }}
checksum/api-secret: {{ include (print $.Template.BasePath "/api-secret.yaml") . | sha256sum }}
{{ include "dify.ud.annotations" . | indent 8 }}
labels:
{{- include "dify.selectorLabels" . | nindent 8 }}
component: api
{{/*
# Required labels for istio
# app: {{ template "dify.api.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
{{ include "dify.ud.labels" . | indent 8 }}
spec:
serviceAccountName: {{ include "dify.api.serviceAccountName" . }}
{{- if eq .Release.Name "dify"}}
{{/*
Disable service environment variables,
otherwise they will clash with `DIFY_PORT` which is needed in entrypoint.sh
*/}}
enableServiceLinks: false
{{- end }}
{{- if .Values.image.api.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.api.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.api.podSecurityContext }}
securityContext:
{{ toYaml .Values.api.podSecurityContext | indent 8 }}
{{- end }}
initContainers:
- name: init
image: "{{.Values.image.python.repository }}:{{ default "3.12-slim" .Values.image.python.tag }}"
imagePullPolicy: "{{.Values.image.python.pullPolicy }}"
command: ["/bin/sh"]
args: ["-c", "pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn"]
volumeMounts:
- name: python-config
mountPath: /root/.config/pip
containers:
- image: "{{ .Values.image.api.repository }}:{{ default .Chart.AppVersion .Values.image.api.tag }}"
imagePullPolicy: "{{ .Values.image.api.pullPolicy }}"
name: api
{{- if .Values.api.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.api.customLivenessProbe "context" $) | nindent 10 }}
{{- else if .Values.api.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.api.livenessProbe "enabled") "context" $) | nindent 10 }}
httpGet:
path: /health
port: api
{{- end }}
{{- if .Values.api.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.api.customReadinessProbe "context" $) | nindent 10 }}
{{- else if .Values.api.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.api.readinessProbe "enabled") "context" $) | nindent 10 }}
httpGet:
path: /health
port: api
{{- end }}
{{- if .Values.api.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.api.customStartupProbe "context" $) | nindent 10 }}
{{- else if .Values.api.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.api.startupProbe "enabled") "context" $) | nindent 10 }}
tcpSocket:
port: api
{{- end }}
{{- if .Values.api.containerSecurityContext }}
securityContext:
{{ toYaml .Values.api.containerSecurityContext | indent 10 }}
{{- end }}
env:
{{- if .Values.sandbox.enabled }}
- name: CODE_EXECUTION_API_KEY
valueFrom:
secretKeyRef:
name: {{ template "dify.sandbox.fullname" . }}
key: "API_KEY"
{{- end }}
{{- if .Values.api.extraEnv }}
{{- toYaml .Values.api.extraEnv | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ template "dify.api.fullname" . }}
- secretRef:
name: {{ template "dify.api.fullname" . }}
ports:
- name: api
containerPort: 5001
protocol: TCP
resources:
{{- toYaml .Values.api.resources | nindent 12 }}
volumeMounts:
- name: python-config
mountPath: /root/.config/pip
{{- if $usePvc }}
- name: app-data
mountPath: {{ .Values.api.persistence.mountPath | quote }}
subPath: {{ .Values.api.persistence.persistentVolumeClaim.subPath | default "" }}
{{- end }}
{{- if and (.Values.nodeSelector) (not .Values.api.nodeSelector) }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.api.nodeSelector }}
nodeSelector:
{{ toYaml .Values.api.nodeSelector | indent 8 }}
{{- end }}
{{- if and (.Values.affinity) (not .Values.api.affinity) }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.api.affinity }}
affinity:
{{ toYaml .Values.api.affinity | indent 8 }}
{{- end }}
{{- if and (.Values.tolerations) (not .Values.api.tolerations) }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.api.tolerations }}
tolerations:
{{ toYaml .Values.api.tolerations | indent 8 }}
{{- end }}
volumes:
- name: python-config
emptyDir: {}
{{- if $usePvc }}
- name: app-data
persistentVolumeClaim:
claimName: {{ .Values.api.persistence.persistentVolumeClaim.existingClaim | default (printf "%s" (include "dify.fullname" . | trunc 58)) }}
{{- end }}
{{- end }}
+7
View File
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "dify.api.fullname" . }}
type: Opaque
data:
{{- include "dify.api.credentials" . | nindent 2 }}
+13
View File
@@ -0,0 +1,13 @@
{{- if .Values.api.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dify.api.serviceAccountName" . }}
labels: {{- include "dify.labels" . | nindent 4 }}
component: api
{{- if or .Values.api.serviceAccount.annotations (include "dify.ud.annotations" .) }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.api.serviceAccount.annotations (include "dify.ud.annotations" .) ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.api.serviceAccount.automountServiceAccountToken }}
{{- end }}
+29
View File
@@ -0,0 +1,29 @@
{{- if .Values.api.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "dify.api.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
{{- if .Values.api.service.labels }}
{{ toYaml .Values.api.service.labels | indent 4 }}
{{- end }}
component: "api"
{{- with .Values.api.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
type: ClusterIP
{{- if .Values.api.service.clusterIP }}
clusterIP: {{ .Values.api.service.clusterIP }}
{{- end }}
ports:
- name: http-api
port: {{ .Values.api.service.port }}
protocol: TCP
targetPort: api
selector:
{{ include "dify.selectorLabels" . | indent 4 }}
component: "api"
{{- end }}
+566
View File
@@ -0,0 +1,566 @@
{{- define "dify.api.config" -}}
# Startup mode, 'api' starts the API server.
MODE: api
# The log level for the application. Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`
LOG_LEVEL: {{ .Values.api.logLevel }}
# A secret key that is used for securely signing the session cookie and encrypting sensitive information on the database. You can generate a strong key using `openssl rand -base64 42`.
# SECRET_KEY: {{ .Values.api.secretKey }}
# The base URL of console application web frontend, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_WEB_URL: {{ .Values.api.url.consoleWeb | quote }}
# The base URL of console application api server, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_API_URL: {{ .Values.api.url.consoleApi | quote }}
# The URL prefix for Service API endpoints, refers to the base URL of the current API service if api domain is
# different from console domain.
# example: http://api.dify.ai
SERVICE_API_URL: {{ .Values.api.url.serviceApi | quote }}
# The URL prefix for Web APP frontend, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
APP_WEB_URL: {{ .Values.api.url.appWeb | quote }}
# File preview or download Url prefix.
# used to display File preview or download Url to the front-end or as Multi-model inputs;
# Url is signed and has expiration time.
FILES_URL: {{ .Values.api.url.files | quote }}
{{- include "dify.marketplace.config" . }}
# When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed.
MIGRATION_ENABLED: {{ .Values.api.migration | toString | quote }}
# The configurations of postgres database connection.
# It is consistent with the configuration in the 'db' service below.
{{- include "dify.db.config" . }}
# The configurations of redis connection.
# It is consistent with the configuration in the 'redis' service below.
{{- include "dify.redis.config" . }}
# The configurations of celery broker.
{{- include "dify.celery.config" . }}
# Specifies the allowed origins for cross-origin requests to the Web API, e.g. https://dify.app or * for all origins.
WEB_API_CORS_ALLOW_ORIGINS: '*'
# Specifies the allowed origins for cross-origin requests to the console API, e.g. https://cloud.dify.ai or * for all origins.
CONSOLE_CORS_ALLOW_ORIGINS: '*'
# CSRF Cookie settings
# Controls whether a cookie is sent with cross-site requests,
# providing some protection against cross-site request forgery attacks
#
# Default: `SameSite=Lax, Secure=false, HttpOnly=true`
# This default configuration supports same-origin requests using either HTTP or HTTPS,
# but does not support cross-origin requests. It is suitable for local debugging purposes.
#
# If you want to enable cross-origin support,
# you must use the HTTPS protocol and set the configuration to `SameSite=None, Secure=true, HttpOnly=true`.
#
{{ include "dify.storage.config" . }}
{{ include "dify.vectordb.config" . }}
{{ include "dify.mail.config" . }}
# The DSN for Sentry error reporting. If not set, Sentry error reporting will be disabled.
SENTRY_DSN: ''
# The sample rate for Sentry events. Default: `1.0`
SENTRY_TRACES_SAMPLE_RATE: "1.0"
# The sample rate for Sentry profiles. Default: `1.0`
SENTRY_PROFILES_SAMPLE_RATE: "1.0"
{{- if .Values.sandbox.enabled }}
CODE_EXECUTION_ENDPOINT: http://{{ template "dify.sandbox.fullname" .}}:{{ .Values.sandbox.service.port }}
{{- end }}
{{- if .Values.ssrfProxy.enabled }}
SSRF_PROXY_HTTP_URL: http://{{ template "dify.ssrfProxy.fullname" .}}:{{ .Values.ssrfProxy.service.port }}
SSRF_PROXY_HTTPS_URL: http://{{ template "dify.ssrfProxy.fullname" .}}:{{ .Values.ssrfProxy.service.port }}
{{- end }}
{{- if .Values.pluginDaemon.enabled }}
PLUGIN_DAEMON_URL: http://{{ template "dify.pluginDaemon.fullname" .}}:{{ .Values.pluginDaemon.service.ports.daemon }}
{{- end }}
{{- end }}
{{- define "dify.worker.config" -}}
# worker service
# The Celery worker for processing the queue.
# Startup mode, 'worker' starts the Celery worker for processing the queue.
MODE: worker
# The base URL of console application web frontend, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_WEB_URL: {{ .Values.api.url.consoleWeb | quote }}
# --- All the configurations below are the same as those in the 'api' service. ---
# The log level for the application. Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`
LOG_LEVEL: {{ .Values.worker.logLevel | quote }}
# A secret key that is used for securely signing the session cookie and encrypting sensitive information on the database. You can generate a strong key using `openssl rand -base64 42`.
# same as the API service
# SECRET_KEY: {{ .Values.api.secretKey }}
# The configurations of postgres database connection.
# It is consistent with the configuration in the 'db' service below.
{{ include "dify.db.config" . }}
# The configurations of redis cache connection.
{{ include "dify.redis.config" . }}
# The configurations of celery broker.
{{ include "dify.celery.config" . }}
{{ include "dify.storage.config" . }}
# The Vector store configurations.
{{ include "dify.vectordb.config" . }}
{{ include "dify.mail.config" . }}
{{- if .Values.pluginDaemon.enabled }}
PLUGIN_DAEMON_URL: http://{{ template "dify.pluginDaemon.fullname" .}}:{{ .Values.pluginDaemon.service.ports.daemon }}
{{- end }}
{{- include "dify.marketplace.config" . }}
{{- end }}
{{- define "dify.web.config" -}}
# The base URL of console application api server, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_API_URL: {{ .Values.api.url.consoleApi | quote }}
# The URL for Web APP api server, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
APP_API_URL: {{ .Values.api.url.appApi | quote }}
# The DSN for Sentry
{{- include "dify.marketplace.config" . }}
MARKETPLACE_URL: {{ .Values.api.url.marketplace | quote }}
{{- end }}
{{- define "dify.db.config" -}}
{{- if .Values.externalPostgres.enabled }}
# DB_USERNAME: {{ .Values.externalPostgres.username }}
# DB_PASSWORD: {{ .Values.externalPostgres.password }}
DB_HOST: {{ .Values.externalPostgres.address }}
DB_PORT: {{ .Values.externalPostgres.port | toString | quote }}
DB_DATABASE: {{ .Values.externalPostgres.database.api | quote }}
{{- else if .Values.postgresql.enabled }}
{{ with .Values.postgresql.global.postgresql.auth }}
{{- if empty .username }}
# DB_USERNAME: postgres
# DB_PASSWORD: {{ .postgresPassword }}
{{- else }}
# DB_USERNAME: {{ .username }}
# DB_PASSWORD: {{ .password }}
{{- end }}
{{- end }}
{{- if eq .Values.postgresql.architecture "replication" }}
DB_HOST: {{ .Release.Name }}-postgresql-primary
{{- else }}
DB_HOST: {{ .Release.Name }}-postgresql
{{- end }}
DB_PORT: "5432"
DB_DATABASE: {{ .Values.postgresql.global.postgresql.auth.database }}
{{- end }}
{{- end }}
{{- define "dify.storage.config" -}}
{{- if .Values.externalS3.enabled }}
# The type of storage to use for storing user files. Supported values are `local`, `s3`, `azure-blob`, `aliyun-oss` and `google-storage`, Default: `local`
STORAGE_TYPE: s3
# The S3 storage configurations, only available when STORAGE_TYPE is `s3`.
S3_ENDPOINT: {{ .Values.externalS3.endpoint }}
S3_BUCKET_NAME: {{ .Values.externalS3.bucketName }}
# S3_ACCESS_KEY: {{ .Values.externalS3.accessKey }}
# S3_SECRET_KEY: {{ .Values.externalS3.secretKey }}
S3_REGION: {{ .Values.externalS3.region }}
{{- else if .Values.externalAzureBlobStorage.enabled }}
# The type of storage to use for storing user files. Supported values are `local`, `s3`, `azure-blob`, `aliyun-oss` and `google-storage`, Default: `local`
STORAGE_TYPE: azure-blob
# The Azure Blob storage configurations, only available when STORAGE_TYPE is `azure-blob`.
AZURE_BLOB_ACCOUNT_NAME: {{ .Values.externalAzureBlobStorage.account | quote }}
# AZURE_BLOB_ACCOUNT_KEY: {{ .Values.externalAzureBlobStorage.key | quote }}
AZURE_BLOB_CONTAINER_NAME: {{ .Values.externalAzureBlobStorage.container | quote }}
AZURE_BLOB_ACCOUNT_URL: {{ .Values.externalAzureBlobStorage.url | quote }}
{{- else if .Values.externalOSS.enabled }}
# The type of storage to use for storing user files. Supported values are `local`, `s3`, `azure-blob`, `aliyun-oss` and `google-storage`, Default: `local`
STORAGE_TYPE: aliyun-oss
# The OSS storage configurations, only available when STORAGE_TYPE is `aliyun-oss`.
ALIYUN_OSS_ENDPOINT: {{ .Values.externalOSS.endpoint | quote }}
ALIYUN_OSS_BUCKET_NAME: {{ .Values.externalOSS.bucketName | quote }}
# ALIYUN_OSS_ACCESS_KEY: {{ .Values.externalOSS.accessKey }}
# ALIYUN_OSS_SECRET_KEY: {{ .Values.externalOSS.secretKey }}
ALIYUN_OSS_REGION: {{ .Values.externalOSS.region | quote }}
ALIYUN_OSS_AUTH_VERSION: {{ .Values.externalOSS.authVersion | quote }}
ALIYUN_OSS_PATH: {{ .Values.externalOSS.path | quote }}
{{- else if .Values.externalGCS.enabled }}
# The type of storage to use for storing user files. Supported values are `local`, `s3`, `azure-blob`, `aliyun-oss` and `google-storage`, Default: `local`
STORAGE_TYPE: google-storage
GOOGLE_STORAGE_BUCKET_NAME: {{ .Values.externalGCS.bucketName }}
GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64: {{ .Values.externalGCS.serviceAccountJsonBase64 }}
{{- else if .Values.externalCOS.enabled }}
# The type of storage to use for storing user files. Supported values are `local`, `s3`, `azure-blob`, `aliyun-oss`, `google-storage` and `tencent-cos`, Default: `local`
STORAGE_TYPE: tencent-cos
# The name of the Tencent COS bucket to use for storing files.
TENCENT_COS_BUCKET_NAME: {{ .Values.externalCOS.bucketName }}
# The secret key to use for authenticating with the Tencent COS service.
TENCENT_COS_SECRET_KEY: {{ .Values.externalCOS.secretKey }}
# The secret id to use for authenticating with the Tencent COS service.
TENCENT_COS_SECRET_ID: {{ .Values.externalCOS.secretId }}
# The region of the Tencent COS service.
TENCENT_COS_REGION: {{ .Values.externalCOS.region }}
# The scheme of the Tencent COS service.
TENCENT_COS_SCHEME: {{ .Values.externalCOS.scheme }}
{{- else }}
# The type of storage to use for storing user files. Supported values are `local` and `s3` and `azure-blob`, Default: `local`
STORAGE_TYPE: local
# The path to the local storage directory, the directory relative the root path of API service codes or absolute path. Default: `storage` or `/home/john/storage`.
# only available when STORAGE_TYPE is `local`.
STORAGE_LOCAL_PATH: {{ .Values.api.persistence.mountPath }}
{{- end }}
{{- end }}
{{- define "dify.redis.config" -}}
{{- if .Values.externalRedis.enabled }}
{{- with .Values.externalRedis }}
REDIS_HOST: {{ .host | quote }}
REDIS_PORT: {{ .port | toString | quote }}
# REDIS_USERNAME: {{ .username | quote }}
# REDIS_PASSWORD: {{ .password | quote }}
REDIS_USE_SSL: {{ .useSSL | toString | quote }}
# use redis db 0 for redis cache
REDIS_DB: "0"
{{- end }}
{{- else if .Values.redis.enabled }}
{{- $redisHost := printf "%s-redis-master" .Release.Name -}}
{{- with .Values.redis }}
REDIS_HOST: {{ $redisHost }}
REDIS_PORT: {{ .master.service.ports.redis | toString | quote }}
# REDIS_USERNAME: ""
# REDIS_PASSWORD: {{ .auth.password | quote }}
REDIS_USE_SSL: {{ .tls.enabled | toString | quote }}
# use redis db 0 for redis cache
REDIS_DB: "0"
{{- end }}
{{- end }}
{{- end }}
{{- define "dify.celery.config" -}}
# Use redis as the broker, and redis db 1 for celery broker.
{{- if .Values.externalRedis.enabled }}
{{- with .Values.externalRedis }}
# CELERY_BROKER_URL: {{ printf "redis://%s:%s@%s:%v/1" .username .password .host .port }}
{{- end }}
{{- else if .Values.redis.enabled }}
{{- $redisHost := printf "%s-redis-master" .Release.Name -}}
{{- with .Values.redis }}
# CELERY_BROKER_URL: {{ printf "redis://:%s@%s:%v/1" .auth.password $redisHost .master.service.ports.redis }}
{{- end }}
{{- end }}
{{- end }}
{{- define "dify.vectordb.config" -}}
{{- if .Values.externalWeaviate.enabled }}
# The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`, `pgvector`, `tencent`, `myscale`.
VECTOR_STORE: weaviate
# The Weaviate endpoint URL. Only available when VECTOR_STORE is `weaviate`.
WEAVIATE_ENDPOINT: {{ .Values.externalWeaviate.endpoint | quote }}
# The Weaviate API key.
# WEAVIATE_API_KEY: {{ .Values.externalWeaviate.apiKey }}
{{- else if .Values.externalQdrant.enabled }}
VECTOR_STORE: qdrant
# The Qdrant endpoint URL. Only available when VECTOR_STORE is `qdrant`.
QDRANT_URL: {{ .Values.externalQdrant.endpoint }}
# The Qdrant API key.
# QDRANT_API_KEY: {{ .Values.externalQdrant.apiKey }}
# The Qdrant clinet timeout setting.
QDRANT_CLIENT_TIMEOUT: {{ .Values.externalQdrant.timeout | quote }}
# The Qdrant client enable gRPC mode.
QDRANT_GRPC_ENABLED: {{ .Values.externalQdrant.grpc.enabled | toString | quote }}
# The Qdrant server gRPC mode PORT.
QDRANT_GRPC_PORT: {{ .Values.externalQdrant.grpc.port | quote }}
# The DSN for Sentry error reporting. If not set, Sentry error reporting will be disabled.
{{- else if .Values.externalMilvus.enabled}}
# Milvus configuration Only available when VECTOR_STORE is `milvus`.
VECTOR_STORE: milvus
# The milvus host.
MILVUS_HOST: {{ .Values.externalMilvus.host | quote }}
# The milvus host.
MILVUS_PORT: {{ .Values.externalMilvus.port | toString | quote }}
# The milvus URI.
{{- if .Values.externalMilvus.uri }}
MILVUS_URI: {{ .Values.externalMilvus.uri | quote }}
{{- else }}
MILVUS_URI: {{ .Values.externalMilvus.host }}:{{ .Values.externalMilvus.port }}
{{- end }}
# The milvus database
MILVUS_DATABASE: {{ .Values.externalMilvus.database | quote }}
# The milvus username.
# MILVUS_USER: {{ .Values.externalMilvus.user | quote }}
# The milvus password.
# MILVUS_PASSWORD: {{ .Values.externalMilvus.password | quote }}
# The milvus tls switch.
MILVUS_SECURE: {{ .Values.externalMilvus.useTLS | toString | quote }}
{{- else if .Values.externalPgvector.enabled}}
# pgvector configurations, only available when VECTOR_STORE is `pgvecto-rs or pgvector`
VECTOR_STORE: pgvector
PGVECTOR_HOST: {{ .Values.externalPgvector.address }}
PGVECTOR_PORT: {{ .Values.externalPgvector.port | toString | quote }}
PGVECTOR_DATABASE: {{ .Values.externalPgvector.dbName }}
# DB_USERNAME: {{ .Values.externalPgvector.username }}
# DB_PASSWORD: {{ .Values.externalPgvector.password }}
{{- else if .Values.externalTencentVectorDB.enabled}}
# tencent vector configurations, only available when VECTOR_STORE is `tencent`
VECTOR_STORE: tencent
TENCENT_VECTOR_DB_URL: {{ .Values.externalTencentVectorDB.url | quote }}
# TENCENT_VECTOR_DB_API_KEY: {{ .Values.externalTencentVectorDB.apiKey | quote }}
TENCENT_VECTOR_DB_TIMEOUT: {{ .Values.externalTencentVectorDB.timeout | quote }}
# TENCENT_VECTOR_DB_USERNAME: {{ .Values.externalTencentVectorDB.username | quote }}
TENCENT_VECTOR_DB_DATABASE: {{ .Values.externalTencentVectorDB.database | quote }}
TENCENT_VECTOR_DB_SHARD: {{ .Values.externalTencentVectorDB.shard | quote }}
TENCENT_VECTOR_DB_REPLICAS: {{ .Values.externalTencentVectorDB.replicas | quote }}
{{- else if .Values.externalMyScaleDB.enabled}}
# MyScaleDB vector db configurations, only available when VECTOR_STORE is `myscale`
VECTOR_STORE: myscale
MYSCALE_HOST: {{ .Values.externalMyScaleDB.host | quote }}
MYSCALE_PORT: {{ .Values.externalMyScaleDB.port | toString | quote }}
# MYSCALE_USER: {{ .Values.externalMyScaleDB.username | quote }}
# MYSCALE_PASSWORD: {{ .Values.externalMyScaleDB.password | quote }}
MYSCALE_DATABASE: {{ .Values.externalMyScaleDB.database | quote }}
MYSCALE_FTS_PARAMS: {{ .Values.externalMyScaleDB.ftsParams | quote }}
{{- else if .Values.weaviate.enabled }}
# The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`.
VECTOR_STORE: weaviate
{{- with .Values.weaviate.service }}
{{- if and (eq .type "ClusterIP") (not (eq .clusterIP "None"))}}
# The Weaviate endpoint URL. Only available when VECTOR_STORE is `weaviate`.
{{/*
Pitfall: scheme (i.e.) must be supecified, or weviate client won't function as
it depends on `hostname` from urllib.parse.urlparse will be empty if schema is not specified.
*/}}
WEAVIATE_ENDPOINT: {{ printf "http://%s" .name | quote }}
{{- end }}
{{- end }}
# The Weaviate API key.
{{- if .Values.weaviate.authentication.apikey }}
# WEAVIATE_API_KEY: {{ first .Values.weaviate.authentication.apikey.allowed_keys }}
{{- end }}
{{- end }}
{{- end }}
{{- define "dify.mail.config" -}}
{{- if eq .Values.api.mail.type "resend" }}
# Mail configuration for resend
MAIL_TYPE: {{ .Values.api.mail.type | quote }}
MAIL_DEFAULT_SEND_FROM: {{ .Values.api.mail.defaultSender | quote }}
# RESEND_API_KEY: {{ .Values.api.mail.resend.apiKey | quote }}
RESEND_API_URL: {{ .Values.api.mail.resend.apiUrl | quote }}
{{- else if eq .Values.api.mail.type "smtp" }}
# Mail configuration for SMTP
MAIL_TYPE: {{ .Values.api.mail.type | quote }}
MAIL_DEFAULT_SEND_FROM: {{ .Values.api.mail.defaultSender | quote }}
SMTP_SERVER: {{ .Values.api.mail.smtp.server | quote }}
SMTP_PORT: {{ .Values.api.mail.smtp.port | quote }}
# SMTP_USERNAME: {{ .Values.api.mail.smtp.username | quote }}
# SMTP_PASSWORD: {{ .Values.api.mail.smtp.password | quote }}
SMTP_USE_TLS: {{ .Values.api.mail.smtp.tls.enabled | toString | quote }}
SMTP_OPPORTUNISTIC_TLS: {{ .Values.api.mail.smtp.tls.optimistic | toString | quote }}
{{- end }}
{{- end }}
{{/*
Python 3.12.x 国内镜像源,配置文件挂载路径:/root/.config/pip/pip.conf
*/}}
{{- define "dify.python.environment.config" -}}
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
{{- end }}
{{- define "dify.sandbox.config" -}}
GIN_MODE: release
SANDBOX_PORT: '8194'
{{- if .Values.ssrfProxy.enabled }}
HTTP_PROXY: http://{{ template "dify.ssrfProxy.fullname" .}}:{{ .Values.ssrfProxy.service.port }}
HTTPS_PROXY: http://{{ template "dify.ssrfProxy.fullname" .}}:{{ .Values.ssrfProxy.service.port }}
{{- end }}
{{- end }}
{{- define "dify.nginx.config.proxy" }}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
{{- end }}
{{- define "dify.nginx.config.nginx" }}
user nginx;
worker_processes auto;
{{- if .Values.proxy.log.persistence.enabled }}
error_log {{ .Values.proxy.log.persistence.mountPath }}/error.log notice;
{{- end }}
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
{{- if .Values.proxy.log.persistence.enabled }}
access_log {{ .Values.proxy.log.persistence.mountPath }}/access.log main;
{{- end }}
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
client_max_body_size {{ .Values.proxy.clientMaxBodySize | default "15m" }};
include /etc/nginx/conf.d/*.conf;
}
{{- end }}
{{- define "dify.nginx.config.default" }}
server {
listen 80;
server_name _;
location /console/api {
proxy_pass http://{{ template "dify.api.fullname" .}}:{{ .Values.api.service.port }};
include proxy.conf;
}
location /api {
proxy_pass http://{{ template "dify.api.fullname" .}}:{{ .Values.api.service.port }};
include proxy.conf;
}
location /v1 {
proxy_pass http://{{ template "dify.api.fullname" .}}:{{ .Values.api.service.port }};
include proxy.conf;
}
location /files {
proxy_pass http://{{ template "dify.api.fullname" .}}:{{ .Values.api.service.port }};
include proxy.conf;
}
location /explore {
proxy_pass http://{{ template "dify.web.fullname" .}}:{{ .Values.web.service.port }};
proxy_set_header Dify-Hook-Url $scheme://$host$request_uri;
include proxy.conf;
}
location /e {
proxy_pass http://{{ template "dify.pluginDaemon.fullname" .}}:{{ .Values.pluginDaemon.service.ports.daemon }};
include proxy.conf;
}
location / {
proxy_pass http://{{ template "dify.web.fullname" .}}:{{ .Values.web.service.port }};
include proxy.conf;
}
}
{{- end }}
{{- define "dify.ssrfProxy.config.squid" }}
acl localnet src 0.0.0.1-0.255.255.255 # RFC 1122 "this" network (LAN)
acl localnet src 10.0.0.0/8 # RFC 1918 local private network (LAN)
acl localnet src 100.64.0.0/10 # RFC 6598 shared address space (CGN)
acl localnet src 169.254.0.0/16 # RFC 3927 link-local (directly plugged) machines
acl localnet src 172.16.0.0/12 # RFC 1918 local private network (LAN)
acl localnet src 192.168.0.0/16 # RFC 1918 local private network (LAN)
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localhost
include /etc/squid/conf.d/*.conf
http_access deny all
################################## Proxy Server ################################
http_port 3128
coredump_dir /var/spool/squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern \/(Packages|Sources)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
refresh_pattern \/Release(|\.gpg)$ 0 0% 0 refresh-ims
refresh_pattern \/InRelease$ 0 0% 0 refresh-ims
refresh_pattern \/(Translation-.*)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
refresh_pattern . 0 20% 4320
# upstream proxy, set to your own upstream proxy IP to avoid SSRF attacks
# cache_peer 172.1.1.1 parent 3128 0 no-query no-digest no-netdb-exchange default
################################## Reverse Proxy To Sandbox ################################
http_port {{ .Values.sandbox.service.port }} accel vhost
cache_peer {{ template "dify.sandbox.fullname" .}} parent {{ .Values.sandbox.service.port }} 0 no-query originserver
acl src_all src all
http_access allow src_all
{{/*Dump logs to stdout only when log persistence is not enabled*/}}
{{- if not .Values.ssrfProxy.log.persistence.enabled }}
cache_log none
access_log none
cache_store_log none
{{- end }}
{{- end }}
{{- define "dify.pluginDaemon.db.config" -}}
{{- if .Values.externalPostgres.enabled }}
DB_HOST: {{ .Values.externalPostgres.address }}
DB_PORT: {{ .Values.externalPostgres.port | toString | quote }}
DB_DATABASE: {{ .Values.externalPostgres.database.pluginDaemon | quote }}
{{- else if .Values.postgresql.enabled }}
# N.B.: `pluginDaemon` will the very same `PostgresSQL` database as `api`, `worker`,
# which is NOT recommended for production and subject to possible confliction in the future releases of `dify`
{{- include "dify.db.config" . }}
{{- end }}
{{- end }}
{{- define "dify.pluginDaemon.config" }}
{{- include "dify.redis.config" . }}
{{- include "dify.pluginDaemon.db.config" .}}
SERVER_PORT: "5002"
PLUGIN_REMOTE_INSTALLING_HOST: "0.0.0.0"
PLUGIN_REMOTE_INSTALLING_PORT: "5003"
MAX_PLUGIN_PACKAGE_SIZE: "52428800"
PLUGIN_WORKING_PATH: {{ .Values.pluginDaemon.persistence.mountPath | quote }}
DIFY_INNER_API_URL: "http://{{ template "dify.api.fullname" . }}:{{ .Values.api.service.port }}"
{{- include "dify.marketplace.config" . }}
{{- end }}
{{- define "dify.marketplace.config" }}
{{- if .Values.pluginDaemon.marketplace.enabled }}
MARKETPLACE_ENABLED: "true"
MARKETPLACE_API_URL: {{ .Values.api.url.marketplaceApi | quote }}
{{- else }}
MARKETPLACE_ENABLED: "false"
{{- end }}
{{- end }}
+152
View File
@@ -0,0 +1,152 @@
{{- define "dify.api.credentials" -}}
# A secret key that is used for securely signing the session cookie and encrypting sensitive information on the database. You can generate a strong key using `openssl rand -base64 42`.
SECRET_KEY: {{ .Values.api.secretKey | b64enc | quote }}
{{- if .Values.sandbox.enabled }}
CODE_EXECUTION_API_KEY: {{ .Values.sandbox.auth.apiKey | b64enc | quote }}
{{- end }}
{{- include "dify.db.credentials" . }}
# The configurations of redis connection.
# It is consistent with the configuration in the 'redis' service below.
{{- include "dify.redis.credentials" . }}
# The configurations of celery broker.
{{- include "dify.celery.credentials" . }}
{{ include "dify.storage.credentials" . }}
{{ include "dify.vectordb.credentials" . }}
{{ include "dify.mail.credentials" . }}
{{- if .Values.pluginDaemon.enabled }}
PLUGIN_DAEMON_KEY: {{ .Values.pluginDaemon.auth.serverKey | b64enc | quote }}
INNER_API_KEY_FOR_PLUGIN: {{ .Values.pluginDaemon.auth.difyApiKey | b64enc | quote }}
{{- end }}
{{- end }}
{{- define "dify.worker.credentials" -}}
SECRET_KEY: {{ .Values.api.secretKey | b64enc | quote }}
# The configurations of postgres database connection.
# It is consistent with the configuration in the 'db' service below.
{{ include "dify.db.credentials" . }}
# The configurations of redis cache connection.
{{ include "dify.redis.credentials" . }}
# The configurations of celery broker.
{{ include "dify.celery.credentials" . }}
{{ include "dify.storage.credentials" . }}
# The Vector store configurations.
{{ include "dify.vectordb.credentials" . }}
{{ include "dify.mail.credentials" . }}
{{- if .Values.pluginDaemon.enabled }}
PLUGIN_DAEMON_KEY: {{ .Values.pluginDaemon.auth.serverKey | b64enc | quote }}
INNER_API_KEY_FOR_PLUGIN: {{ .Values.pluginDaemon.auth.difyApiKey | b64enc | quote }}
{{- end }}
{{- end }}
{{- define "dify.web.credentials" -}}
{{- end }}
{{- define "dify.db.credentials" -}}
{{- if .Values.externalPostgres.enabled }}
DB_USERNAME: {{ .Values.externalPostgres.username | b64enc | quote }}
DB_PASSWORD: {{ .Values.externalPostgres.password | b64enc | quote }}
{{- else if .Values.postgresql.enabled }}
{{ with .Values.postgresql.global.postgresql.auth}}
{{- if empty .username }}
DB_USERNAME: {{ print "postgres" | b64enc | quote }}
DB_PASSWORD: {{ .postgresPassword | b64enc | quote }}
{{- else }}
DB_USERNAME: {{ .username | b64enc | quote }}
DB_PASSWORD: {{ .password | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- define "dify.storage.credentials" -}}
{{- if .Values.externalS3.enabled}}
S3_ACCESS_KEY: {{ .Values.externalS3.accessKey | b64enc | quote }}
S3_SECRET_KEY: {{ .Values.externalS3.secretKey | b64enc | quote }}
{{- else if .Values.externalAzureBlobStorage.enabled }}
# The Azure Blob storage configurations, only available when STORAGE_TYPE is `azure-blob`.
AZURE_BLOB_ACCOUNT_KEY: {{ .Values.externalAzureBlobStorage.key | b64enc | quote }}
{{- else if .Values.externalOSS.enabled }}
ALIYUN_OSS_ACCESS_KEY: {{ .Values.externalOSS.accessKey | b64enc | quote }}
ALIYUN_OSS_SECRET_KEY: {{ .Values.externalOSS.secretKey | b64enc | quote }}
{{- else }}
{{- end }}
{{- end }}
{{- define "dify.redis.credentials" -}}
{{- if .Values.externalRedis.enabled }}
{{- with .Values.externalRedis }}
REDIS_USERNAME: {{ .username | b64enc | quote }}
REDIS_PASSWORD: {{ .password | b64enc | quote }}
{{- end }}
{{- else if .Values.redis.enabled }}
{{- $redisHost := printf "%s-redis-master" .Release.Name -}}
{{- with .Values.redis }}
REDIS_USERNAME: {{ print "" | b64enc | quote }}
REDIS_PASSWORD: {{ .auth.password | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- define "dify.celery.credentials" -}}
# Use redis as the broker, and redis db 1 for celery broker.
{{- if .Values.externalRedis.enabled }}
{{- with .Values.externalRedis }}
CELERY_BROKER_URL: {{ printf "redis://%s:%s@%s:%v/1" .username .password .host .port | b64enc | quote }}
{{- end }}
{{- else if .Values.redis.enabled }}
{{- $redisHost := printf "%s-redis-master" .Release.Name -}}
{{- with .Values.redis }}
CELERY_BROKER_URL: {{ printf "redis://:%s@%s:%v/1" .auth.password $redisHost .master.service.ports.redis | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- define "dify.vectordb.credentials" -}}
{{- if .Values.externalWeaviate.enabled }}
WEAVIATE_API_KEY: {{ .Values.externalWeaviate.apiKey | b64enc | quote }}
{{- else if .Values.externalQdrant.enabled }}
QDRANT_API_KEY: {{ .Values.externalQdrant.apiKey | b64enc | quote }}
{{- else if .Values.externalMilvus.enabled}}
MILVUS_USER: {{ .Values.externalMilvus.user | b64enc | quote }}
# The milvus password.
MILVUS_PASSWORD: {{ .Values.externalMilvus.password | b64enc | quote }}
{{- else if .Values.externalPgvector.enabled}}
PGVECTOR_USER: {{ .Values.externalPgvector.username | b64enc | quote }}
# The pgvector password.
PGVECTOR_PASSWORD: {{ .Values.externalPgvector.password | b64enc | quote }}
{{- else if .Values.externalTencentVectorDB.enabled}}
TENCENT_VECTOR_DB_USERNAME: {{ .Values.externalTencentVectorDB.username | b64enc | quote }}
TENCENT_VECTOR_DB_API_KEY: {{ .Values.externalTencentVectorDB.apiKey | b64enc | quote }}
{{- else if .Values.externalMyScaleDB.enabled}}
MYSCALE_USER: {{ .Values.externalMyScaleDB.username | b64enc | quote }}
MYSCALE_PASSWORD: {{ .Values.externalMyScaleDB.password | b64enc | quote }}
{{- else if .Values.weaviate.enabled }}
# The Weaviate API key.
{{- if .Values.weaviate.authentication.apikey }}
WEAVIATE_API_KEY: {{ first .Values.weaviate.authentication.apikey.allowed_keys | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- define "dify.mail.credentials" -}}
{{- if eq .Values.api.mail.type "resend" }}
RESEND_API_KEY: {{ .Values.api.mail.resend.apiKey | b64enc | quote }}
{{- else if eq .Values.api.mail.type "smtp" }}
# Mail configuration for SMTP
SMTP_USERNAME: {{ .Values.api.mail.smtp.username | b64enc | quote }}
SMTP_PASSWORD: {{ .Values.api.mail.smtp.password | b64enc | quote }}
{{- end }}
{{- end }}
{{- define "dify.sandbox.credentials" -}}
API_KEY: {{ .Values.sandbox.auth.apiKey | b64enc | quote }}
{{- end }}
{{- define "dify.pluginDaemon.credentials" -}}
{{ include "dify.db.credentials" . }}
{{ include "dify.redis.credentials" . }}
SERVER_KEY: {{ .Values.pluginDaemon.auth.serverKey | b64enc | quote }}
DIFY_INNER_API_KEY: {{ .Values.pluginDaemon.auth.difyApiKey | b64enc | quote }}
{{- end }}
+135
View File
@@ -0,0 +1,135 @@
{{- if .Values.api.autoscaling.enabled }}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "dify.api.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "dify.api.fullname" . }}
minReplicas: {{ .Values.api.autoscaling.minReplicas }}
maxReplicas: {{ .Values.api.autoscaling.maxReplicas }}
metrics:
{{- if .Values.api.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.api.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.api.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.web.autoscaling.enabled }}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "dify.web.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "dify.web.fullname" . }}
minReplicas: {{ .Values.web.autoscaling.minReplicas }}
maxReplicas: {{ .Values.web.autoscaling.maxReplicas }}
metrics:
{{- if .Values.web.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.web.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.web.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.web.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.worker.autoscaling.enabled }}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "dify.worker.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "dify.worker.fullname" . }}
minReplicas: {{ .Values.worker.autoscaling.minReplicas }}
maxReplicas: {{ .Values.worker.autoscaling.maxReplicas }}
metrics:
{{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.sandbox.autoscaling.enabled }}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "dify.sandbox.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "dify.sandbox.fullname" . }}
minReplicas: {{ .Values.sandbox.autoscaling.minReplicas }}
maxReplicas: {{ .Values.sandbox.autoscaling.maxReplicas }}
metrics:
{{- if .Values.sandbox.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.sandbox.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.sandbox.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.sandbox.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
+61
View File
@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "dify.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "dify.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
+6
View File
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dify.pluginDaemon.fullname" . }}
data:
{{- include "dify.pluginDaemon.config" . | nindent 2 }}
+132
View File
@@ -0,0 +1,132 @@
{{- if and .Values.pluginDaemon.enabled}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{ include "dify.ud.annotations" . | indent 4 }}
descriptions: plugin-daemon
labels:
{{- include "dify.labels" . | nindent 4 }}
component: plugin-daemon
# app: {{ template "dify.pluginDaemon.fullname" . }}
{{ include "dify.ud.labels" . | indent 4 }}
name: {{ template "dify.pluginDaemon.fullname" . }}
spec:
replicas: {{ .Values.pluginDaemon.replicas }}
selector:
matchLabels:
{{- include "dify.selectorLabels" . | nindent 6 }}
component: plugin-daemon
{{/*
# Required labels for istio
# app: {{ template "dify.pluginDaemon.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
template:
metadata:
annotations:
checksum/plugin-daemon-config: {{ include (print $.Template.BasePath "/plugin-daemon-config.yaml") . | sha256sum }}
checksum/plugin-daemon-secret: {{ include (print $.Template.BasePath "/plugin-daemon-secret.yaml") . | sha256sum }}
{{ include "dify.ud.annotations" . | indent 8 }}
labels:
{{- include "dify.selectorLabels" . | nindent 8 }}
component: plugin-daemon
{{/*
# Required labels for istio
# app: {{ template "dify.pluginDaemon.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
{{ include "dify.ud.labels" . | indent 8 }}
spec:
serviceAccountName: {{ include "dify.pluginDaemon.serviceAccountName" . }}
{{- if .Values.image.pluginDaemon.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pluginDaemon.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.pluginDaemon.podSecurityContext }}
securityContext:
{{ toYaml .Values.pluginDaemon.podSecurityContext | indent 8 }}
{{- end }}
initContainers:
- name: init
image: "{{.Values.image.python.repository }}:{{ default "3.12-slim" .Values.image.python.tag }}"
imagePullPolicy: "{{.Values.image.python.pullPolicy }}"
command: ["/bin/sh"]
args: ["-c", "pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn"]
volumeMounts:
- name: python-config
mountPath: /root/.config/pip
containers:
- image: "{{ .Values.image.pluginDaemon.repository }}:{{ default .Chart.AppVersion .Values.image.pluginDaemon.tag }}"
imagePullPolicy: "{{ .Values.image.pluginDaemon.pullPolicy }}"
name: plugin-daemon
{{- if .Values.pluginDaemon.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.pluginDaemon.customLivenessProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.pluginDaemon.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.pluginDaemon.customReadinessProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.pluginDaemon.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.pluginDaemon.customStartupProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.pluginDaemon.containerSecurityContext }}
securityContext:
{{ toYaml .Values.pluginDaemon.containerSecurityContext | indent 10 }}
{{- end }}
env:
{{- if .Values.pluginDaemon.extraEnv }}
{{- toYaml .Values.pluginDaemon.extraEnv | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ template "dify.pluginDaemon.fullname" . }}
- secretRef:
name: {{ template "dify.pluginDaemon.fullname" . }}
ports:
- name: daemon
containerPort: 5002
protocol: TCP
- name: plugin-install
containerPort: 5003
protocol: TCP
resources:
{{- toYaml .Values.pluginDaemon.resources | nindent 12 }}
volumeMounts:
- name: python-config
mountPath: /root/.config/pip
- name: app-data
mountPath: {{ .Values.pluginDaemon.persistence.mountPath | quote }}
subPath: {{ .Values.pluginDaemon.persistence.persistentVolumeClaim.subPath | default "" }}
{{- if and (.Values.nodeSelector) (not .Values.pluginDaemon.nodeSelector) }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.pluginDaemon.nodeSelector }}
nodeSelector:
{{ toYaml .Values.pluginDaemon.nodeSelector | indent 8 }}
{{- end }}
{{- if and (.Values.affinity) (not .Values.pluginDaemon.affinity) }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.pluginDaemon.affinity }}
affinity:
{{ toYaml .Values.pluginDaemon.affinity | indent 8 }}
{{- end }}
{{- if and (.Values.tolerations) (not .Values.pluginDaemon.tolerations) }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.pluginDaemon.tolerations }}
tolerations:
{{ toYaml .Values.pluginDaemon.tolerations | indent 8 }}
{{- end }}
volumes:
- name: python-config
emptyDir: {}
- name: app-data
persistentVolumeClaim:
claimName: {{ .Values.pluginDaemon.persistence.persistentVolumeClaim.existingClaim | default (printf "%s" (include "dify.pluginDaemon.fullname" . | trunc 58)) }}
{{- end }}
+7
View File
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "dify.pluginDaemon.fullname" . }}
type: Opaque
data:
{{- include "dify.pluginDaemon.credentials" . | nindent 2 }}
@@ -0,0 +1,13 @@
{{- if .Values.pluginDaemon.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dify.pluginDaemon.serviceAccountName" . }}
labels: {{- include "dify.labels" . | nindent 4 }}
component: plugin-daemon
{{- if or .Values.pluginDaemon.serviceAccount.annotations (include "dify.ud.annotations" .) }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.pluginDaemon.serviceAccount.annotations (include "dify.ud.annotations" .) ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.pluginDaemon.serviceAccount.automountServiceAccountToken }}
{{- end }}
+35
View File
@@ -0,0 +1,35 @@
{{- if .Values.pluginDaemon.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "dify.pluginDaemon.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
{{- if .Values.pluginDaemon.service.labels }}
{{ toYaml .Values.pluginDaemon.service.labels | indent 4 }}
{{- end }}
component: "plugin-daemon"
{{- with .Values.pluginDaemon.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
type: ClusterIP
{{- if .Values.pluginDaemon.service.clusterIP }}
clusterIP: {{ .Values.pluginDaemon.service.clusterIP }}
{{- end }}
ports:
- name: http-daemon
port: {{ .Values.pluginDaemon.service.ports.daemon }}
protocol: TCP
targetPort: daemon
{{- if .Values.pluginDaemon.service.ports.pluginInstall }}
- name: http-plugin-install
port: {{ .Values.pluginDaemon.service.ports.pluginInstall }}
protocol: TCP
targetPort: plugin-install
{{- end }}
selector:
{{ include "dify.selectorLabels" . | indent 4 }}
component: "plugin-daemon"
{{- end }}
+15
View File
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dify.nginx.fullname" . }}
data:
proxy.conf: |-
{{- include "dify.nginx.config.proxy" . | indent 4 }}
nginx.conf: |-
{{- include "dify.nginx.config.nginx" . | indent 4 }}
default.conf: |-
{{- include "dify.nginx.config.default" . | indent 4 }}
{{- range $key, $value := .Values.extraConfigFiles }}
{{ $key }}: |-
{{ $value | indent 4 }}
{{- end }}
+130
View File
@@ -0,0 +1,130 @@
{{- if and .Values.proxy.enabled}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{ include "dify.ud.annotations" . | indent 4 }}
descriptions: nginx proxy
labels:
{{- include "dify.labels" . | nindent 4 }}
component: proxy
# app: {{ template "dify.nginx.fullname" . }}
{{ include "dify.ud.labels" . | indent 4 }}
name: {{ template "dify.nginx.fullname" . }}
spec:
replicas: {{ .Values.proxy.replicas }}
selector:
matchLabels:
{{- include "dify.selectorLabels" . | nindent 6 }}
component: proxy
{{/*
# Required labels for istio
# app: {{ template "dify.nginx.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
template:
metadata:
annotations:
checksum/proxy-config: {{ include (print $.Template.BasePath "/proxy-configmap.yaml") . | sha256sum }}
{{ include "dify.ud.annotations" . | indent 8 }}
labels:
{{- include "dify.selectorLabels" . | nindent 8 }}
component: proxy
{{/*
# Required labels for istio
# app: {{ template "dify.nginx.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
{{ include "dify.ud.labels" . | indent 8 }}
spec:
serviceAccountName: {{ include "dify.proxy.serviceAccountName" . }}
{{- if .Values.image.proxy.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.proxy.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.proxy.podSecurityContext }}
securityContext:
{{ toYaml .Values.proxy.podSecurityContext | indent 8 }}
{{- end }}
containers:
- image: "{{ .Values.image.proxy.repository }}:{{ .Values.image.proxy.tag }}"
imagePullPolicy: "{{ .Values.image.proxy.pullPolicy }}"
name: nginx
{{- if .Values.proxy.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.proxy.customLivenessProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.proxy.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.proxy.customReadinessProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.proxy.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.proxy.customStartupProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.proxy.containerSecurityContext }}
securityContext:
{{ toYaml .Values.proxy.containerSecurityContext | indent 10 }}
{{- end }}
env:
{{- if .Values.proxy.extraEnv }}
{{- toYaml .Values.proxy.extraEnv | nindent 8 }}
{{- end }}
ports:
- name: dify
containerPort: 80
protocol: TCP
resources:
{{- toYaml .Values.proxy.resources | nindent 12 }}
volumeMounts:
- name: nginx
mountPath: /etc/nginx/nginx.conf
readOnly: true
subPath: nginx.conf
- name: nginx
mountPath: /etc/nginx/proxy.conf
readOnly: true
subPath: proxy.conf
- name: nginx
mountPath: /etc/nginx/conf.d/default.conf
readOnly: true
subPath: default.conf
{{- if .Values.proxy.log.persistence.enabled }}
- name: nginx-logs-disk
mountPath: {{ .Values.proxy.log.persistence.mountPath | quote }}
subPath: {{ .Values.proxy.log.persistence.persistentVolumeClaim.subPath | default "" }}
{{- end }}
{{- if and (.Values.nodeSelector) (not .Values.proxy.nodeSelector) }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.proxy.nodeSelector }}
nodeSelector:
{{ toYaml .Values.proxy.nodeSelector | indent 8 }}
{{- end }}
{{- if and (.Values.affinity) (not .Values.proxy.affinity) }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.proxy.affinity }}
affinity:
{{ toYaml .Values.proxy.affinity | indent 8 }}
{{- end }}
{{- if and (.Values.tolerations) (not .Values.proxy.tolerations) }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.proxy.tolerations }}
tolerations:
{{ toYaml .Values.proxy.tolerations | indent 8 }}
{{- end }}
volumes:
- name: nginx
configMap:
defaultMode: 420
name: {{ template "dify.nginx.fullname" . }}
{{- if .Values.proxy.log.persistence.enabled }}
- name: nginx-logs-disk
persistentVolumeClaim:
claimName: {{ .Values.proxy.log.persistence.persistentVolumeClaim.existingClaim | default (printf "%s-logs" (include "dify.nginx.fullname" . | trunc 58)) }}
{{- end }}
{{- end }}
+13
View File
@@ -0,0 +1,13 @@
{{- if .Values.proxy.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dify.proxy.serviceAccountName" . }}
labels: {{- include "dify.labels" . | nindent 4 }}
component: proxy
{{- if or .Values.proxy.serviceAccount.annotations (include "dify.ud.annotations" .) }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.proxy.serviceAccount.annotations (include "dify.ud.annotations" .) ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.proxy.serviceAccount.automountServiceAccountToken }}
{{- end }}
+121
View File
@@ -0,0 +1,121 @@
{{- if not (or .Values.externalS3.enabled .Values.externalAzureBlobStorage.enabled .Values.externalOSS.enabled) }}
{{- $pvc := .Values.api.persistence.persistentVolumeClaim -}}
{{- if (not $pvc.existingClaim) }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ printf "%s" (include "dify.fullname" . | trunc 58) }}
{{- with .Values.api.persistence.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{ include "dify.labels" . | indent 4 }}
spec:
accessModes:
- {{ $pvc.accessModes | quote }}
{{- if $pvc.storageClass }}
{{- if eq "-" $pvc.storageClass }}
storageClassName: ""
{{- else }}
storageClassName: {{ $pvc.storageClass }}
{{- end }}
{{- end }}
resources:
requests:
storage: {{ $pvc.size }}
{{- end }}
{{- end }}
{{- $pvc := .Values.proxy.log.persistence.persistentVolumeClaim -}}
{{- if and .Values.proxy.log.persistence.enabled (not $pvc.existingClaim) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ printf "%s-logs" (include "dify.nginx.fullname" . | trunc 58) }}
{{- with .Values.proxy.log.persistence.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{ include "dify.labels" . | indent 4 }}
spec:
accessModes:
- {{ $pvc.accessModes | quote }}
{{- if $pvc.storageClass }}
{{- if eq "-" $pvc.storageClass }}
storageClassName: ""
{{- else }}
storageClassName: {{ $pvc.storageClass }}
{{- end }}
{{- end }}
resources:
requests:
storage: {{ $pvc.size }}
{{- end }}
{{- $pvc := .Values.ssrfProxy.log.persistence.persistentVolumeClaim -}}
{{- if and .Values.ssrfProxy.log.persistence.enabled (not $pvc.existingClaim) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ printf "%s-logs" (include "dify.ssrfProxy.fullname" . | trunc 58) }}
{{- with .Values.ssrfProxy.log.persistence.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{ include "dify.labels" . | indent 4 }}
spec:
accessModes:
- {{ $pvc.accessModes | quote }}
{{- if $pvc.storageClass }}
{{- if eq "-" $pvc.storageClass }}
storageClassName: ""
{{- else }}
storageClassName: {{ $pvc.storageClass }}
{{- end }}
{{- end }}
resources:
requests:
storage: {{ $pvc.size }}
{{- end }}
{{- $pvc := .Values.pluginDaemon.persistence.persistentVolumeClaim -}}
{{- if and .Values.pluginDaemon.enabled (not $pvc.existingClaim) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ printf "%s" (include "dify.pluginDaemon.fullname" . | trunc 58) }}
{{- with .Values.pluginDaemon.persistence.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{ include "dify.labels" . | indent 4 }}
spec:
accessModes:
- {{ $pvc.accessModes | quote }}
{{- if $pvc.storageClass }}
{{- if eq "-" $pvc.storageClass }}
storageClassName: ""
{{- else }}
storageClassName: {{ $pvc.storageClass }}
{{- end }}
{{- end }}
resources:
requests:
storage: {{ $pvc.size }}
{{- end }}
+6
View File
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dify.sandbox.fullname" . }}
data:
{{- include "dify.sandbox.config" . | nindent 2 }}
+124
View File
@@ -0,0 +1,124 @@
{{- if and .Values.sandbox.enabled}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{ include "dify.ud.annotations" . | indent 4 }}
descriptions: sandbox
labels:
{{- include "dify.labels" . | nindent 4 }}
component: sandbox
# app: {{ template "dify.sandbox.fullname" . }}
{{ include "dify.ud.labels" . | indent 4 }}
name: {{ template "dify.sandbox.fullname" . }}
spec:
replicas: {{ .Values.sandbox.replicas }}
selector:
matchLabels:
{{- include "dify.selectorLabels" . | nindent 6 }}
component: sandbox
{{/*
# Required labels for istio
# app: {{ template "dify.sandbox.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
template:
metadata:
annotations:
checksum/sandbox-config: {{ include (print $.Template.BasePath "/sandbox-config.yaml") . | sha256sum }}
checksum/sandbox-secret: {{ include (print $.Template.BasePath "/sandbox-secret.yaml") . | sha256sum }}
{{ include "dify.ud.annotations" . | indent 8 }}
labels:
{{- include "dify.selectorLabels" . | nindent 8 }}
component: sandbox
{{/*
# Required labels for istio
# app: {{ template "dify.sandbox.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
{{ include "dify.ud.labels" . | indent 8 }}
spec:
serviceAccountName: {{ include "dify.sandbox.serviceAccountName" . }}
{{- if .Values.image.sandbox.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.sandbox.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.sandbox.podSecurityContext }}
securityContext:
{{ toYaml .Values.sandbox.podSecurityContext | indent 8 }}
{{- end }}
containers:
- image: "{{ .Values.image.sandbox.repository }}:{{ .Values.image.sandbox.tag }}"
imagePullPolicy: "{{ .Values.image.sandbox.pullPolicy }}"
name: sandbox
{{- if .Values.sandbox.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.sandbox.customLivenessProbe "context" $) | nindent 10 }}
{{- else if .Values.sandbox.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.sandbox.livenessProbe "enabled") "context" $) | nindent 10 }}
httpGet:
path: /health
port: sandbox
{{- end }}
{{- if .Values.sandbox.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.sandbox.customReadinessProbe "context" $) | nindent 10 }}
{{- else if .Values.sandbox.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.sandbox.readinessProbe "enabled") "context" $) | nindent 10 }}
httpGet:
path: /health
port: sandbox
{{- end }}
{{- if .Values.sandbox.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.sandbox.customStartupProbe "context" $) | nindent 10 }}
{{- else if .Values.sandbox.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.sandbox.startupProbe "enabled") "context" $) | nindent 10 }}
tcpSocket:
port: sandbox
{{- end }}
{{- if .Values.sandbox.containerSecurityContext }}
securityContext:
{{ toYaml .Values.sandbox.containerSecurityContext | indent 10 }}
{{- end }}
env:
{{- if .Values.sandbox.extraEnv }}
{{- toYaml .Values.sandbox.extraEnv | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ template "dify.sandbox.fullname" . }}
- secretRef:
name: {{ template "dify.sandbox.fullname" . }}
ports:
- name: sandbox
containerPort: 8194
protocol: TCP
resources:
{{- toYaml .Values.sandbox.resources | nindent 12 }}
securityContext:
allowPrivilegeEscalation: {{ .Values.sandbox.privileged }}
{{- if and (.Values.nodeSelector) (not .Values.sandbox.nodeSelector) }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.sandbox.nodeSelector }}
nodeSelector:
{{ toYaml .Values.sandbox.nodeSelector | indent 8 }}
{{- end }}
{{- if and (.Values.affinity) (not .Values.sandbox.affinity) }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.sandbox.affinity }}
affinity:
{{ toYaml .Values.sandbox.affinity | indent 8 }}
{{- end }}
{{- if and (.Values.tolerations) (not .Values.sandbox.tolerations) }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.sandbox.tolerations }}
tolerations:
{{ toYaml .Values.sandbox.tolerations | indent 8 }}
{{- end }}
{{- end }}
+9
View File
@@ -0,0 +1,9 @@
{{- if .Values.sandbox.enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "dify.sandbox.fullname" . }}
type: Opaque
data:
{{- include "dify.sandbox.credentials" . | nindent 2 }}
{{- end }}
+13
View File
@@ -0,0 +1,13 @@
{{- if .Values.sandbox.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dify.sandbox.serviceAccountName" . }}
labels: {{- include "dify.labels" . | nindent 4 }}
component: sandbox
{{- if or .Values.sandbox.serviceAccount.annotations (include "dify.ud.annotations" .) }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.sandbox.serviceAccount.annotations (include "dify.ud.annotations" .) ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.sandbox.serviceAccount.automountServiceAccountToken }}
{{- end }}
+29
View File
@@ -0,0 +1,29 @@
{{- if .Values.sandbox.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "dify.sandbox.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
{{- if .Values.sandbox.service.labels }}
{{ toYaml .Values.sandbox.service.labels | indent 4 }}
{{- end }}
component: "sandbox"
{{- with .Values.sandbox.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
type: ClusterIP
{{- if .Values.sandbox.service.clusterIP }}
clusterIP: {{ .Values.sandbox.service.clusterIP }}
{{- end }}
ports:
- name: http-sandbox
port: {{ .Values.sandbox.service.port }}
protocol: TCP
targetPort: sandbox
selector:
{{ include "dify.selectorLabels" . | indent 4 }}
component: "sandbox"
{{- end }}
+49
View File
@@ -0,0 +1,49 @@
{{- if .Values.proxy.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "dify.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
{{- if .Values.proxy.enabled }}
component: "proxy"
{{- end }}
{{- with .Values.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
type: ClusterIP
{{- if .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
{{- else if eq .Values.service.type "LoadBalancer" }}
type: LoadBalancer
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end -}}
{{- else }}
type: {{ .Values.service.type }}
{{- end }}
ports:
- name: http-dify
port: {{ .Values.service.port }}
protocol: TCP
targetPort: dify
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{.Values.service.nodePort}}
{{- end }}
selector:
{{ include "dify.selectorLabels" . | indent 4 }}
{{- if and .Values.proxy.enabled }}
component: "proxy"
{{- end }}
{{- end }}
+9
View File
@@ -0,0 +1,9 @@
{{- if .Values.ssrfProxy.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dify.ssrfProxy.fullname" . }}
data:
squid.conf: |-
{{- include "dify.ssrfProxy.config.squid" . | indent 4 }}
{{- end }}
+124
View File
@@ -0,0 +1,124 @@
{{- if .Values.ssrfProxy.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{ include "dify.ud.annotations" . | indent 4 }}
descriptions: 'SSRF Proxy'
labels:
{{- include "dify.labels" . | nindent 4 }}
component: ssrf-proxy
# app: {{ template "dify.ssrfProxy.fullname" . }}
{{ include "dify.ud.labels" . | indent 4 }}
name: {{ template "dify.ssrfProxy.fullname" . }}
spec:
replicas: {{ .Values.ssrfProxy.replicas }}
selector:
matchLabels:
{{- include "dify.selectorLabels" . | nindent 6 }}
component: ssrf-proxy
{{/*
# Required labels for istio
# app: {{ template "dify.ssrfProxy.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
template:
metadata:
annotations:
checksum/ssrf-proxy-config: {{ include (print $.Template.BasePath "/ssrf-proxy-configmap.yaml") . | sha256sum }}
{{ include "dify.ud.annotations" . | indent 8 }}
labels:
{{- include "dify.selectorLabels" . | nindent 8 }}
component: ssrf-proxy
{{/*
# Required labels for istio
# app: {{ template "dify.ssrfProxy.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
{{ include "dify.ud.labels" . | indent 8 }}
spec:
serviceAccountName: {{ include "dify.ssrfProxy.serviceAccountName" . }}
{{- if .Values.image.ssrfProxy.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.ssrfProxy.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.ssrfProxy.podSecurityContext }}
securityContext:
{{ toYaml .Values.ssrfProxy.podSecurityContext | indent 8 }}
{{- end }}
containers:
- image: "{{ .Values.image.ssrfProxy.repository }}:{{ .Values.image.ssrfProxy.tag }}"
imagePullPolicy: "{{ .Values.image.ssrfProxy.pullPolicy }}"
name: squid
{{- if .Values.ssrfProxy.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.ssrfProxy.customLivenessProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.ssrfProxy.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.ssrfProxy.customReadinessProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.ssrfProxy.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.ssrfProxy.customStartupProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.ssrfProxy.containerSecurityContext }}
securityContext:
{{ toYaml .Values.ssrfProxy.containerSecurityContext | indent 10 }}
{{- end }}
env:
{{- if .Values.ssrfProxy.extraEnv }}
{{- toYaml .Values.ssrfProxy.extraEnv | nindent 8 }}
{{- end }}
ports:
- name: http
containerPort: 3128
protocol: TCP
volumeMounts:
- name: squid-conf
mountPath: /etc/squid/squid.conf
readOnly: true
subPath: squid.conf
{{- if .Values.ssrfProxy.log.persistence.enabled }}
- name: squid-log
mountPath: {{ .Values.ssrfProxy.log.persistence.mountPath | quote }}
subPath: {{ .Values.ssrfProxy.log.persistence.persistentVolumeClaim.subPath | default "" }}
{{- end }}
resources:
{{- toYaml .Values.ssrfProxy.resources | nindent 12 }}
securityContext:
allowPrivilegeEscalation: {{ .Values.ssrfProxy.privileged }}
{{- if and (.Values.nodeSelector) (not .Values.ssrfProxy.nodeSelector) }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.ssrfProxy.nodeSelector }}
nodeSelector:
{{ toYaml .Values.ssrfProxy.nodeSelector | indent 8 }}
{{- end }}
{{- if and (.Values.affinity) (not .Values.ssrfProxy.affinity) }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.ssrfProxy.affinity }}
affinity:
{{ toYaml .Values.ssrfProxy.affinity | indent 8 }}
{{- end }}
{{- if and (.Values.tolerations) (not .Values.ssrfProxy.tolerations) }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.ssrfProxy.tolerations }}
tolerations:
{{ toYaml .Values.ssrfProxy.tolerations | indent 8 }}
{{- end }}
volumes:
- name: squid-conf
configMap:
defaultMode: 420
name: {{ template "dify.ssrfProxy.fullname" . }}
{{- if .Values.ssrfProxy.log.persistence.enabled }}
- name: squid-log
persistentVolumeClaim:
claimName: {{ .Values.ssrfProxy.log.persistence.persistentVolumeClaim.existingClaim | default (printf "%s-logs" (include "dify.ssrfProxy.fullname" . | trunc 58)) }}
{{- end }}
{{- end }}
+13
View File
@@ -0,0 +1,13 @@
{{- if .Values.ssrfProxy.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dify.ssrfProxy.serviceAccountName" . }}
labels: {{- include "dify.labels" . | nindent 4 }}
component: ssrfProxy
{{- if or .Values.ssrfProxy.serviceAccount.annotations (include "dify.ud.annotations" .) }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.ssrfProxy.serviceAccount.annotations (include "dify.ud.annotations" .) ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.ssrfProxy.serviceAccount.automountServiceAccountToken }}
{{- end }}
+29
View File
@@ -0,0 +1,29 @@
{{- if .Values.ssrfProxy.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "dify.ssrfProxy.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
{{- if .Values.ssrfProxy.service.labels }}
{{ toYaml .Values.ssrfProxy.service.labels | indent 4 }}
{{- end }}
component: "ssrf-proxy"
{{- with .Values.ssrfProxy.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
type: ClusterIP
{{- if .Values.ssrfProxy.service.clusterIP }}
clusterIP: {{ .Values.ssrfProxy.service.clusterIP }}
{{- end }}
ports:
- name: http-squid
port: {{ .Values.ssrfProxy.service.port }}
protocol: TCP
targetPort: http
selector:
{{ include "dify.selectorLabels" . | indent 4 }}
component: "ssrf-proxy"
{{- end }}
+15
View File
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "dify.fullname" . }}-test-connection"
labels:
{{- include "dify.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "dify.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
+52
View File
@@ -0,0 +1,52 @@
{{/*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{/* vim: set filetype=mustache: */}}
{{/*
Renders a value that contains template perhaps with scope if the scope is present.
Usage:
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
*/}}
{{- define "common.tplvalues.render" -}}
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
{{- if contains "{{" (toJson .value) }}
{{- if .scope }}
{{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
{{- else }}
{{- tpl $value .context }}
{{- end }}
{{- else }}
{{- $value }}
{{- end }}
{{- end -}}
{{/*
Merge a list of values that contains template after rendering them.
Merge precedence is consistent with http://masterminds.github.io/sprig/dicts.html#merge-mustmerge
Usage:
{{ include "common.tplvalues.merge" ( dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $ ) }}
*/}}
{{- define "common.tplvalues.merge" -}}
{{- $dst := dict -}}
{{- range .values -}}
{{- $dst = include "common.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | merge $dst -}}
{{- end -}}
{{ $dst | toYaml }}
{{- end -}}
{{/*
Merge a list of values that contains template after rendering them.
Merge precedence is consistent with https://masterminds.github.io/sprig/dicts.html#mergeoverwrite-mustmergeoverwrite
Usage:
{{ include "common.tplvalues.merge-overwrite" ( dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $ ) }}
*/}}
{{- define "common.tplvalues.merge-overwrite" -}}
{{- $dst := dict -}}
{{- range .values -}}
{{- $dst = include "common.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | mergeOverwrite $dst -}}
{{- end -}}
{{ $dst | toYaml }}
{{- end -}}
+6
View File
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dify.web.fullname" . }}
data:
{{- include "dify.web.config" . | nindent 2 }}
+125
View File
@@ -0,0 +1,125 @@
{{- if and .Values.web.enabled}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{ include "dify.ud.annotations" . | indent 4 }}
descriptions: web server
labels:
{{- include "dify.labels" . | nindent 4 }}
component: web
# app: {{ template "dify.web.fullname" . }}
{{ include "dify.ud.labels" . | indent 4 }}
name: {{ template "dify.web.fullname" . }}
spec:
replicas: {{ .Values.web.replicas }}
selector:
matchLabels:
{{- include "dify.selectorLabels" . | nindent 6 }}
component: web
{{/*
# Required labels for istio
# app: {{ template "dify.web.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
template:
metadata:
annotations:
checksum/web-config: {{ include (print $.Template.BasePath "/web-config.yaml") . | sha256sum }}
{{ include "dify.ud.annotations" . | indent 8 }}
labels:
{{- include "dify.selectorLabels" . | nindent 8 }}
component: web
{{/*
# Required labels for istio
# app: {{ template "dify.web.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
{{ include "dify.ud.labels" . | indent 8 }}
spec:
serviceAccountName: {{ include "dify.web.serviceAccountName" . }}
{{- if .Values.image.web.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.web.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.web.podSecurityContext }}
securityContext:
{{ toYaml .Values.web.podSecurityContext | indent 8 }}
{{- end }}
containers:
- image: "{{ .Values.image.web.repository }}:{{ default .Chart.AppVersion .Values.image.web.tag }}"
imagePullPolicy: "{{ .Values.image.web.pullPolicy }}"
name: web
{{- if .Values.web.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.web.customLivenessProbe "context" $) | nindent 10 }}
{{- else if .Values.web.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.web.livenessProbe "enabled") "context" $) | nindent 10 }}
httpGet:
path: /apps
port: web
httpHeaders:
- name: accept-language
value: en
{{- end }}
{{- if .Values.web.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.web.customReadinessProbe "context" $) | nindent 10 }}
{{- else if .Values.web.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.web.readinessProbe "enabled") "context" $) | nindent 10 }}
httpGet:
path: /apps
port: web
httpHeaders:
- name: accept-language
value: en
{{- end }}
{{- if .Values.web.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.web.customStartupProbe "context" $) | nindent 10 }}
{{- else if .Values.web.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.web.startupProbe "enabled") "context" $) | nindent 10 }}
tcpSocket:
port: web
{{- end }}
{{- if .Values.web.containerSecurityContext }}
securityContext:
{{ toYaml .Values.web.containerSecurityContext | indent 10 }}
{{- end }}
env:
{{- if .Values.web.extraEnv }}
{{- toYaml .Values.web.extraEnv | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ template "dify.web.fullname" . }}
ports:
- name: web
containerPort: 3000
protocol: TCP
resources:
{{- toYaml .Values.web.resources | nindent 12 }}
{{- if and (.Values.nodeSelector) (not .Values.web.nodeSelector) }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.web.nodeSelector }}
nodeSelector:
{{ toYaml .Values.web.nodeSelector | indent 8 }}
{{- end }}
{{- if and (.Values.affinity) (not .Values.web.affinity) }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.web.affinity }}
affinity:
{{ toYaml .Values.web.affinity | indent 8 }}
{{- end }}
{{- if and (.Values.tolerations) (not .Values.web.tolerations) }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.web.tolerations }}
tolerations:
{{ toYaml .Values.web.tolerations | indent 8 }}
{{- end }}
{{- end }}
+13
View File
@@ -0,0 +1,13 @@
{{- if .Values.web.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dify.web.serviceAccountName" . }}
labels: {{- include "dify.labels" . | nindent 4 }}
component: web
{{- if or .Values.web.serviceAccount.annotations (include "dify.ud.annotations" .) }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.web.serviceAccount.annotations (include "dify.ud.annotations" .) ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.web.serviceAccount.automountServiceAccountToken }}
{{- end }}
+29
View File
@@ -0,0 +1,29 @@
{{- if .Values.web.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "dify.web.fullname" . }}
labels:
{{ include "dify.labels" . | indent 4 }}
{{- if .Values.web.service.labels }}
{{ toYaml .Values.web.service.labels | indent 4 }}
{{- end }}
component: "web"
{{- with .Values.web.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
type: ClusterIP
{{- if .Values.web.service.clusterIP }}
clusterIP: {{ .Values.web.service.clusterIP }}
{{- end }}
ports:
- name: http-web
port: {{ .Values.web.service.port }}
protocol: TCP
targetPort: web
selector:
{{ include "dify.selectorLabels" . | indent 4 }}
component: "web"
{{- end }}
+6
View File
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dify.worker.fullname" . }}
data:
{{- include "dify.worker.config" . | nindent 2 }}
+130
View File
@@ -0,0 +1,130 @@
{{- if and .Values.worker.enabled}}
{{- $usePvc := not (or .Values.externalS3.enabled .Values.externalOSS.enabled .Values.externalAzureBlobStorage.enabled .Values.externalGCS.enabled .Values.externalCOS.enabled) -}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{ include "dify.ud.annotations" . | indent 4 }}
descriptions: worker
labels:
{{- include "dify.labels" . | nindent 4 }}
component: worker
# app: {{ template "dify.worker.fullname" . }}
{{ include "dify.ud.labels" . | indent 4 }}
name: {{ template "dify.worker.fullname" . }}
spec:
replicas: {{ .Values.worker.replicas }}
selector:
matchLabels:
{{- include "dify.selectorLabels" . | nindent 6 }}
component: worker
{{/*
# Required labels for istio
# app: {{ template "dify.worker.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
template:
metadata:
annotations:
checksum/worker-config: {{ include (print $.Template.BasePath "/worker-config.yaml") . | sha256sum }}
checksum/worker-secret: {{ include (print $.Template.BasePath "/worker-secret.yaml") . | sha256sum }}
{{ include "dify.ud.annotations" . | indent 8 }}
labels:
{{- include "dify.selectorLabels" . | nindent 8 }}
component: worker
{{/*
# Required labels for istio
# app: {{ template "dify.worker.fullname" . }}
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
*/}}
{{ include "dify.ud.labels" . | indent 8 }}
spec:
serviceAccountName: {{ include "dify.worker.serviceAccountName" . }}
{{- if .Values.image.api.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.api.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.worker.podSecurityContext }}
securityContext:
{{ toYaml .Values.worker.podSecurityContext | indent 8 }}
{{- end }}
initContainers:
- name: init
image: "{{.Values.image.python.repository }}:{{ default "3.12-slim" .Values.image.python.tag }}"
imagePullPolicy: "{{.Values.image.python.pullPolicy }}"
command: ["/bin/sh"]
args: ["-c", "pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn"]
volumeMounts:
- name: python-config
mountPath: /root/.config/pip
containers:
- image: "{{ .Values.image.api.repository }}:{{ default .Chart.AppVersion .Values.image.api.tag }}"
imagePullPolicy: "{{ .Values.image.api.pullPolicy }}"
name: worker
{{- if .Values.worker.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.worker.customLivenessProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.worker.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.worker.customReadinessProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.worker.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.worker.customStartupProbe "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.worker.containerSecurityContext }}
securityContext:
{{ toYaml .Values.worker.containerSecurityContext | indent 10 }}
{{- end }}
env:
{{- if .Values.worker.extraEnv }}
{{- toYaml .Values.worker.extraEnv | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ template "dify.worker.fullname" . }}
- secretRef:
name: {{ template "dify.worker.fullname" . }}
resources:
{{- toYaml .Values.worker.resources | nindent 12 }}
volumeMounts:
- name: python-config
mountPath: /root/.config/pip
{{- if $usePvc }}
- name: app-data
mountPath: {{ .Values.api.persistence.mountPath | quote }}
subPath: {{ .Values.api.persistence.persistentVolumeClaim.subPath | default "" }}
{{- end }}
{{- if and (.Values.nodeSelector) (not .Values.worker.nodeSelector) }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.worker.nodeSelector }}
nodeSelector:
{{ toYaml .Values.worker.nodeSelector | indent 8 }}
{{- end }}
{{- if and (.Values.affinity) (not .Values.worker.affinity) }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.worker.affinity }}
affinity:
{{ toYaml .Values.worker.affinity | indent 8 }}
{{- end }}
{{- if and (.Values.tolerations) (not .Values.worker.tolerations) }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.worker.tolerations }}
tolerations:
{{ toYaml .Values.worker.tolerations | indent 8 }}
{{- end }}
volumes:
- name: python-config
emptyDir: {}
{{- if $usePvc }}
- name: app-data
persistentVolumeClaim:
claimName: {{ .Values.api.persistence.persistentVolumeClaim.existingClaim | default (printf "%s" (include "dify.fullname" . | trunc 58)) }}
{{- end }}
{{- end }}
+7
View File
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "dify.worker.fullname" . }}
type: Opaque
data:
{{- include "dify.worker.credentials" . | nindent 2 }}
+13
View File
@@ -0,0 +1,13 @@
{{- if .Values.worker.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dify.worker.serviceAccountName" . }}
labels: {{- include "dify.labels" . | nindent 4 }}
component: worker
{{- if or .Values.worker.serviceAccount.annotations (include "dify.ud.annotations" .) }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.worker.serviceAccount.annotations (include "dify.ud.annotations" .) ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.worker.serviceAccount.automountServiceAccountToken }}
{{- end }}