From f5c7fafd1bbea8f64663283e5131d8334fe4aec5 Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Tue, 16 Jul 2024 15:59:23 +0800 Subject: [PATCH] Add helm test for chart tei - Added helm test for chart tei - Update the chart README Signed-off-by: Lianhao Lu --- helm-charts/common/tei/README.md | 34 +++++++++++++------ helm-charts/common/tei/templates/NOTES.txt | 19 ----------- .../common/tei/templates/tests/test-pod.yaml | 25 ++++++++++++++ 3 files changed, 48 insertions(+), 30 deletions(-) delete mode 100644 helm-charts/common/tei/templates/NOTES.txt create mode 100644 helm-charts/common/tei/templates/tests/test-pod.yaml diff --git a/helm-charts/common/tei/README.md b/helm-charts/common/tei/README.md index 83a8d616..a218a9af 100644 --- a/helm-charts/common/tei/README.md +++ b/helm-charts/common/tei/README.md @@ -7,25 +7,37 @@ Helm chart for deploying Hugging Face Text Generation Inference service. To install the chart, run the following: ```console -$ cd ${GenAIInfro_repo}/helm-charts/common -$ export MODELDIR=/mnt/model -$ export MODELNAME="BAAI/bge-base-en-v1.5" -$ helm install tei tei --set global.modelUseHostPath=${MODELDIR} --set EMBEDDING_MODEL_ID=${MODELNAME} +cd ${GenAIInfro_repo}/helm-charts/common +export MODELDIR=/mnt/opea-models +export MODELNAME="BAAI/bge-base-en-v1.5" +helm install tei tei --set global.modelUseHostPath=${MODELDIR} --set EMBEDDING_MODEL_ID=${MODELNAME} ``` By default, the tei service will downloading the "BAAI/bge-base-en-v1.5" which is about 1.1GB. If you already cached the model locally, you can pass it to container like this example: -MODELDIR=/mnt/model +MODELDIR=/mnt/opea-models MODELNAME="/data/BAAI/bge-base-en-v1.5" +## Verify + +To verify the installation, run the command `kubectl get pod` to make sure all pods are runinng. + +Then run the command `kubectl port-forward svc/tei 2081:80` to expose the tei service for access. + +Open another terminal and run the following command to verify the service if working: + +```console +curl http://localhost:2081/embed -X POST -d '{"inputs":"What is Deep Learning?"}' -H 'Content-Type: application/json' +``` + ## Values -| Key | Type | Default | Description | -| ----------------------- | ------ | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| EMBEDDING_MODEL_ID | string | `"BAAI/bge-base-en-v1.5"` | Models id from https://huggingface.co/, or predownloaded model directory | -| global.modelUseHostPath | string | `"/mnt"` | Cached models directory, tei will not download if the model is cached here. The host path "modelUseHostPath" will be mounted to container as /data directory | -| image.repository | string | `"ghcr.io/huggingface/text-embeddings-inference"` | | -| image.tag | string | `"cpu-1.2"` | | +| Key | Type | Default | Description | +| ----------------------- | ------ | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| EMBEDDING_MODEL_ID | string | `"BAAI/bge-base-en-v1.5"` | Models id from https://huggingface.co/, or predownloaded model directory | +| global.modelUseHostPath | string | `"/mnt/opea-models"` | Cached models directory, tei will not download if the model is cached here. The host path "modelUseHostPath" will be mounted to container as /data directory. Set this to null/empty will force it to download model. | +| image.repository | string | `"ghcr.io/huggingface/text-embeddings-inference"` | | +| image.tag | string | `"cpu-1.2"` | | diff --git a/helm-charts/common/tei/templates/NOTES.txt b/helm-charts/common/tei/templates/NOTES.txt deleted file mode 100644 index fd02755e..00000000 --- a/helm-charts/common/tei/templates/NOTES.txt +++ /dev/null @@ -1,19 +0,0 @@ -1. Get the application IP or 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 "tei.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 "tei.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "tei.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export tei_svc_ip=$(kubectl get svc --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "tei.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].spec.clusterIP}") && echo ${tei_svc_ip} -{{- end }} - -2. Use this command to verify tei service: - curl http://${tei_svc_ip}/embed \ - -X POST \ - -d '{"inputs":"What is Deep Learning?"}' \ - -H 'Content-Type: application/json' diff --git a/helm-charts/common/tei/templates/tests/test-pod.yaml b/helm-charts/common/tei/templates/tests/test-pod.yaml new file mode 100644 index 00000000..185c2d36 --- /dev/null +++ b/helm-charts/common/tei/templates/tests/test-pod.yaml @@ -0,0 +1,25 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "tei.fullname" . }}-testpod" + labels: + {{- include "tei.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: + - | + curl http://{{ include "tei.fullname" . }}/embed -sS --fail-with-body \ + -X POST \ + -d '{"inputs":"What is Deep Learning?"}' \ + -H 'Content-Type: application/json' + restartPolicy: Never