-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chatbot-rag-app: adds Kubernetes manifest and instructions #396
Draft
codefromthecrypt
wants to merge
3
commits into
main
Choose a base branch
from
k8s-chatbot-rag-app
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+376
−8
Draft
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
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: | ||
# The below will recreate your secret based on the gcloud credentials file | ||
# kubectl create secret generic gcloud-credentials \ | ||
# --from-file=application_default_credentials.json=$HOME/.config/gcloud/application_default_credentials.json | ||
volumes: | ||
- name: gcloud-credentials | ||
secret: | ||
secretName: gcloud-credentials | ||
initContainers: | ||
- name: create-index | ||
image: &image ghcr.io/elastic/elasticsearch-labs/chatbot-rag-app:latest | ||
args: ["flask", "create-index"] | ||
env: | ||
- name: FLASK_APP | ||
value: api/app.py | ||
# 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 | ||
volumeMounts: &volumeMounts | ||
- name: gcloud-credentials | ||
mountPath: /root/.config/application_default_credentials.json | ||
readOnly: true | ||
containers: | ||
- name: api-frontend | ||
image: *image | ||
ports: | ||
- containerPort: 4000 | ||
envFrom: *envFrom | ||
volumeMounts: *volumeMounts | ||
--- | ||
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/docker/docker-compose-elastic.yml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think this is wrong file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep |
||
``` | ||
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find the GCP-specific instructions in the readme and manifest to be sort of jarring and one point is this is mostly for running locally, while in a cluster the pod should use service account auth provided by the cluster. Similar can be said about using static AWS credentials via env.
"Note for cloud provided backends such as Vertex AI and Bedrock, the pod will need to be authenticated with access to them. This is usually with service account authentication in running clusters, while if testing locally can be with AWS static credentials passed by environment variables or copying a GCP credentials file into a secret mounted as a volume."
Not sure if this is too much information though but I think it would be good if this yaml could avoid the gcloud-specific parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, I also was troubled by it. better to leave this out as it is arduous and creates FUD.