Skip to main content

Overview

Dify is an open-source builder for LLM applications: chatbots, agents and visual workflows with RAG knowledge bases. You build an app in the browser, then publish it as a web page, call it through the REST service API or expose it as an MCP server. This template runs Dify on a bundled PostgreSQL with pgvector and a bundled Redis. A login is always required.
This template does not create a GVC. It deploys into an existing GVC that you already have, and that GVC should have exactly one location, because the database, Redis, both volumes and the plugin daemon run in one location.

What Gets Created

The template creates no credentials. The public *.cpln.app URL is on by default and every page needs a Dify login. Each Dify tier accepts connections only from the tiers that call it.

Prerequisites

1

Create the Dify keys secret

A dictionary secret holding Dify’s own keys. Use only letters and digits in every value, and keep initPassword to at most 30 characters:
Set dify.secretName to this name.
2

Create the code sandbox key secret

An opaque secret holding the key that Dify and the code sandbox share:
Set codeExecution.apiKeySecretName to this name.
3

Create the database credentials secret

A dictionary secret with exactly username, password and database, letters and digits only:
Set postgres.config.credentialsSecretName to this name (or postgresHA.config.credentialsSecretName with the HA database).
4

Create the Redis password secret

A dictionary secret with a password key, letters and digits only. A password is required because user code runs inside this GVC:
Set redis.redis.auth.fromSecret.name to this name.
Secret names are org-wide, so give each release its own secrets. A value with other characters stops the API, worker and scheduler at start with a log line naming the key. Backups and a custom domain are optional, see Backing Up and Connecting.
Every secret your release names must exist before you install. If one does not, the deployment waits silently: cpln logs returns nothing, and the only place the missing secret is named is status.versions[].message in cpln workload get-deployments RELEASE_NAME-dify-api --gvc GVC_NAME -o yaml. Create the secret and the deployment recovers on its own after several minutes, or run cpln workload force-redeployment WORKLOAD_NAME --gvc GVC_NAME on each Dify workload to skip the wait.

Installation

The required values are the names of the four secrets from Prerequisites:
To install with the highly available database, add --set postgres.enabled=false --set postgresHA.enabled=true --set postgresHA.config.credentialsSecretName=DB_CREDENTIALS_SECRET_NAME. To install with the CLI, UI, Terraform or Pulumi, follow the instructions for your preferred method:

UI

Browse, install, and manage templates visually

CLI

Manage templates from your terminal

Terraform

Declare templates in your Terraform configurations

Pulumi

Declare templates in your Pulumi programs

Configuration

Dify

The gateway, web and beat tiers take the same resources shape under dify.resources.
Each API and worker process holds up to 8 database connections (SQLALCHEMY_POOL_SIZE 5 plus SQLALCHEMY_MAX_OVERFLOW 3), which allows about 8 concurrent runs per API replica. To allow more, set both in dify.extraEnv, staying within PostgreSQL’s 100 connections:

Code Execution and Network

Database

Redis

Connecting

Dify builds every link, cookie and webhook from the public URL, and the login works only on that exact address. With dify.publicUrl empty it is the gateway’s *.cpln.app endpoint. Behind a custom domain, route the domain to the RELEASE_NAME-dify workload and set dify.publicUrl to it. With publicAccess.enabled: false, set dify.publicUrl to the address users open, such as http://localhost:8080 for port-forward. To check the gateway, forward the port and read its health:
Streaming responses and long runs pass through the gateway unbuffered. The public endpoint cuts a request after dify.requestTimeoutSeconds; calls from inside the GVC over cpln.local are not subject to it.

First Run

Open the public URL. Dify asks for the initPassword from the Dify keys secret, then lets you create the admin account on the /install page. Read the password with cpln secret reveal DIFY_SECRET_NAME -o yaml. Self sign-up and creating more workspaces are turned off; invite members from Settings → Members, which shows an invite link to copy because the template sends no email.

Operations

Backing Up

All state lives in PostgreSQL and the file storage volume. Enable postgres.backup.enabled (or postgresHA.backup.enabled with the HA database) and fill in the provider block; the keys and defaults are in the chart’s values.yaml. The bucket, cloud account and IAM policy are set up as described in the postgres or postgres-highly-available template, and a MinIO provider needs a dictionary secret with the keys accessKey and secretKey. Restore steps are in those templates’ pages. The backup covers the database only; uploaded files and the keys that decrypt saved provider credentials on the file storage volume are not included.

Backup retention

The backup job only uploads; it never deletes old backups. To keep a fixed window, add a lifecycle rule on the bucket that expires objects under the backup prefix. Each backup is a complete, standalone copy, so expiring old ones never affects restoring a newer one. Set the window to at least your retention plus one backup interval, and note that an age rule keeps no minimum: if backups stop running, the last ones expire too. In wal-g mode (postgresHA.backup.mode: wal-g), a restore needs the newest full base backup plus the WAL files written after it, all under the same prefix and never rewritten. Older base backups and the WAL before them are not needed, so the same rule is safe as long as the window is longer than two base-backup intervals (postgresHA.backup.walg.intervalSeconds). If base backups stop while WAL archiving continues, the rule eventually expires the last base backup, so check that new basebackups_005/ entries keep appearing. The rules below use the default prefix postgres/backups/; change it if you changed postgres.backup.<provider>.prefix (or postgresHA.backup.<provider>.prefix in HA mode). AWS S3. put-bucket-lifecycle-configuration replaces every existing rule on the bucket, so check for existing rules first and add them to the file:
Google Cloud Storage. --lifecycle-file also replaces the bucket’s existing rules; check with gcloud storage buckets describe gs://BUCKET_NAME --format='json(lifecycle_config)' first:
MinIO (adds a rule alongside existing ones; the access key needs s3:PutLifecycleConfiguration, which the built-in readwrite policy grants):
Lifecycle rules run in the background; objects are removed within about a day of reaching the age. The Noncurrent parts matter only on a versioned bucket, where expiry otherwise just adds a delete marker.

Upgrading from 1.x

The single-instance database of 2.0.0 runs PostgreSQL 19. A 1.x release’s data directory is PostgreSQL 18, and a data directory only starts under the major version that created it: on a PostgreSQL 19 image the database container does not start PostgreSQL and changes nothing on the volume. RELEASE_NAME-postgres stays not ready, Dify waits for it, and the database logs repeat a [pg-guard] REFUSING TO START message:
Stay on PostgreSQL 18. Pin the pgvector image, and keep the pin in your values file for every later upgrade (cpln helm upgrade does not reuse the release’s values). Use the pgvector image (the database log names it), because Dify’s knowledge bases need the extension:
If an upgrade ran without the pin, run the same upgrade again with --set postgres.image=pgvector/pgvector:0.8.7-pg18; the database comes back on its data. The Console upgrade wizard keeps the installed image and warns before a change to another major version. Move to PostgreSQL 19 (a dump and restore into a new release in the same GVC; Dify gets a new endpoint and cannot write while the copy runs):
  1. Install 2.0.0 as a new release with the same dify.secretName, postgres.config.credentialsSecretName and codeExecution.apiKeySecretName. Wait until NEW_RELEASE-dify-api and NEW_RELEASE-dify-plugin-daemon are ready (they create empty schemas); do not open its /install page.
  2. Copy the file storage (uploads and the keys that decrypt saved model credentials) and the installed plugins through your machine while the old release still runs (./cwd, the plugins’ Python environments, is left out: the plugin daemon rebuilds it):
    cpln cp may end with Cannot change mode ... Operation not permitted and exit 2: the volume’s root directory belongs to root, so its mode cannot be copied. The files themselves arrive; check with cpln workload exec NEW_RELEASE-dify-api --gvc GVC_NAME --container api -- ls -la /app/api/storage.
  3. Stop writes on both releases:
  4. Stream both databases (Dify’s own and the plugin daemon’s dify_plugin) into the new release, inside its database container (--clean replaces the empty schemas; nothing binary crosses cpln workload exec):
  5. Start the new release (for the first few minutes the plugin daemon rebuilds the plugins’ environments, and knowledge bases and the plugin list return errors until it finishes), sign in with your existing account, check your apps, knowledge bases and model providers, and point your users at the new URL (or move your custom domain and dify.publicUrl):
  6. Uninstall the old release.
Highly available mode (postgresHA). The upgrade is in place: an existing cluster keeps the PostgreSQL major it was created with (17 for a 1.x release) on the new patroni-postgres:0.9 image, and only a new cluster starts on PostgreSQL 18. To move an existing cluster to 18, follow Upgrading an existing cluster to PostgreSQL 18 in the postgres-highly-available template, with a new Dify 2.0.0 release (postgresHA.enabled: true, the same secrets) as the second release. This chart names its database workloads RELEASE_NAME-postgres-ha and RELEASE_NAME-postgres-ha-proxy, so those commands apply as written, and pg_dumpall copies both of Dify’s databases. Copy the file storage and plugins as in step 2, and stop both releases’ Dify workloads as in step 3 while the copy runs. The backup identity no longer carries cpln-connector; your bucket-scoped IAM policy needs no change.

Scaling and Availability

Set dify.replicas from 1 to 3 for the gateway, web, API, code sandbox and SSRF proxy, and worker.replicas from 1 to 3 for the worker. The scheduler and the plugin daemon always run one replica. When several API replicas start together, one applies the database migrations and the others wait for it. For near-zero-downtime upgrades and failover, set dify.replicas: 2, worker.replicas: 2 and postgresHA.enabled: true. Redis stays a single node. After changing a secret a workload reads, redeploy the workloads that use it:

Clearing a Login Lockout

Dify locks an email address out for 24 hours after 6 failed logins, from any address. To clear it, delete the lock from Redis:

Troubleshooting

A secret named in the values does not exist. Read status.versions[].message with cpln workload get-deployments RELEASE_NAME-dify-api --gvc GVC_NAME -o yaml, create the secret, then run cpln workload force-redeployment WORKLOAD_NAME --gvc GVC_NAME on each Dify workload.
A database or Redis value contains characters other than letters and digits, secretKey is empty, or initPassword is longer than 30 characters. Fix the secret and redeploy the Dify workloads.
The login works only on the exact address in dify.publicUrl. For a private install or a custom domain, set dify.publicUrl to the address users open, without a trailing slash.
The SSRF proxy refuses private, link-local and in-GVC addresses (*.cpln.local) for HTTP Request nodes, tools and Python HTTP calls. Set ssrfProxy.enabled: false to lift it, knowing that flows can then call any service in the GVC. Model-provider plugins run in the plugin daemon, not through the proxy, so Ollama, vLLM and LiteLLM providers can use in-GVC URLs.
Concurrent runs exhausted the database connection pool. Raise SQLALCHEMY_POOL_SIZE and SQLALCHEMY_MAX_OVERFLOW in dify.extraEnv, as shown in Configuration.
The public endpoint cuts requests after dify.requestTimeoutSeconds (default 600, maximum 3600). Raise it for longer calls.
Clear the lock as shown in Clearing a Login Lockout.
The error names the offending value. The template rejects replica counts outside 1-3, enabling both or neither database, redis.mode other than dev, and extraEnv names that the chart sets itself.

Important Notes

  • The Dify license allows one workspace per install, not a multi-tenant service, and forbids removing or changing the Dify logo and copyright in the console.
  • Never rotate secretKey (it signs every login and shared link) and never delete the file storage volume (it holds the keys that decrypt the model-provider credentials saved in Dify).
  • Anyone who can edit an app can run Python and JavaScript in the code sandbox, and that code can open direct connections to the internet. The Dify API, web and plugin daemon refuse the sandbox, but the other services in this GVC, including the bundled PostgreSQL and Redis, are guarded only by their passwords. Give accounts only to people you trust.
  • With the SSRF proxy on, HTTP Request nodes, tools and Python requests calls in Code nodes go through it. JavaScript code gets no proxy.
  • Plugins install from the Dify marketplace or an uploaded package, and only signed plugins are accepted.
  • Use a single-location GVC: the database, Redis, both volumes and the plugin daemon run in one location.
  • The first helm upgrade after an install can restart the bundled database, which briefly interrupts Dify.
  • Uninstalling deletes the database and both volumes, and with them every app, user, knowledge base and installed plugin.
  • Upgrading a 1.x release with the single-instance database needs postgres.image: pgvector/pgvector:0.8.7-pg18 in your values on that and every later upgrade, or the database refuses to start (data untouched); moving the data to PostgreSQL 19 is a dump and restore into a new release. The file storage and installed plugins are copied separately from the database. See Upgrading from 1.x.

External References

Dify documentation

Concepts, apps and deployment

Environment variables

Dify settings

Dify service API

Calling published apps over REST

Dify as an MCP server

Exposing apps as MCP tools

Dify on GitHub

Source, license and issues