langflow/docs/docs/Deployment/deployment-kubernetes.md
Mendon Kissling 2bbb0f5838
docs: clean up and test deployment documentation (#6029)
* docs: correct spelling and formatting in Docker deployment guide

* HuggingFace Spaces deployment documentation

* docs: simplify introduction for HuggingFace Spaces deployment guide

* docs: Update Kubernetes deployment documentation with comprehensive improvements

- Enhance Langflow Kubernetes deployment guide with clearer instructions
- Improve formatting, add more precise configuration examples
- Update service names, port forwarding, and scaling configuration details
- Add more explicit links to Helm chart repositories and values files
- Clarify runtime and IDE deployment sections with better explanations

* docs: Add Docker flow packaging guide and enhance deployment documentation

- Introduce new section on packaging Langflow flows as Docker images
- Provide step-by-step instructions for creating custom Docker images with flows
- Include example commands for building, running, and pushing Docker images
- Minor formatting and clarity improvements to existing Docker deployment guide

* docs: Refine Kubernetes and Docker deployment documentation

- Streamline Docker and Kubernetes deployment guides
- Improve clarity and conciseness of instructions
- Add more precise examples for deploying Langflow with custom images
- Enhance secret configuration and flow deployment explanations
- Simplify formatting and remove redundant text

* docs: Minor text refinements in Kubernetes and Docker deployment documentation

- Update link text for Langflow runtime deployment
- Correct capitalization and minor typos in deployment guides
- Improve clarity of deployment section descriptions

* revert-lockfiles

* Revert "HuggingFace Spaces deployment documentation"

This reverts commit 2943deb1e0964a05c6909d6e1afdf8bddf7173fb.

* Remove lockfiles from PR

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* docs: Standardize deployment documentation titles

* code-review

* docs: Refactor deployment documentation for clarity and conciseness

* shorten-nav-titles

* code-review-and-cleanup

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* service

* gcp

* hf-spaces

* railway-and-render

* kubernetes

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* remove-extra-heading

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

---------

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>
2025-02-26 21:21:14 +00:00

10 KiB

title slug
Deploy Langflow on Kubernetes /deployment-kubernetes

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

This guide demonstrates deploying Langflow on a Kubernetes cluster.

Two charts are available at the Langflow Helm Charts repository:

  • Deploy the Langflow IDE for the complete Langflow development environment.
  • Deploy the Langflow runtime to deploy a standalone Langflow application in a more secure and stable environment.

Deploy the Langflow IDE

The Langflow IDE deployment is a complete environment for developers to create, test, and debug their flows. It includes both the API and the UI.

The langflow-ide Helm chart is available in the Langflow Helm Charts repository.

Prerequisites

Prepare a Kubernetes cluster

This example uses Minikube, but you can use any Kubernetes cluster.

  1. Create a Kubernetes cluster on Minikube.

    minikube start
    
  2. Set kubectl to use Minikube.

    kubectl config use-context minikube
    

Install the Langflow IDE Helm chart

  1. Add the repository to Helm and update it.

    helm repo add langflow https://langflow-ai.github.io/langflow-helm-charts
    helm repo update
    
  2. Install Langflow with the default options in the langflow namespace.

    helm install langflow-ide langflow/langflow-ide -n langflow --create-namespace
    
  3. Check the status of the pods

    kubectl get pods -n langflow
    
    NAME                                 READY   STATUS    RESTARTS       AGE
    langflow-0                           1/1     Running   0              33s
    langflow-frontend-5d9c558dbb-g7tc9   1/1     Running   0              38s
    

Configure port forwarding to access Langflow

Enable local port forwarding to access Langflow from your local machine.

  1. To make the Langflow API accessible from your local machine at port 7860:
kubectl port-forward -n langflow svc/langflow-service-backend 7860:7860
  1. To make the Langflow UI accessible from your local machine at port 8080:
kubectl port-forward -n langflow svc/langflow-service 8080:8080

Now you can access:

  • The Langflow API at http://localhost:7860
  • The Langflow UI at http://localhost:8080

Configure the Langflow version

Langflow is deployed with the latest version by default.

To specify a different Langflow version, set the langflow.backend.image.tag and langflow.frontend.image.tag values in the values.yaml file.

langflow:
  backend:
    image:
      tag: "1.0.0a59"
  frontend:
    image:
      tag: "1.0.0a59"

Configure external storage

By default, the chart deploys a SQLite database stored in a local persistent disk. If you want to use an external PostgreSQL database, you can configure it in two ways:

  • Use the built-in PostgreSQL chart:
postgresql:
  enabled: true
  auth:
    username: "langflow"
    password: "langflow-postgres"
    database: "langflow-db"
  • Use an external database:
postgresql:
  enabled: false

langflow:
  backend:
    externalDatabase:
      enabled: true
      driver:
        value: "postgresql"
      port:
        value: "5432"
      user:
        value: "langflow"
      password:
        valueFrom:
          secretKeyRef:
            key: "password"
            name: "your-secret-name"
      database:
        value: "langflow-db"
    sqlite:
      enabled: false

Configure scaling

Scale the number of replicas and resources for both frontend and backend services:

langflow:
  backend:
    replicaCount: 1
    resources:
      requests:
        cpu: 0.5
        memory: 1Gi
      # limits:
      #   cpu: 0.5
      #   memory: 1Gi

  frontend:
    enabled: true
    replicaCount: 1
    resources:
      requests:
        cpu: 0.3
        memory: 512Mi
      # limits:
      #   cpu: 0.3
      #   memory: 512Mi

Deploy the Langflow runtime

The runtime chart is tailored for deploying applications in a production environment. It is focused on stability, performance, isolation, and security to ensure that applications run reliably and efficiently.

The langflow-runtime Helm chart is available in the Langflow Helm Charts repository.

Prerequisites

Install the Langflow runtime Helm chart

  1. Add the repository to Helm.
helm repo add langflow https://langflow-ai.github.io/langflow-helm-charts
helm repo update
  1. Install the Langflow app with the default options in the langflow namespace.

If you have a created a custom image with packaged flows, you can deploy Langflow by overriding the default values.yaml file with the --set flag.

  • Use a custom image with bundled flows:
helm install my-langflow-app langflow/langflow-runtime -n langflow --create-namespace --set image.repository=myuser/langflow-hello-world --set image.tag=1.0.0
  • Alternatively, install the chart and download the flows from a URL with the --set flag:
helm install my-langflow-app-with-flow langflow/langflow-runtime \
  -n langflow \
  --create-namespace \
  --set 'downloadFlows.flows[0].url=https://raw.githubusercontent.com/langflow-ai/langflow/dev/tests/data/basic_example.json'

:::important You may need to escape the square brackets in this command if you are using a shell that requires it:

helm install my-langflow-app-with-flow langflow/langflow-runtime \
  -n langflow \
  --create-namespace \
  --set 'downloadFlows.flows\[0\].url=https://raw.githubusercontent.com/langflow-ai/langflow/dev/tests/data/basic_example.json'

:::

  1. Check the status of the pods.
kubectl get pods -n langflow

Access the Langflow app API

  1. Get your service name.
kubectl get svc -n langflow

The service name is your release name followed by -langflow-runtime. For example, if you used helm install my-langflow-app-with-flow the service name is my-langflow-app-with-flow-langflow-runtime.

  1. Enable port forwarding to access Langflow from your local machine:
kubectl port-forward -n langflow svc/my-langflow-app-with-flow-langflow-runtime 7860:7860
  1. Confirm you can access the API at http://localhost:7860/api/v1/flows/ and view a list of flows.
curl -v http://localhost:7860/api/v1/flows/
  1. Execute the packaged flow.

The following command gets the first flow ID from the flows list and runs the flow.

# Get flow ID
id=$(curl -s "http://localhost:7860/api/v1/flows/" | jq -r '.[0].id')

# Run flow
curl -X POST \
    "http://localhost:7860/api/v1/run/$id?stream=false" \
    -H 'Content-Type: application/json' \
    -d '{
      "input_value": "Hello!",
      "output_type": "chat",
      "input_type": "chat"
    }'

Configure secrets

To inject secrets and Langflow global variables, use the secrets and env sections in the values.yaml file.

For example, the example flow JSON uses a global variable that is a secret. When you export the flow as JSON, it's recommended to not include the secret.

Instead, when importing the flow in the Langflow runtime, you can set the global variable in one of the following ways:

env:
  - name: openai_key_var
    valueFrom:
      secretKeyRef:
        name: openai-key
        key: openai-key

Or directly in the values file (not recommended for secret values):

env:
  - name: openai_key_var
    value: "sk-...."
  1. Create the secret:
kubectl create secret generic openai-credentials \
  --namespace langflow \
  --from-literal=OPENAI_API_KEY=sk...
  1. Verify the secret exists. The result is encrypted.
kubectl get secrets -n langflow openai-credentials
  1. Upgrade the Helm release to use the secret.
helm upgrade my-langflow-app-image langflow/langflow-runtime -n langflow \
  --reuse-values \
  --set "extraEnv[0].name=OPENAI_API_KEY" \
  --set "extraEnv[0].valueFrom.secretKeyRef.name=openai-credentials" \
  --set "extraEnv[0].valueFrom.secretKeyRef.key=OPENAI_API_KEY"

Configure the log level

Set the log level and other Langflow configurations in the values.yaml file.

env:
  - name: LANGFLOW_LOG_LEVEL
    value: "INFO"

Configure scaling

To scale the number of replicas for the Langflow appplication, change the replicaCount value in the values.yaml file.

replicaCount: 3

To scale the application vertically by increasing the resources for the pods, change the resources values in the values.yaml file.

resources:
  requests:
    memory: "2Gi"
    cpu: "1000m"

Deploy Langflow on AWS EKS, Google GKE, or Azure AKS and other examples

For more information, see the Langflow Helm Charts repository.