Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions charts/dify/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ type: application
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)

version: 0.36.0
version: 0.36.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.12.1"
appVersion: "1.14.0-rc1"

dependencies:
- name: postgresql
Expand Down
19 changes: 19 additions & 0 deletions charts/dify/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{ template "dify.fullname" . }}-sandbox
{{- end -}}

{{/*
Create a default fully qualified agentbox name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dify.agentbox.fullname" -}}
{{ template "dify.fullname" . }}-agentbox
{{- 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).
Expand Down Expand Up @@ -162,6 +170,17 @@ Create the name of the service account to use for the Sandbox
{{- end -}}
{{- end -}}

{{/*
Create the name of the service account to use for the Agentbox
*/}}
{{- define "dify.agentbox.serviceAccountName" -}}
{{- if .Values.agentbox.serviceAccount.create -}}
{{ default (include "dify.agentbox.fullname" .) .Values.agentbox.serviceAccount.name | trunc 63 | trimSuffix "-" }}
{{- else -}}
{{ default "default" .Values.agentbox.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Create the name of the service account to use for the ssrfProxy
*/}}
Expand Down
9 changes: 9 additions & 0 deletions charts/dify/templates/agentbox-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dify.agentbox.fullname" . }}
labels:
{{- include "dify.labels" . | nindent 4 }}
component: agentbox
data:
{{- include "dify.agentbox.config" . | nindent 2 }}
148 changes: 148 additions & 0 deletions charts/dify/templates/agentbox-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{{- if and .Values.agentbox.enabled}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{- include "dify.ud.annotations" . | nindent 4 }}
descriptions: agentbox
labels:
{{- include "dify.labels" . | nindent 4 }}
component: agentbox
{{- include "dify.ud.labels" . | nindent 4 }}
name: {{ template "dify.agentbox.fullname" . }}
spec:
replicas: {{ .Values.agentbox.replicas }}
selector:
matchLabels:
{{- include "dify.selectorLabels" . | nindent 6 }}
component: agentbox
{{- if .Values.agentbox.updateStrategy }}
strategy: {{- toYaml .Values.agentbox.updateStrategy | nindent 4 }}
{{- end }}
template:
metadata:
annotations:
checksum/agentbox-config: {{ include (print $.Template.BasePath "/agentbox-config.yaml") . | sha256sum }}
checksum/agentbox-secret: {{ include (print $.Template.BasePath "/agentbox-secret.yaml") . | sha256sum }}
{{- include "dify.ud.annotations" . | nindent 8 }}
labels:
{{- include "dify.selectorLabels" . | nindent 8 }}
component: agentbox
{{- include "dify.ud.labels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "dify.agentbox.serviceAccountName" . }}
{{- if .Values.agentbox.priorityClassName }}
priorityClassName: {{ .Values.agentbox.priorityClassName | quote }}
{{- end }}
{{- if .Values.image.agentbox.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.agentbox.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.agentbox.hostAliases }}
hostAliases:
{{- toYaml .Values.agentbox.hostAliases | nindent 8 }}
{{- end }}
{{- if .Values.agentbox.podSecurityContext }}
securityContext:
{{- toYaml .Values.agentbox.podSecurityContext | nindent 8 }}
{{- end }}
containers:
- image: "{{ .Values.image.agentbox.repository }}:{{ .Values.image.agentbox.tag }}"
imagePullPolicy: "{{ .Values.image.agentbox.pullPolicy }}"
name: agentbox
command: ["sh", "-c"]
args:
- |
set -e;
if ! command -v sshd >/dev/null 2>&1; then
apt-get update;
DEBIAN_FRONTEND=noninteractive apt-get install -y openssh-server;
rm -rf /var/lib/apt/lists/*;
fi;
mkdir -p /run/sshd;
ssh-keygen -A;
if [ "$${AGENTBOX_SSH_USERNAME}" = "root" ]; then
echo "root:$${AGENTBOX_SSH_PASSWORD}" | chpasswd;
grep -q '^PermitRootLogin' /etc/ssh/sshd_config && sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config || echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config;
else
id -u "$${AGENTBOX_SSH_USERNAME}" >/dev/null 2>&1 || useradd -m -s /bin/bash "$${AGENTBOX_SSH_USERNAME}";
echo "$${AGENTBOX_SSH_USERNAME}:$${AGENTBOX_SSH_PASSWORD}" | chpasswd;
fi;
grep -q '^PasswordAuthentication' /etc/ssh/sshd_config && sed -i 's/^PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config || echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config;
nohup socat TCP-LISTEN:$${AGENTBOX_SOCAT_TARGET_PORT},bind=127.0.0.1,fork,reuseaddr TCP:$${AGENTBOX_SOCAT_TARGET_HOST}:$${AGENTBOX_SOCAT_TARGET_PORT} >/tmp/socat.log 2>&1 &
exec /usr/sbin/sshd -D -p $${AGENTBOX_SSH_PORT}
{{- if .Values.agentbox.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.agentbox.customLivenessProbe "context" $) | nindent 12 }}
{{- else if .Values.agentbox.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.agentbox.livenessProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: agentbox
{{- end }}
{{- if .Values.agentbox.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.agentbox.customReadinessProbe "context" $) | nindent 12 }}
{{- else if .Values.agentbox.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.agentbox.readinessProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: agentbox
{{- end }}
{{- if .Values.agentbox.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.agentbox.customStartupProbe "context" $) | nindent 12 }}
{{- else if .Values.agentbox.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.agentbox.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: agentbox
{{- end }}
{{- if .Values.agentbox.containerSecurityContext }}
securityContext:
{{- toYaml .Values.agentbox.containerSecurityContext | nindent 12 }}
{{- end }}
env:
{{- if .Values.agentbox.extraEnv }}
{{- toYaml .Values.agentbox.extraEnv | nindent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ template "dify.agentbox.fullname" . }}
- secretRef:
name: {{ template "dify.agentbox.fullname" . }}
ports:
- name: agentbox
containerPort: 22
protocol: TCP
resources:
{{- toYaml .Values.agentbox.resources | nindent 14 }}
{{- if .Values.agentbox.extraVolumeMounts }}
volumeMounts:
{{- include "common.tplvalues.render" (dict "value" .Values.agentbox.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.agentbox.extraVolumes }}
volumes:
{{- include "common.tplvalues.render" (dict "value" .Values.agentbox.extraVolumes "context" $) | nindent 8 }}
{{- end }}
{{- if and (.Values.nodeSelector) (not .Values.agentbox.nodeSelector) }}
nodeSelector:
{{- toYaml .Values.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.agentbox.nodeSelector }}
nodeSelector:
{{- toYaml .Values.agentbox.nodeSelector | nindent 8 }}
{{- end }}
{{- if and (.Values.affinity) (not .Values.agentbox.affinity) }}
affinity:
{{- toYaml .Values.affinity | nindent 8 }}
{{- end }}
{{- if .Values.agentbox.affinity }}
affinity:
{{- toYaml .Values.agentbox.affinity | nindent 8 }}
{{- end }}
{{- if and (.Values.tolerations) (not .Values.agentbox.tolerations) }}
tolerations:
{{- toYaml .Values.tolerations | nindent 8 }}
{{- end }}
{{- if .Values.agentbox.tolerations }}
tolerations:
{{- toYaml .Values.agentbox.tolerations | nindent 8 }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/dify/templates/agentbox-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if and .Values.agentbox.enabled (not (and .Values.externalSecret.enabled .Values.externalSecret.agentbox.enabled)) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "dify.agentbox.fullname" . }}
labels:
{{- include "dify.labels" . | nindent 4 }}
component: agentbox
type: Opaque
data:
{{- include "dify.agentbox.credentials" . | nindent 2 }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/dify/templates/agentbox-service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if and .Values.agentbox.enabled .Values.agentbox.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dify.agentbox.serviceAccountName" . }}
labels:
{{- include "dify.labels" . | nindent 4 }}
component: agentbox
{{- if .Values.agentbox.serviceAccount.annotations }}
annotations:
{{- toYaml .Values.agentbox.serviceAccount.annotations | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.agentbox.serviceAccount.automountServiceAccountToken }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/dify/templates/agentbox-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.agentbox.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "dify.agentbox.fullname" . }}
labels:
{{- include "dify.labels" . | nindent 4 }}
component: agentbox
{{- include "dify.ud.labels" . | nindent 4 }}
annotations:
{{- include "dify.ud.annotations" . | nindent 4 }}
{{- if .Values.agentbox.service.annotations }}
{{- toYaml .Values.agentbox.service.annotations | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
{{- if .Values.agentbox.service.clusterIP }}
clusterIP: {{ .Values.agentbox.service.clusterIP }}
{{- end }}
ports:
- name: agentbox
port: {{ .Values.agentbox.service.port }}
targetPort: 22
protocol: TCP
selector:
{{- include "dify.selectorLabels" . | nindent 4 }}
component: agentbox
{{- end }}
6 changes: 6 additions & 0 deletions charts/dify/templates/config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,12 @@ HTTPS_PROXY: http://{{ template "dify.ssrfProxy.fullname" .}}:{{ .Values.ssrfPro
{{- end }}
{{- end }}

{{- define "dify.agentbox.config" -}}
AGENTBOX_SSH_PORT: {{ .Values.agentbox.environment.sshPort | quote }}
AGENTBOX_SOCAT_TARGET_HOST: {{ .Values.agentbox.environment.socatTargetHost | quote }}
AGENTBOX_SOCAT_TARGET_PORT: {{ .Values.agentbox.environment.socatTargetPort | quote }}
{{- end }}

{{- define "dify.nginx.config.proxy" }}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
5 changes: 5 additions & 0 deletions charts/dify/templates/credentials.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ SMTP_PASSWORD: {{ .Values.api.mail.smtp.password | b64enc | quote }}
API_KEY: {{ .Values.sandbox.auth.apiKey | default .Values.global.internalApiKey | b64enc | quote }}
{{- end }}

{{- define "dify.agentbox.credentials" -}}
AGENTBOX_SSH_USERNAME: {{ .Values.agentbox.environment.sshUsername | b64enc | quote }}
AGENTBOX_SSH_PASSWORD: {{ .Values.agentbox.environment.sshPassword | b64enc | quote }}
{{- end }}

{{- define "dify.pluginDaemon.credentials" -}}
{{ include "dify.db.credentials" . }}
{{ include "dify.redis.credentials" . }}
Expand Down
10 changes: 9 additions & 1 deletion charts/dify/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
"pullPolicy": { "type": "string" }
}
},
"agentbox": {
"type": "object",
"properties": {
"repository": { "type": "string" },
"tag": { "type": "string" },
"pullPolicy": { "type": "string" }
}
},
"pluginDaemon": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1061,4 +1069,4 @@
}
}
}
}
}
Loading
Loading