Skip to content

Commit

Permalink
Add helm test for chart retriever-usvc
Browse files Browse the repository at this point in the history
- Add helm test for chart

- Update the chart README

- Add flag autodependency.enabled=true to automatically install dependency charts

Signed-off-by: Lianhao Lu <[email protected]>
  • Loading branch information
lianhao authored and leslieluyu committed Jul 18, 2024
1 parent 3972089 commit 6db408a
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 19 deletions.
9 changes: 9 additions & 0 deletions helm-charts/common/retriever-usvc/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ type: application
version: 0.8.0
# The retriever microservice server version
appVersion: "1.0.0"
dependencies:
- name: tei
version: 0.8.0
repository: file://../tei
condition: autodependency.enabled
- name: redis-vector-db
version: 0.8.0
repository: file://../redis-vector-db
condition: autodependency.enabled
36 changes: 33 additions & 3 deletions helm-charts/common/retriever-usvc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,44 @@ Helm chart for deploying Retriever microservice.

retriever-usvc depends on redis and tei, you should set these endpoints before start.

## Installing the Chart
## (Option1): Installing the chart separately:

To install the chart, run the following:
First, you need to install the tei and redis-vector-db chart, please refer to the [tei](../tei) and [redis-vector-db](../redis-vector-db) for more information.

After you've deployted the tei and redis-vector-db chart successfully, please run `kubectl get svc` to get the service endpoint and URL respectively, i.e. `http://tei`, `redis://redis-vector-db:6379`.

To install retriever-usvc chart, run the following:

```console
cd GenAIInfra/helm-charts/common/retriever-usvc
export REDIS_URL="redis://redis-vector-db:6379"
export TEI_EMBEDDING_ENDPOINT="http://tei"
helm install retriever retriever-usvc --set REDIS_URL=${REDIS_URL} --set TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT}
helm dependency update
helm install retriever-usvc . --set REDIS_URL=${REDIS_URL} --set TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT}
```

## (Option2): Installing the chart with dependencies automatically:

```console
cd GenAIInfra/helm-charts/common/retriever-usvc
helm dependency update
helm install retriever-usvc . --set autodependency.enabled=true
```

## Verify

To verify the installation, run the command `kubectl get pod` to make sure all pods are running.

Then run the command `kubectl port-forward svc/retriever-usvc 7000:7000` to expose the retriever-usvc service for access.

Open another terminal and run the following command to verify the service if working:

```console
export your_embedding=$(python3 -c "import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)")
curl http://localhost:7000/v1/retrieval \
-X POST \
-d "{\"text\":\"What is the revenue of Nike in 2023?\",\"embedding\":${your_embedding}}" \
-H 'Content-Type: application/json'
```

## Values
Expand Down
16 changes: 0 additions & 16 deletions helm-charts/common/retriever-usvc/templates/NOTES.txt

This file was deleted.

26 changes: 26 additions & 0 deletions helm-charts/common/retriever-usvc/templates/tests/test-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: Pod
metadata:
name: "{{ include "retriever-usvc.fullname" . }}-testpod"
labels:
{{- include "retriever-usvc.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
#"helm.sh/hook-delete-policy": "hook-succeeded, hook-failure"
spec:
containers:
- name: curl
#image: alpine/curl
image: python:3.10.14
command: ['sh', '-c']
args:
- |
your_embedding=$(python3 -c "import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)");
curl http://{{ include "retriever-usvc.fullname" . }}:{{ .Values.service.port }}/v1/retrieval -sS --fail-with-body \
-X POST \
-d "{\"text\":\"What is the revenue of Nike in 2023?\",\"embedding\":${your_embedding}}" \
-H 'Content-Type: application/json'
restartPolicy: Never
3 changes: 3 additions & 0 deletions helm-charts/common/retriever-usvc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

autodependency:
enabled: false

replicaCount: 1

TEI_EMBEDDING_ENDPOINT: ""
Expand Down

0 comments on commit 6db408a

Please sign in to comment.