diff --git a/helm-charts/common/retriever-usvc/Chart.yaml b/helm-charts/common/retriever-usvc/Chart.yaml index 170db3fc..8a3cd7d9 100644 --- a/helm-charts/common/retriever-usvc/Chart.yaml +++ b/helm-charts/common/retriever-usvc/Chart.yaml @@ -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 diff --git a/helm-charts/common/retriever-usvc/README.md b/helm-charts/common/retriever-usvc/README.md index b1c85360..79672982 100644 --- a/helm-charts/common/retriever-usvc/README.md +++ b/helm-charts/common/retriever-usvc/README.md @@ -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 diff --git a/helm-charts/common/retriever-usvc/templates/NOTES.txt b/helm-charts/common/retriever-usvc/templates/NOTES.txt deleted file mode 100644 index eff01dd1..00000000 --- a/helm-charts/common/retriever-usvc/templates/NOTES.txt +++ /dev/null @@ -1,16 +0,0 @@ -1. Get the application URL by running these commands: -{{- if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "retriever-usvc.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "retriever-usvc.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "retriever-usvc.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "retriever-usvc.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/helm-charts/common/retriever-usvc/templates/tests/test-pod.yaml b/helm-charts/common/retriever-usvc/templates/tests/test-pod.yaml new file mode 100644 index 00000000..264f1415 --- /dev/null +++ b/helm-charts/common/retriever-usvc/templates/tests/test-pod.yaml @@ -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 diff --git a/helm-charts/common/retriever-usvc/values.yaml b/helm-charts/common/retriever-usvc/values.yaml index 58d88de1..380f658d 100644 --- a/helm-charts/common/retriever-usvc/values.yaml +++ b/helm-charts/common/retriever-usvc/values.yaml @@ -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: ""