Zhoneym/DifyAI-Kubernetes

28

stars

20

commits

Shell

primary language

Jul 23, 2025

updated

README

DifyAI on Kubernetes

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.sh to generate the ConfigMap from a .env file

πŸ“œ License

This project is licensed under the GPL License.

πŸ™ Acknowledgements

Contributors

Zhoneym

20 commits

Zhoneym/DifyAI-Kubernetes

28

stars

20

commits

Shell

primary language

Jul 23, 2025

updated

README

DifyAI on Kubernetes

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.sh to generate the ConfigMap from a .env file

πŸ“œ License

This project is licensed under the GPL License.

πŸ™ Acknowledgements

Contributors

Zhoneym

20 commits

Languages

Shell

100.0%