|
| 1 | +# Deployment of Wren AI to Kubernetes with Helm Chart |
| 2 | +1. Ensure you satisfy the dependencies required to deploy Wren AI. |
| 3 | +2. Adjust the values accordingly to fit your Kubernetes environment. |
| 4 | +3. Secrets vales can be deployed together or separately. |
| 5 | +Note: Without authentication, once you publish this on the internet, anyone can access your app, see your data, and modify your settings! |
| 6 | + |
| 7 | +## Dependencies used in this kustomization: |
| 8 | +- nginx.ingress |
| 9 | +- external-dns |
| 10 | +- cert-manager |
| 11 | +- kubectl |
| 12 | +- helm |
| 13 | + |
| 14 | +## Steps to deploy: |
| 15 | + |
| 16 | +`Suggestion`: Before deploying, check out the Helm values in the `deployment/helm ` file and modify them to suit your Kubernetes environment. |
| 17 | + |
| 18 | +The `deployment/helm` folder contains a `values.yaml` file that will inflate the manifests into a `deployment/helm/template` files used to deploy the app to your Kubernetes cluster. |
| 19 | + |
| 20 | +```shell |
| 21 | +# Clone the repository with Helm chart |
| 22 | +git clone https://github.com/Canner/WrenAI.git |
| 23 | +cd WrenAI |
| 24 | + |
| 25 | +# Create namespace |
| 26 | +kubectl create namespace wren |
| 27 | + |
| 28 | +# !!!!!!!!!!!! |
| 29 | +# OPENAI_API_KEY or GEMINI_API_KEY is REQUIRED: without a valid key the wren-ai-service pod will not start |
| 30 | +# You must update PG_URL, otherwise wren-ui will not work |
| 31 | + |
| 32 | +# MODIFY/GENERATE values of secret and apply kubectl command to create secret (recommended for production) |
| 33 | + |
| 34 | +# Generate secure passwords |
| 35 | +OPENAI_API_KEY=UkVRVUlSRUQ6IHNrLXByb2otYWxsLWFjY2Vzcy1wbGFjZWhvbGRlci00LXdyZW4tYWktc2VydmljZS1kZXBsb3ltZW50 |
| 36 | +PG_USERNAME=wrenai |
| 37 | +PG_PASSWORD=$(openssl rand -base64 32) |
| 38 | +PG_ADMIN_PASSWORD=$(openssl rand -base64 32) |
| 39 | +PG_URL=postgres://wrenai-user:wrenai-pass@wren-postgresql:5432/wrenai |
| 40 | +LANGFUSE_PUBLIC_KEY=VUlSYWxsLWFjRUQ6IHNrLtdmljZS1kZXBYWxsLWFktc2VydmljZS13ltZW50 |
| 41 | +LANGFUSE_SECRET_KEY=UQ6IHNrLsLWFjtYWxsLWFdmljZS1kZXBktVUlSRUQ6IHNrLXByHNYWxsLWFj |
| 42 | +POSTHOG_API_KEY=YWxsLWZS1kZXBYWxsLWFkHNrLXByb2oYWxsLWFjtc2VydmljZS1kZXHNrLXByb2o |
| 43 | +USER_UUID=$(openssl rand -base64 32) |
| 44 | + |
| 45 | +kubectl create secret generic wrenai-secrets \ |
| 46 | + --from-literal=OPENAI_API_KEY=$OPENAI_API_KEY \ |
| 47 | + --from-literal=PG_USERNAME=$PG_USERNAME \ |
| 48 | + --from-literal=PG_PASSWORD=$PG_PASSWORD \ |
| 49 | + --from-literal=PG_ADMIN_PASSWORD=$PG_ADMIN_PASSWORD \ |
| 50 | + --from-literal=PG_URL=$PG_URL \ |
| 51 | + --from-literal=LANGFUSE_PUBLIC_KEY=$LANGFUSE_PUBLIC_KEY \ |
| 52 | + --from-literal=LANGFUSE_SECRET_KEY=$LANGFUSE_SECRET_KEY \ |
| 53 | + --from-literal=POSTHOG_API_KEY=$POSTHOG_API_KEY \ |
| 54 | + --from-literal=USER_UUID=$USER_UUID \ |
| 55 | + -n wren |
| 56 | + |
| 57 | + |
| 58 | +# Download Wren AI dependency charts like Qdrant or postgresql |
| 59 | +helm dependency build ./deployment/helm |
| 60 | + |
| 61 | +# Deploy Wren AI with Helm |
| 62 | +helm upgrade --install wrenai ./deployment/helm \ |
| 63 | + --namespace wren \ |
| 64 | + -f deployment/helm/values.yaml \ |
| 65 | + |
| 66 | +kubectl get pods -n wren |
| 67 | +``` |
| 68 | + |
| 69 | +### Notes on Helm: |
| 70 | +- `deployment/helm/values.yaml` is the main file responsible for versions of other apps such as Qdrant and PostgreSQL, version of your Wren AI app. It also combines resourses from the manifest such as ConfigMaps, Deployments, and Services. And example Ingress and Secrets. |
| 71 | +- `deployment/helm/template` is the manifests folder that contains the core Wren AI manifest templates, its less likely you need to modify them, but check just in case |
| 72 | +- `deployment/helm/charts` is directory contains any dependent Helm charts (subcharts) required by Wren AI, such as PostgreSQL or Qdrant. These dependencies are either added manually or using `helm dependency add`, and they are used to deploy third-party services alongside Wren AI. |
| 73 | +- `deployment/helm/Chart.yaml` This file defines the metadata for the Helm chart used to deploy Wren AI. It includes the chart name, version, application version, dependencies and a description. Helm uses this file to identify and manage the chart during installation and upgrades. |
| 74 | + |
| 75 | +#### Wren-UI Database |
| 76 | +Starting with wren-ui version 0.6.0 by default the postgres database is used for wren-ui in this helm chart and will be installed in the same namespace as wren-ai. |
| 77 | +- `postgres`: Database that will be installed in the same namespace as wren-ai. You *must* update `PG_URL` in the Secret manifest. |
| 78 | + |
| 79 | +Example: `PG_URL: "postgres://wrenai-user:wrenai-pass@wren-postgresql:5432/wrenai"` |
| 80 | +- `postgres://` This is the protocol. It tells the system that you’re connecting to a PostgreSQL database. |
| 81 | +- `wrenai-user:wrenai-pass` These are the username(first) and password(second) for the database respectively, separated by a colon. In this case, both the username and password are “postgres”. |
| 82 | +- `@wren-postgresql` This is the hostname of the database server. "wren-postgresql" means the database server is running in a Kubernetes cluster and it is named "wren-postgresql" in the *same* namespace. If you are using another namespace you must provide the full hostname, example: `wren-postgresql.wrenai.svc.cluster.local`, "wrenai" is the namespace name, "svc.cluster.local" is the default domain name for Kubernetes services no need to change it. |
| 83 | +- `:5432` This is the port number. PostgreSQL servers listen on port 5432 by default. |
| 84 | +- `/wrenai` This is the name of the database you’re connecting to. In this case, the database name is `wrenai`. It can be found in the helm values file in the auth.database parameter. |
| 85 | + |
| 86 | +# Minikube |
| 87 | +Prepare your k8s environment. Then use the `Steps to deploy` section to deploy Wren AI app into your k8s. |
| 88 | +```shell |
| 89 | +minikube start |
| 90 | +minikube addons enable ingress |
| 91 | +minikube addons enable metallb |
| 92 | +minikube kubectl -- get nodes |
| 93 | +minikube kubectl -- get pods -A |
| 94 | + |
| 95 | +minikube update-context |
| 96 | +helm repo add bitnami https://charts.bitnami.com/bitnami |
| 97 | +helm repo update |
| 98 | +helm install external-dns bitnami/external-dns |
| 99 | +helm install \ |
| 100 | + external-dns bitnami/external-dns \ |
| 101 | + --namespace external-dns \ |
| 102 | + --version 7.5.2 \ |
| 103 | + --create-namespace \ |
| 104 | + --set installCRDs=true |
| 105 | +kubectl get pods -n external-dns |
| 106 | + |
| 107 | +helm repo add jetstack https://charts.jetstack.io |
| 108 | +helm repo update |
| 109 | +helm install \ |
| 110 | + cert-manager jetstack/cert-manager \ |
| 111 | + --namespace cert-manager \ |
| 112 | + --version v1.13.6 \ |
| 113 | + --create-namespace \ |
| 114 | + --set installCRDs=true |
| 115 | +kubectl get pods -n cert-manager |
| 116 | + |
| 117 | +########## |
| 118 | +# Use the `Steps to deploy` section to continue as you would on a production k8s cluster. |
| 119 | +``` |
| 120 | + |
| 121 | +# GitOps Patches |
| 122 | +In the [patches](./patches) folder you can find usefull kustomization examples files if you wish to use existing official kustomization directly from this repo as a base kustomization layer and only customize some values. It can be usefull for you GitOps workflow and can be used in conjunction with FluxCD or ArgoCD. |
0 commit comments