diff --git a/docs/docs/Deployment/deployment-docker.md b/docs/docs/Deployment/deployment-docker.md index f867416e7..7bdf64203 100644 --- a/docs/docs/Deployment/deployment-docker.md +++ b/docs/docs/Deployment/deployment-docker.md @@ -128,7 +128,7 @@ docker build -t myuser/langflow-hello-world:1.0.0 . docker push myuser/langflow-hello-world:1.0.0 ``` -To deploy the image with Helm, see [Langflow runtime deployment](/deployment-kubernetes#deploy-the-langflow-runtime). +To deploy the image with Helm, see [Deploy the Langflow production environment on Kubernetes](/deployment-kubernetes-prod). ## Customize the Langflow Docker image with your own code diff --git a/docs/docs/Deployment/deployment-kubernetes-dev.md b/docs/docs/Deployment/deployment-kubernetes-dev.md new file mode 100644 index 000000000..07466f473 --- /dev/null +++ b/docs/docs/Deployment/deployment-kubernetes-dev.md @@ -0,0 +1,160 @@ +--- +title: Deploy the Langflow development environment on Kubernetes +slug: /deployment-kubernetes-dev +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +The [Langflow Integrated Development Environment (IDE)](https://github.com/langflow-ai/langflow-helm-charts/tree/main/charts/langflow-ide) Helm chart is designed to provide a complete environment for developers to create, test, and debug their flows. It includes both the API and the UI. + +### Prerequisites + +- A [Kubernetes](https://kubernetes.io/docs/setup/) cluster +- [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) +- [Helm](https://helm.sh/docs/intro/install/) + +### Prepare a Kubernetes cluster + +This example uses [Minikube](https://minikube.sigs.k8s.io/docs/start/), but you can use any Kubernetes cluster. + +1. Create a Kubernetes cluster on Minikube. + + ```shell + minikube start + ``` + +2. Set `kubectl` to use Minikube. + + ```shell + kubectl config use-context minikube + ``` + +### Install the Langflow IDE Helm chart + +1. Add the repository to Helm and update it. + + ```shell + 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. + + ```shell + helm install langflow-ide langflow/langflow-ide -n langflow --create-namespace + ``` + +3. Check the status of the pods. + + ```shell + kubectl get pods -n langflow + ``` + +### Access the Langflow IDE + +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: +```shell +kubectl port-forward -n langflow svc/langflow-service-backend 7860:7860 +``` + +2. To make the Langflow UI accessible from your local machine at port 8080: +```shell +kubectl port-forward -n langflow svc/langflow-service 8080:8080 +``` + +Now you can do the following: +- Access the Langflow API at `http://localhost:7860`. +- Access 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](https://github.com/langflow-ai/langflow-helm-charts/blob/main/charts/langflow-ide/values.yaml) file. + +```yaml +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: +```yaml +postgresql: + enabled: true + auth: + username: "langflow" + password: "langflow-postgres" + database: "langflow-db" +``` + +* Use an external database: +```yaml +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: + +```yaml +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 +``` + +:::note +If your flow relies on a shared state, such as built-in chat memory, you need to set up a shared database when scaling horizontally. +::: + +For more examples of `langflow-ide` deployment, see the [Langflow Helm Charts repository](https://github.com/langflow-ai/langflow-helm-charts/tree/main/examples/langflow-ide). diff --git a/docs/docs/Deployment/deployment-kubernetes.md b/docs/docs/Deployment/deployment-kubernetes-prod.md similarity index 55% rename from docs/docs/Deployment/deployment-kubernetes.md rename to docs/docs/Deployment/deployment-kubernetes-prod.md index a433eb163..58b8349a3 100644 --- a/docs/docs/Deployment/deployment-kubernetes.md +++ b/docs/docs/Deployment/deployment-kubernetes-prod.md @@ -1,188 +1,12 @@ --- -title: Deploy Langflow on Kubernetes -slug: /deployment-kubernetes +title: Deploy the Langflow production environment on Kubernetes +slug: /deployment-kubernetes-prod --- 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](https://github.com/langflow-ai/langflow-helm-charts): - -- Deploy the [Langflow IDE](#deploy-the-langflow-ide) for the complete Langflow development environment. -- Deploy the [Langflow runtime](#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](https://github.com/langflow-ai/langflow-helm-charts/tree/main/charts/langflow-ide). - -### Prerequisites - -- A [Kubernetes](https://kubernetes.io/docs/setup/) cluster -- [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) -- [Helm](https://helm.sh/docs/intro/install/) - -### Prepare a Kubernetes cluster - -This example uses [Minikube](https://minikube.sigs.k8s.io/docs/start/), but you can use any Kubernetes cluster. - -1. Create a Kubernetes cluster on Minikube. - - ```text - minikube start - ``` - -2. Set `kubectl` to use Minikube. - - ```text - kubectl config use-context minikube - ``` - -### Install the Langflow IDE Helm chart - -1. Add the repository to Helm and update it. - - ```text - 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. - - ```text - helm install langflow-ide langflow/langflow-ide -n langflow --create-namespace - ``` - -3. Check the status of the pods - - ```text - kubectl get pods -n langflow - ``` - - - ```text - 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: -```text -kubectl port-forward -n langflow svc/langflow-service-backend 7860:7860 -``` - -2. To make the Langflow UI accessible from your local machine at port 8080: -```text -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](https://github.com/langflow-ai/langflow-helm-charts/blob/main/charts/langflow-ide/values.yaml) file. - - -```yaml -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: -```yaml -postgresql: - enabled: true - auth: - username: "langflow" - password: "langflow-postgres" - database: "langflow-db" -``` - -* Use an external database: -```yaml -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: - -```yaml -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](https://github.com/langflow-ai/langflow-helm-charts/tree/main/charts/langflow-runtime). +The [Langflow Runtime](https://github.com/langflow-ai/langflow-helm-charts/blob/main/charts/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](https://github.com/langflow-ai/langflow-helm-charts/blob/main/charts/langflow-runtime/values.yaml#L46) 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. @@ -239,7 +63,7 @@ helm install my-langflow-app-with-flow langflow/langflow-runtime \ kubectl get pods -n langflow ``` -### Access the Langflow app API +### Access the Langflow runtime 1. Get your service name. ```shell @@ -353,7 +177,6 @@ replicaCount: 3 To scale the application vertically by increasing the resources for the pods, change the `resources` values in the [values.yaml](https://github.com/langflow-ai/langflow-helm-charts/blob/main/charts/langflow-runtime/values.yaml) file. - ```yaml resources: requests: @@ -361,8 +184,8 @@ resources: cpu: "1000m" ``` -## Deploy Langflow on AWS EKS, Google GKE, or Azure AKS and other examples - -For more information, see the [Langflow Helm Charts repository](https://github.com/langflow-ai/langflow-helm-charts). +For more information about deploying Langflow on AWS EKS, Google GKE, or Azure AKS, see the [Langflow Helm Charts repository](https://github.com/langflow-ai/langflow-helm-charts). + + diff --git a/docs/docs/Deployment/deployment-overview.md b/docs/docs/Deployment/deployment-overview.md index efadf9c32..28ea00d82 100644 --- a/docs/docs/Deployment/deployment-overview.md +++ b/docs/docs/Deployment/deployment-overview.md @@ -10,15 +10,18 @@ You have a flow, and want to share it with the world in a production environment This page outlines the journey from locally-run flow to a cloud-hosted production server. -More specific instructions are available in the [Docker](/deployment-docker) and [Kubernetes](/deployment-kubernetes) pages. +More specific instructions are available in the [Docker](/deployment-docker) and [Kubernetes](/deployment-kubernetes-dev) pages. ## Langflow deployment architecture -Langflow can be deployed as an [IDE](https://github.com/langflow-ai/langflow-helm-charts/tree/main/charts/langflow-ide) or as a [runtime](https://github.com/langflow-ai/langflow-helm-charts/tree/main/charts/langflow-runtime). +Langflow can be deployed in two distinct environments: -The **IDE** includes the frontend for visual development of your flow. The default [docker-compose.yml](https://github.com/langflow-ai/langflow/blob/main/docker_example/docker-compose.yml) file hosted in the Langflow repository builds the Langflow IDE image. To deploy the Langflow IDE, see [Docker](/deployment-docker). +* [Langflow IDE](/deployment-kubernetes-dev) - A development environment for creating and testing flows. +* [Langflow runtime](/deployment-kubernetes-prod) - A production environment for hosting and serving flows. -The **runtime** is a headless or backend-only mode. The server exposes your flow as an endpoint, and runs only the processes necessary to serve your flow, with PostgreSQL as the database for improved scalability. Use the Langflow **runtime** to deploy your flows, because you don't require the frontend for visual development. +The **Langflow IDE** includes the frontend for visual development of your flow. The default [docker-compose.yml](https://github.com/langflow-ai/langflow/blob/main/docker_example/docker-compose.yml) file hosted in the Langflow repository builds the Langflow IDE image. The Langflow IDE can be deployed on [Docker](/deployment-docker) or [Kubernetes](/deployment-kubernetes-dev). + +The **Langflow runtime** is a headless or backend-only mode. The server exposes your flow as an endpoint, and runs only the processes necessary to serve your flow, with PostgreSQL as the database for improved scalability. Use the Langflow **runtime** to deploy your flows if you don't require the frontend for visual development. The Langflow runtime can be deployed on [Docker](/deployment-docker) or [Kubernetes](/deployment-kubernetes-prod). :::tip You can start Langflow in headless mode with the [LANGFLOW_BACKEND_ONLY](/environment-variables#LANGFLOW_BACKEND_ONLY) environment variable. @@ -36,7 +39,10 @@ For more on building the Langflow docker image and pushing it to Docker Hub, see After your flow is packaged as a Docker image and available on Docker Hub, deploy your application by overriding the values in the [langflow-runtime](https://github.com/langflow-ai/langflow-helm-charts/blob/main/charts/langflow-runtime/Chart.yaml) Helm chart. -For more information, see [Deploy Langflow on Kubernetes](/deployment-kubernetes). +For more information, see [Deploy the Langflow development environment on Kubernetes](/deployment-kubernetes-dev). + + + diff --git a/docs/docs/Deployment/deployment-prod-best-practices.md b/docs/docs/Deployment/deployment-prod-best-practices.md new file mode 100644 index 000000000..3e9ab3764 --- /dev/null +++ b/docs/docs/Deployment/deployment-prod-best-practices.md @@ -0,0 +1,55 @@ +--- +title: Langflow architecture and best practices on Kubernetes +slug: /deployment-prod-best-practices +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +While Langflow offers flexible deployment options, deploying on a Kubernetes cluster is highly recommended for production environments. + +Deploying on Kubernetes offers the following advantages: + +* **Scalability**: Kubernetes allows you to scale the Langflow service to meet the demands of your workload. +* **Availability and resilience**: Kubernetes provides built-in resilience features, such as automatic failover and self-healing, to ensure that the Langflow service is always available. +* **Security**: Kubernetes provides security features, such as role-based access control and network isolation, to protect the Langflow service and its data. +* **Portability**: Kubernetes is a portable platform, which means that you can deploy the Langflow service to any Kubernetes cluster, on-premises or in the cloud. + +Langflow can be deployed on cloud deployments like **AWS EKS, Google GKE, or Azure AKS**. For more information about deploying Langflow on AWS EKS, Google GKE, or Azure AKS, see the [Langflow Helm charts repository](https://github.com/langflow-ai/langflow-helm-charts). + +## Langflow deployment + +A typical Langflow deployment includes: + +* **Langflow API and UI** – The Langflow service is the core component of the Langflow platform. It provides a RESTful API for executing flows. +* **Kubernetes cluster** – The Kubernetes cluster provides a platform for deploying and managing the Langflow service and its supporting components. +* **Persistent storage** – Persistent storage is used to store the Langflow service's data, such as models and training data. +* **Ingress controller** – The ingress controller provides a single entry point for traffic to the Langflow service. +* **Load balancer** – Balances traffic across multiple Langflow replicas. +* **Vector database** – If you are using Langflow for RAG, you can integrate with the vector database in Astra Serverless. + +![Langflow reference architecture on Kubernetes](/img/langflow-reference-architecture.png) + +## Environment isolation + +It is recommended to deploy and run two separate environments for Langflow, with one environment reserved for development use and another for production use. + + +![Langflow environments](/img/langflow-env.png) + +* **The Langflow development environment** must include the Integrated Development Environment (IDE) for the full experience of Langflow, optimized for prototyping and testing new flows. +* **The Langflow production environment** executes the flow logic in production and enables Langflow flows as standalone services. + +## Why is it important to have separate deployments? + +This separation is designed to enhance security, optimize resource allocation, and streamline management. + +* **Security** + * **Isolation**: By separating the development and production environments, you can better isolate different phases of the application lifecycle. This isolation minimizes the risk of development-related issues impacting the production environments. + * **Access control**: Different security policies and access controls can be applied to each environment. Developers may require broader access in the IDE for testing and debugging, while the runtime environment can be locked down with stricter security measures. + * **Reduced attack surface**: The runtime environment is configured to include only essential components, reducing the attack surface and potential vulnerabilities. +* **Resource allocation** + * **Optimized resource usage and cost efficiency**: By separating the two environments, you can allocate resources more effectively. Each flow can be deployed independently, providing fine-grained resource control. + * **Scalability**: The runtime environment can be scaled independently based on application load and performance requirements, without affecting the development environment. + + diff --git a/docs/docs/Develop/develop-application.md b/docs/docs/Develop/develop-application.md index 4d070792b..2babdceb5 100644 --- a/docs/docs/Develop/develop-application.md +++ b/docs/docs/Develop/develop-application.md @@ -162,4 +162,4 @@ The test application returns a large amount of text, so the example command used For instructions on building and pushing your image to Docker Hub, see [Docker](/deployment-docker). -To deploy your application to Kubernetes, see [Kubernetes](/deployment-kubernetes). \ No newline at end of file +To deploy your application to Kubernetes, see [Deploy the Langflow production environment to Kubernetes](/deployment-kubernetes-prod). \ No newline at end of file diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index d1c4db893..13c43c9c8 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -250,6 +250,12 @@ const config = { to: "/components-custom-components", from: "/components/custom", }, + { + to: "/deployment-kubernetes-dev", + from: [ + "/deployment-kubernetes", + ] + }, // add more redirects like this // { // to: '/docs/anotherpage', diff --git a/docs/sidebars.js b/docs/sidebars.js index d44e31905..1b824b726 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -112,9 +112,25 @@ module.exports = { label: "Docker" }, { - type: "doc", - id: "Deployment/deployment-kubernetes", - label: "Kubernetes" + type: "category", + label: "Kubernetes", + items: [ + { + type: "doc", + id: "Deployment/deployment-prod-best-practices", + label: "Langflow architecture and best practices" + }, + { + type: "doc", + id: "Deployment/deployment-kubernetes-dev", + label: "Deploy in development" + }, + { + type: "doc", + id: "Deployment/deployment-kubernetes-prod", + label: "Deploy in production" + } + ] }, { type: "doc", @@ -135,7 +151,7 @@ module.exports = { type: "doc", id: "Deployment/deployment-render", label: "Render" - } + }, ], }, { diff --git a/docs/static/img/langflow-env.png b/docs/static/img/langflow-env.png new file mode 100644 index 000000000..ac0929e85 Binary files /dev/null and b/docs/static/img/langflow-env.png differ diff --git a/docs/static/img/langflow-reference-architecture.png b/docs/static/img/langflow-reference-architecture.png new file mode 100644 index 000000000..701f3d2ca Binary files /dev/null and b/docs/static/img/langflow-reference-architecture.png differ