Deploying Dify on Kubernetes with Helm

Introduction

Dify is an open-source LLM-powered application development platform that simplifies prototyping, deploying, and managing AI applications. It provides a visual workflow builder, prompt IDE, RAG capabilities, and agent tools that integrate with various AI models like GPT, Mistral, and Llama3.

This blog post will guide you through deploying Dify on Kubernetes using a Helm chart to manage configurations efficiently.


Prerequisites

Before you begin, ensure you have the following:

  • A Kubernetes cluster (Minikube, Kind, EKS, AKS, GKE, etc.)
  • kubectl installed and configured
  • Helm installed (Install Helm)
  • Persistent Volume (PV) support for storing data
  • PostgreSQL & Redis deployed in your cluster (or external services)

Step 1: Clone the Dify Repository

1
2
git clone https://github.com/langgenius/dify.git
cd dify

Step 2: Deploy Dependencies

Dify requires PostgreSQL (for data storage) and Redis (for caching). You can deploy them using Helm:

Deploy PostgreSQL

1
2
3
4
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install dify-postgres bitnami/postgresql \
--set auth.postgresPassword=yourpassword \
--set primary.persistence.enabled=true

Deploy Redis

1
2
3
helm install dify-redis bitnami/redis \
--set auth.enabled=false \
--set master.persistence.enabled=true

Step 3: Deploy Dify using Helm

Create a Helm values file (values.yaml) for Dify:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
image:
repository: langgenius/dify
tag: latest
pullPolicy: IfNotPresent

env:
DATABASE_URL: "postgresql://postgres:yourpassword@dify-postgres.default.svc.cluster.local:5432/postgres"
REDIS_URL: "redis://dify-redis-master.default.svc.cluster.local:6379"
SECRET_KEY: "your-random-secret-key"
BASE_URL: "http://localhost"

service:
type: ClusterIP
port: 80

ingress:
enabled: true
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
hosts:
- host: dify.local
paths:
- path: /
pathType: ImplementationSpecific

Now, deploy Dify:

1
helm install dify ./helm-chart -f values.yaml

Step 4: Verify Deployment

Check the deployed pods:

1
kubectl get pods

Expose the service (if not using Ingress):

1
kubectl port-forward svc/dify 8080:80

Access the Dify Web UI at http://localhost:8080 and complete the installation.


Conclusion

In this guide, we successfully deployed Dify on Kubernetes using Helm, along with its dependencies. This setup provides scalability, ease of management, and better security compared to standalone Docker deployments.

Feel free to explore Dify’s agent tools, RAG pipelines, and LLMOps features to build AI-powered applications effectively!

Happy Deploying!