@@ -22,8 +22,8 @@ Copy [env.example](env.example) to `.env` and fill in values noted inside.
22
22
## Installing and connecting to Elasticsearch
23
23
24
24
There are a number of ways to install Elasticsearch. Cloud is best for most
25
- use-cases. We also have [ docker-compose-elastic.yml] ( ../../ docker) , that starts
26
- Elasticsearch, Kibana, and APM Server on your laptop with one command .
25
+ use-cases. We also have [ docker-compose-elastic.yml] [ docker-compose-elastic ] ,
26
+ that starts Elasticsearch, Kibana, and APM Server on your laptop in one step .
27
27
28
28
Once you decided your approach, edit your ` .env ` file accordingly.
29
29
@@ -71,6 +71,68 @@ Clean up when finished, like this:
71
71
docker compose down
72
72
```
73
73
74
+ ### Run with Kubernetes
75
+
76
+ Kubernetes is more complicated than Docker, but closer to the production
77
+ experience for many users. [ k8s-manifest.yml] ( k8s-manifest.yml ) creates the
78
+ same services, but needs additional configuration first.
79
+
80
+ First step is to setup your environment. [ env.example] ( env.example ) must be
81
+ copied to a file name ` .env ` and updated with ` ELASTICSEARCH_URL ` and
82
+ ` OTEL_EXPORTER_OTLP_ENDPOINT ` values visible to you Kubernetes deployment.
83
+
84
+ For example, if you started your Elastic Stack with [ k8s-manifest-elastic.yml] [ k8s-manifest-elastic ] ,
85
+ you would update these values:
86
+ ```
87
+ ELASTICSEARCH_URL=http://elasticsearch:9200
88
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://apm-server:8200
89
+ ```
90
+
91
+ Then, import your ` .env ` file as a configmap like this:
92
+ ``` bash
93
+ kubectl create configmap chatbot-rag-app-env --from-env-file=.env
94
+ ```
95
+
96
+ <details >
97
+ <summary >To use Vertex AI, set `LLM_TYPE=vertex` in your `.env` and follow these steps</summary >
98
+ The ` api-frontend container ` needs access to your Google Cloud credentials.
99
+ Share your ` application_default_credentials.json ` as a Kubernetes secret:
100
+ ``` bash
101
+ # Logs you into Google Cloud and creates application_default_credentials.json
102
+ gcloud auth application-default login
103
+ # Adds your credentials to a Kubernetes secret named gcloud-credentials
104
+ kubectl create secret generic gcloud-credentials \
105
+ --from-file=application_default_credentials.json=$HOME /.config/gcloud/application_default_credentials.json
106
+ ```
107
+ </details >
108
+
109
+ Now that your configuration is applied, create the ` chatbot-rag-app ` deployment
110
+ and service by applying this manifest:
111
+ ``` bash
112
+ kubectl apply -f k8s-manifest.yml
113
+ ```
114
+
115
+ Next, block until ` chatbot-rag-app ` is available.
116
+ ``` bash
117
+ kubectl wait --for=condition=available --timeout=20m deployment/chatbot-rag-app
118
+ ```
119
+
120
+ * Note* : The first run may take several minutes to become available. Here's how
121
+ to follow logs on this stage:
122
+ ``` bash
123
+ kubectl logs deployment.apps/chatbot-rag-app -c create-index -f
124
+ ```
125
+
126
+ Next, forward the web UI port:
127
+ ``` bash
128
+ kubectl port-forward deployment.apps/chatbot-rag-app 4000:4000 &
129
+ ```
130
+
131
+ Clean up when finished, like this:
132
+ ``` bash
133
+ kubectl delete -f k8s-manifest.yml
134
+ ```
135
+
74
136
### Run with Python
75
137
76
138
If you want to run this example with Python, you need to do a few things listed
@@ -196,3 +258,5 @@ docker compose up --build --force-recreate
196
258
---
197
259
[ loader-docs ] : https://python.langchain.com/docs/how_to/#document-loaders
198
260
[ install-es ] : https://www.elastic.co/search-labs/tutorials/install-elasticsearch
261
+ [ docker-compose-elastic ] : ../../docker/docker-compose-elastic.yml
262
+ [ k8s-manifest-elastic ] : ../../k8s/k8s-manifest-elastic.yml
0 commit comments