DifyAI on Kubernetes
July 23, 2025 ยท View on GitHub
This project provides a complete Kubernetes deployment for Dify, an open-source LLMOps platform. It includes all necessary components such as PostgreSQL, Redis, Weaviate, and Dify application modules like API, Web UI, Workers, and Plugin Daemon.
๐ Project Structure
.
โโโ api
โ โโโ service.yaml
โ โโโ statefulset.yaml
โโโ configmap
โ โโโ difyai-configmap.yaml
โ โโโ genconfig.sh
โ โโโ nginx-configmap-0.yaml
โ โโโ nginx-configmap-1.yaml
โ โโโ nginx-configmap-2.yaml
โ โโโ nginx-configmap-3.yaml
โ โโโ nginx-configmap-4.yaml
โ โโโ nginx-configmap-5.yaml
โ โโโ sandbox-configmap-0.yaml
โ โโโ sandbox-configmap-1.yaml
โ โโโ ssrf-proxy-configmap-0.yaml
โ โโโ ssrf-proxy-configmap-1.yaml
โโโ LICENSE
โโโ nginx
โ โโโ deployment.yaml
โ โโโ service.yaml
โโโ persistentvolumeclaim
โ โโโ difyai.yaml
โโโ plugin-daemon
โ โโโ deployment.yaml
โ โโโ service.yaml
โโโ postgresql
โ โโโ README.md
โ โโโ service.yaml
โ โโโ statefulset.yaml
โโโ README.md
โโโ redis
โ โโโ service.yaml
โ โโโ statefulset.yaml
โโโ sandbox
โ โโโ deployment.yaml
โ โโโ service.yaml
โโโ ssrf-proxy
โ โโโ deployment.yaml
โ โโโ service.yaml
โโโ weaviate
โ โโโ service.yaml
โ โโโ statefulset.yaml
โโโ web
โ โโโ deployment.yaml
โ โโโ service.yaml
โโโ worker
โโโ service.yaml
โโโ statefulset.yaml
๐ Features
- Full deployment of Dify backend components on Kubernetes
- Support for persistent volumes and configuration via ConfigMaps
- Modular and extensible structure
- Custom Nginx reverse proxy and sandbox environment included
- External integrations: PostgreSQL, Redis, Weaviate
โ๏ธ Prerequisites
- Kubernetes cluster (v1.20+)
- StorageClass for Persistent Volumes (e.g., Longhorn)
๐๏ธ Setup Guide
1. Clone the Repository:
git clone https://github.com/Zhoneym/DifyAI-Kubernetes.git
cd DifyAI-Kubernetes
2. Create a Project
kubectl create namespace difyai
3. Create Persistent Volume Claims:
kubectl create -f persistentvolumeclaim/difyai.yaml
4. Create ConfigMaps:
kubectl create -f configmap/difyai-configmap.yaml
kubectl create -f configmap/nginx-configmap-0.yaml -f configmap/nginx-configmap-1.yaml -f configmap/nginx-configmap-2.yaml -f configmap/nginx-configmap-3.yaml -f configmap/nginx-configmap-4.yaml -f configmap/nginx-configmap-5.yaml
kubectl create -f configmap/sandbox-configmap-0.yaml -f configmap/sandbox-configmap-1.yaml
kubectl create -f configmap/ssrf-proxy-configmap-0.yaml -f configmap/ssrf-proxy-configmap-1.yaml
5. Create Core Services:
-
PostgreSQL
kubectl create -f postgresql/statefulset.yaml -f postgresql/service.yaml
โ ๏ธ Note: You must initialize the database before proceeding with the deployment.
-
Redis
kubectl create -f redis/statefulset.yaml -f redis/service.yaml -
Weaviate
kubectl create -f weaviate/statefulset.yaml -f weaviate/service.yaml
6. Create Dify Components:
-
Plugin Daemon
kubectl create -f plugin-daemon/deployment.yaml -f plugin-daemon/service.yaml -
Sandbox
kubectl create -f sandbox/deployment.yaml -f sandbox/service.yaml -
SSRF Proxy
kubectl create -f ssrf-proxy/deployment.yaml -f ssrf-proxy/service.yaml -
API
kubectl create -f api/statefulset.yaml -f api/service.yaml -
Web UI
kubectl create -f web/deployment.yaml -f web/service.yaml -
Worker
kubectl create -f worker/statefulset.yaml -f worker/service.yaml -
Nginx
kubectl create -f nginx/deployment.yaml -f nginx/service.yaml
๐ Notes
- Configuration files can be customized under
configmap/ - Ensure that the correct environment variables are set in the Dify ConfigMap
- You may use
configmap/genconfig.shto generate the ConfigMap from a.envfile
๐ License
This project is licensed under the GPL License.