-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chatbot-rag-app: adds Kubernetes manifest and instructions (#396)
Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
- Loading branch information
1 parent
21cfcc6
commit 72835b0
Showing
8 changed files
with
408 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
# chatbot-rag-app deploys "create-index" to install ELSER and load values. | ||
# Then, it starts "api-frontend" to serve the application. | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: chatbot-rag-app | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: chatbot-rag-app | ||
template: | ||
metadata: | ||
labels: | ||
app: chatbot-rag-app | ||
spec: | ||
# For `LLM_TYPE=vertex`: create a volume for application_default_credentials.json | ||
volumes: | ||
- name: gcloud-credentials | ||
secret: | ||
secretName: gcloud-credentials | ||
optional: true # only read when `LLM_TYPE=vertex` | ||
initContainers: | ||
- name: create-index | ||
image: &image ghcr.io/elastic/elasticsearch-labs/chatbot-rag-app:latest | ||
command: &command [ "bash", "-eu", "./entrypoint.sh" ] # match image | ||
args: [ "flask", "create-index" ] | ||
# This recreates your configmap based on your .env file: | ||
# kubectl create configmap chatbot-rag-app-env --from-env-file=.env | ||
envFrom: &envFrom | ||
- configMapRef: | ||
name: chatbot-rag-app-env | ||
containers: | ||
- name: api-frontend | ||
image: *image | ||
command: *command | ||
args: [ "python", "api/app.py" ] | ||
ports: | ||
- containerPort: 4000 | ||
envFrom: *envFrom | ||
# For `LLM_TYPE=vertex`: mount credentials to the path read by the google-cloud-sdk | ||
volumeMounts: | ||
- name: gcloud-credentials | ||
mountPath: /root/.config/gcloud | ||
readOnly: true | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: api | ||
spec: | ||
selector: | ||
app: chatbot-rag-app | ||
ports: | ||
- protocol: TCP | ||
port: 4000 | ||
targetPort: 4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Running your own Elastic Stack with Kubernetes | ||
|
||
If you'd like to start Elastic with Kubernetes, you can use the provided | ||
[manifest-elastic.yml](manifest-elastic.yml) file. This starts | ||
Elasticsearch, Kibana, and APM Server in an existing Kubernetes cluster. | ||
|
||
Note: If you haven't checked out this repository, all you need is one file: | ||
```bash | ||
wget https://raw.githubusercontent.com/elastic/elasticsearch-labs/refs/heads/main/k8s/k8s-manifest-elastic.yml | ||
``` | ||
|
||
Before you begin, ensure you have free CPU and memory in your cluster. If you | ||
plan to use ELSER, assume a minimum of 8 cpus and 6GB memory for the containers | ||
in this manifest. | ||
|
||
First, start this Elastic Stack in the background: | ||
```bash | ||
kubectl apply -f k8s-manifest-elastic.yml | ||
``` | ||
|
||
**Note**: For simplicity, this adds an Elastic Stack to the default namespace. | ||
Commands after here are simpler due to this. If you want to choose a different | ||
one, use `kubectl`'s `--namespace` flag! | ||
|
||
Next, block until the whole stack is available. First install or changing the | ||
Elastic Stack version can take a long time due to image pulling. | ||
```bash | ||
kubectl wait --for=condition=available --timeout=10m \ | ||
deployment/elasticsearch \ | ||
deployment/kibana \ | ||
deployment/apm-server | ||
``` | ||
|
||
Next, forward the kibana port: | ||
```bash | ||
kubectl port-forward service/kibana 5601:5601 & | ||
``` | ||
|
||
Finally, you can view Kibana at http://localhost:5601/app/home#/ | ||
|
||
If asked for a username and password, use username: elastic and password: elastic. | ||
|
||
Clean up when finished, like this: | ||
|
||
```bash | ||
kubectl delete -f k8s-manifest-elastic.yml | ||
``` |
Oops, something went wrong.