Skip to main content

Deploy the Langflow production environment on Kubernetes

The Langflow 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.

important

By default, the Langflow runtime Helm chart enables readOnlyRootFilesystem: true as a security best practice. This setting prevents modifications to the container's root filesystem at runtime, which is a recommended security measure in production environments.

Disabling readOnlyRootFilesystem reduces the security of your deployment. Only disable this setting if you understand the security implications and have implemented other security measures.

For more information, see the Kubernetes documentation.

Prerequisites

Install the Langflow runtime Helm chart

  1. Add the repository to Helm.

_10
helm repo add langflow https://langflow-ai.github.io/langflow-helm-charts
_10
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:

_10
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:

_10
helm install my-langflow-app-with-flow langflow/langflow-runtime \
_10
-n langflow \
_10
--create-namespace \
_10
--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:


_10
helm install my-langflow-app-with-flow langflow/langflow-runtime \
_10
-n langflow \
_10
--create-namespace \
_10
--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.

_10
kubectl get pods -n langflow

Access the Langflow runtime

  1. Get your service name.

_10
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:

_10
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.

_10
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.


_12
# Get flow ID
_12
id=$(curl -s "http://localhost:7860/api/v1/flows/" | jq -r '.[0].id')
_12
_12
# Run flow
_12
curl -X POST \
_12
"http://localhost:7860/api/v1/run/$id?stream=false" \
_12
-H 'Content-Type: application/json' \
_12
-d '{
_12
"input_value": "Hello!",
_12
"output_type": "chat",
_12
"input_type": "chat"
_12
}'

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:


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

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


_10
env:
_10
- name: openai_key_var
_10
value: "sk-...."

Configure the log level

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


_10
env:
_10
- name: LANGFLOW_LOG_LEVEL
_10
value: "INFO"

Configure scaling

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


_10
replicaCount: 3

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


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

For more information about deploying Langflow on AWS EKS, Google GKE, or Azure AKS, see the Langflow Helm Charts repository.

Search