Skip to content
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

Adapt latest changes for retriever #711

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions helm-charts/common/retriever-usvc/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
# retriever-usvc

Helm chart for deploying Retriever microservice.
Helm chart for deploying OPEA retriever-usvc microservice.

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

## (Option1): Installing the chart separately
`retriever-usvc` will use TEI for embedding service, and support different vector DB backends.

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

After you've deployed the tei and redis-vector-db chart successfully, run `kubectl get svc` to get the service endpoint and URL respectively, i.e. `http://tei`, `redis://redis-vector-db:6379`.
- Redis vector DB: please refer to [redis-vector-db](../redis-vector-db/) for more information.

To install retriever-usvc chart, run the following:
- Milvus DB: please refer to [milvus-helm](https://github.com/zilliztech/milvus-helm/tree/milvus-4.2.12) for more information.

```console
cd GenAIInfra/helm-charts/common/retriever-usvc
export REDIS_URL="redis://redis-vector-db:6379"
export TEI_EMBEDDING_ENDPOINT="http://tei"
helm dependency update
helm install retriever-usvc . --set REDIS_URL=${REDIS_URL} --set TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT}
```
First, you need to install the `tei` helm chart and one of the vector DB service, i.e. `redis-vector-db` chart.

## (Option2): Installing the chart with dependencies automatically
After you've deployed dependency charts successfully, please run `kubectl get svc` to get the service endpoint URL respectively, i.e. `http://tei:80`, `redis://redis-vector-db:6379`.

To install `retriever-usvc` chart, run the following:

```console
cd GenAIInfra/helm-charts/common/retriever-usvc
helm dependency update
helm install retriever-usvc . --set tei.enabled=true --set redis-vector-db.enabled=true
export HFTOKEN="insert-your-huggingface-token-here"
export TEI_EMBEDDING_ENDPOINT="http://tei"

# Install retriever-usvc with Redis DB backend
export RETRIEVER_BACKEND="REDIS"
export DB_HOST="redis-vector-db"
helm install retriever-usvc . --set TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT} --set global.HUGGINGFACEHUB_API_TOKEN=${HF_TOKEN} --set RETRIEVER_BACKEND=${RETRIEVER_BACKEND} --set REDIS_HOST=${DB_HOST}

# Install retriever-usvc with Milvus DB backend
# export RETRIEVER_BACKEND="MILVUS"
# export DB_HOST="milvus"
# helm install retriever-usvc . --set TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT} --set global.HUGGINGFACEHUB_API_TOKEN=${HF_TOKEN} --set RETRIEVER_BACKEND=${RETRIEVER_BACKEND} --set MILVUS_HOST=${DB_HOST}
```

## Verify
Expand All @@ -46,14 +53,16 @@ curl http://localhost:7000/v1/retrieval \

## Values

| Key | Type | Default | Description |
| ---------------------- | ------ | ---------------------- | ----------- |
| image.repository | string | `"opea/retriever-tgi"` | |
| service.port | string | `"7000"` | |
| REDIS_URL | string | `""` | |
| TEI_EMBEDDING_ENDPOINT | string | `""` | |
| global.monitoring | bool | `false` | |
| Key | Type | Default | Description |
| ------------------------------- | ------ | --------- | ------------------------------------------------------------------------------------------------------- |
| global.HUGGINGFACEHUB_API_TOKEN | string | `""` | Your own Hugging Face API token |
| service.port | string | `"7000"` | |
| RETRIEVER_BACKEND | string | `"REDIS"` | vector DB backend to use, one of "REDIS", "MILVUS" |
| REDIS_HOST | string | `""` | Redis service URL host, only valid for Redis, please see `values.yaml` for other Redis configuration |
| MILVUS_HOST | string | `""` | Milvus service URL host, only valid for Milvus, please see `values.yaml` for other Milvus configuration |
| TEI_EMBEDDING_ENDPOINT | string | `""` | |
| global.monitoring | bool | `false` | |

## Milvus support

Refer to the milvus-values.yaml for milvus configurations.
Refer to the milvus-values.yaml for Milvus configurations.
27 changes: 14 additions & 13 deletions helm-charts/common/retriever-usvc/milvus-values.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

# Default values for retriever-usvc.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

milvus:
enabled: true
# Milvus config for standalone mode with no PVC which has minimum requirements for the K8s cluster.
# Check https://github.com/zilliztech/milvus-helm/tree/milvus-4.2.12/charts/milvus for more production level configuration.
cluster:
enabled: false
etcd:
replicaCount: 1
persistence:
enabled: false
pulsar:
enabled: false
minio:
mode: standalone
persistence:
enabled: false
standalone:
persistence:
enabled: false
redis-vector-db:
enabled: false
enabled: false
tei:
enabled: true

image:
repository: opea/retriever-milvus
port: 7000
RETRIEVER_BACKEND: "MILVUS"
# text embedding inference service URL, e.g. http://<service-name>:<port>
#TEI_EMBEDDING_ENDPOINT: "http://dataprep-tei:80"
#TEI_EMBEDDING_ENDPOINT: "http://retriever-tei:80"
# milvus DB configurations
#MILVUS_HOST: "dataprep-milvus"
MILVUS_PORT: "19530"
#MILVUS_HOST: "retriever-milvus"
MILVUS_PORT: 19530
COLLECTION_NAME: "rag_milvus"
MOSEC_EMBEDDING_ENDPOINT: ""
MOSEC_EMBEDDING_MODEL: ""
42 changes: 24 additions & 18 deletions helm-charts/common/retriever-usvc/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,47 @@ metadata:
labels:
{{- include "retriever-usvc.labels" . | nindent 4 }}
data:
{{- if .Values.MOSEC_EMBEDDING_ENDPOINT }}
MOSEC_EMBEDDING_ENDPOINT: {{ .Values.MOSEC_EMBEDDING_ENDPOINT | quote}}
MOSEC_EMBEDDING_MODEL: {{ .Values.MOSEC_EMBEDDING_MODEL | quote}}
{{- else if .Values.TEI_EMBEDDING_ENDPOINT }}
TEI_EMBEDDING_ENDPOINT: {{ .Values.TEI_EMBEDDING_ENDPOINT | quote }}
{{- if .Values.TEI_EMBEDDING_ENDPOINT }}
TEI_EMBEDDING_ENDPOINT: {{ tpl .Values.TEI_EMBEDDING_ENDPOINT . | quote }}
{{- else if not .Values.LOCAL_EMBEDDING_MODEL }}
TEI_EMBEDDING_ENDPOINT: "http://{{ .Release.Name }}-tei"
{{- end }}
{{- if .Values.LOCAL_EMBEDDING_MODEL }}
EMBED_MODEL: {{ .Values.LOCAL_EMBEDDING_MODEL | quote }}
LOCAL_EMBEDDING_MODEL: {{ .Values.LOCAL_EMBEDDING_MODEL | quote }}
{{- end }}
{{- if .Values.REDIS_URL }}
REDIS_URL: {{ .Values.REDIS_URL | quote}}
{{- if eq "REDIS" .Values.RETRIEVER_BACKEND }}
RETRIEVER_COMPONENT_NAME: "OPEA_RETRIEVER_REDIS"
{{- if .Values.REDIS_HOST }}
REDIS_HOST: {{ tpl .Values.REDIS_HOST . | quote}}
{{- else }}
REDIS_URL: "redis://{{ .Release.Name }}-redis-vector-db:6379"
REDIS_HOST: "{{ .Release.Name }}-redis-vector-db"
{{- end }}
REDIS_PORT: {{ .Values.REDIS_PORT | quote }}
REDIS_SSL: {{ .Values.REDIS_SSL | quote }}
REDIS_PASSWORD: {{ .Values.REDIS_PASSWORD | quote }}
REDIS_USERNAME: {{ .Values.REDIS_USERNAME | quote }}
INDEX_NAME: {{ .Values.INDEX_NAME | quote }}
EMBED_MODEL: {{ .Values.LOCAL_EMBEDDING_MODEL | quote }}
{{- else if eq "MILVUS" .Values.RETRIEVER_BACKEND }}
RETRIEVER_COMPONENT_NAME: "OPEA_RETRIEVER_MILVUS"
{{- if .Values.MILVUS_HOST }}
MILVUS_HOST: {{ .Values.MILVUS_HOST | quote }}
MILVUS_HOST: {{ tpl .Values.MILVUS_HOST . | quote }}
{{- else }}
MILVUS_HOST: "{{ .Release.Name }}-milvus"
{{- end }}
MILVUS: {{ .Values.MILVUS_HOST | quote }}
MILVUS_PORT: {{ .Values.MILVUS_PORT | quote }}
{{- if .Values.COLLECTION_NAME }}
COLLECTION_NAME: {{ .Values.COLLECTION_NAME | quote }}
LOCAL_EMBEDDING_MODEL: {{ .Values.LOCAL_EMBEDDING_MODEL | quote }}
{{- else }}
{{- cat "Invalid RETRIEVER_BACKEND:" .Values.RETRIEVER_BACKEND | fail }}
{{- end }}
{{- if .Values.global.HF_ENDPOINT }}
HF_ENDPOINT: {{ .Values.global.HF_ENDPOINT | quote}}
{{- end }}
EASYOCR_MODULE_PATH: "/tmp/.EasyOCR"
http_proxy: {{ .Values.global.http_proxy | quote }}
https_proxy: {{ .Values.global.https_proxy | quote }}
{{- if and (not .Values.REDIS_URL) (and (not .Values.TEI_EMBEDDING_ENDPOINT) (or .Values.global.http_proxy .Values.global.https_proxy)) }}
no_proxy: "{{ .Release.Name }}-tei,{{ .Release.Name }}-redis-vector-db,{{ .Values.global.no_proxy }}"
{{- if and (and (not .Values.MILVUS_HOST ) (not .Values.REDIS_HOST)) (and (not .Values.TEI_EMBEDDING_ENDPOINT) (or .Values.global.http_proxy .Values.global.https_proxy)) }}
no_proxy: "{{ .Release.Name }}-tei,{{ .Release.Name }}-redis-vector-db,{{ .Release.Name }}-milvus,{{ .Values.global.no_proxy }}"
{{- else }}
no_proxy: {{ .Values.global.no_proxy | quote }}
no_proxy: {{ tpl .Values.global.no_proxy . | quote }}
{{- end }}
HF_HOME: "/tmp/.cache/huggingface"
HUGGINGFACEHUB_API_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}}
Expand Down
30 changes: 29 additions & 1 deletion helm-charts/common/retriever-usvc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,36 @@ spec:
serviceAccountName: {{ include "retriever-usvc.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: wait-for-db
envFrom:
- configMapRef:
name: {{ include "retriever-usvc.fullname" . }}-config
{{- if .Values.global.extraEnvConfig }}
- configMapRef:
name: {{ .Values.global.extraEnvConfig }}
optional: true
{{- end }}
image: busybox:1.36
command: ["sh", "-c"]
args:
- |
{{- if eq "REDIS" .Values.RETRIEVER_BACKEND }}
TESTHOST=$(REDIS_HOST);
TESTPORT=$(REDIS_PORT);
{{- else if eq "MILVUS" .Values.RETRIEVER_BACKEND }}
TESTHOST=$(MILVUS_HOST);
TESTPORT=$(MILVUS_PORT);
{{- end }}
retry_count={{ .Values.retryCount | default 60 }};
j=1;
while ! nc -z ${TESTHOST} ${TESTPORT}; do
[[ $j -ge ${retry_count} ]] && echo "ERROR: ${TESTHOST}:${TESTPORT} is NOT reachable in $j seconds!" && exit 1;
j=$((j+1)); sleep 1;
done;
echo "${TESTHOST}:${TESTPORT} is reachable within $j seconds.";
containers:
- name: {{ .Release.Name }}
- name: {{ .Chart.Name }}
envFrom:
- configMapRef:
name: {{ include "retriever-usvc.fullname" . }}-config
Expand Down
64 changes: 32 additions & 32 deletions helm-charts/common/retriever-usvc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,36 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

tei:
enabled: false
milvus:
enabled: false
redis-vector-db:
enabled: false

replicaCount: 1

# Set it as a non-null string, such as true, if you want to enable logging facility,
# otherwise, keep it as "" to disable it.
# Set it as a non-null string, such as true, if you want to enable logging.
LOGFLAG: ""

# retriever-usvc needs to use different vector-DB backend service, e.g. Redis, Milvus
# Default is to use Redis as vector-DB backend
RETRIEVER_BACKEND: "REDIS"
REDIS_HOST: ""
REDIS_PORT: 6379
REDIS_SSL: false
REDIS_PASSWORD: ""
REDIS_USERNAME: ""
INDEX_NAME: "rag_redis"

# Uncomment and set the following settings to use Milvus as vector-DB backend
# RETRIEVER_BACKEND: "MILVUS"
MILVUS_HOST: ""
MILVUS_PORT: 19530
COLLECTION_NAME: "rag_milvus"

# retriever-usvc can do embedding locally or talk to remote TEI service to do embedding.
# TEI_EMBEDDING_ENDPOINT takes precedence over LOCAL_EMBEDDING_MODEL.
# text embedding inference service URL, e.g. http://<service-name>:<port>
TEI_EMBEDDING_ENDPOINT: ""
# local embedding model
LOCAL_EMBEDDING_MODEL: ""

REDIS_URL: ""
INDEX_NAME: "rag-redis"

image:
repository: opea/retriever-redis
repository: opea/retriever
# Uncomment the following line to set desired image pull policy if needed, as one of Always, IfNotPresent, Never.
# pullPolicy: ""
# Overrides the image tag whose default is the chart appVersion.
Expand All @@ -52,7 +61,8 @@ podSecurityContext: {}
# fsGroup: 2000

securityContext:
readOnlyRootFilesystem: true
# NOTE: many dependent python modules(e.g. numpy, mpl, haystack, etc.) need to write to local disk
readOnlyRootFilesystem: false
lianhao marked this conversation as resolved.
Show resolved Hide resolved
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 1000
Expand All @@ -69,24 +79,13 @@ service:
port: 7000

resources:
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

livenessProbe:
httpGet:
path: v1/health_check
port: retriever-usvc
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 24
readinessProbe:
httpGet:
path: v1/health_check
Expand All @@ -107,13 +106,6 @@ tolerations: []

affinity: {}

# milvus DB configurations
MILVUS_HOST: ""
MILVUS_PORT: ""
COLLECTION_NAME: ""
MOSEC_EMBEDDING_ENDPOINT: ""
MOSEC_EMBEDDING_MODEL: ""

global:
http_proxy: ""
https_proxy: ""
Expand All @@ -129,3 +121,11 @@ global:

# Prometheus Helm install release name for serviceMonitor
prometheusRelease: prometheus-stack

# For CI tests only
tei:
enabled: false
milvus:
enabled: false
redis-vector-db:
enabled: false
Loading