-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helm chart for VisualQnA example (#505)
Add visualqna and the dependent lvm-uservice helm charts. Signed-off-by: Dolpher Du <[email protected]>
- Loading branch information
1 parent
74476b7
commit b077d44
Showing
23 changed files
with
957 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
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,15 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v2 | ||
name: lvm-uservice | ||
description: The Helm chart for deploying lvm as microservice | ||
type: application | ||
version: 1.0.0 | ||
# The lvm microservice server version | ||
appVersion: "v1.0" | ||
dependencies: | ||
- name: tgi | ||
version: 1.0.0 | ||
repository: file://../tgi | ||
condition: tgi.enabled |
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,55 @@ | ||
# lvm-uservice | ||
|
||
Helm chart for deploying LVM microservice. | ||
|
||
lvm-uservice depends on TGI, you should set LVM_ENDPOINT as tgi endpoint. | ||
|
||
## (Option1): Installing the chart separately | ||
|
||
First, you need to install the tgi chart, please refer to the [tgi](../tgi) chart for more information. | ||
|
||
After you've deployted the tgi chart successfully, please run `kubectl get svc` to get the tgi service endpoint, i.e. `http://tgi`. | ||
|
||
To install the chart, run the following: | ||
|
||
```console | ||
cd GenAIInfra/helm-charts/common/lvm-uservice | ||
export HFTOKEN="insert-your-huggingface-token-here" | ||
export LVM_ENDPOINT="http://tgi" | ||
helm dependency update | ||
helm install lvm-uservice . --set global.HUGGINGFACEHUB_API_TOKEN=${HFTOKEN} --set LVM_ENDPOINT=${LVM_ENDPOINT} --wait | ||
``` | ||
|
||
## (Option2): Installing the chart with dependencies automatically | ||
|
||
```console | ||
cd GenAIInfra/helm-charts/common/lvm-uservice | ||
export HFTOKEN="insert-your-huggingface-token-here" | ||
helm dependency update | ||
helm install lvm-uservice . --set global.HUGGINGFACEHUB_API_TOKEN=${HFTOKEN} --set tgi.enabled=true --wait | ||
``` | ||
|
||
## 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/lvm-uservice 9000:9000` to expose the lvm-uservice service for access. | ||
|
||
Open another terminal and run the following command to verify the service if working: | ||
|
||
```console | ||
curl http://localhost:9000/v1/chat/completions \ | ||
-X POST \ | ||
-d '{"query":"What is Deep Learning?","max_tokens":17,"top_k":10,"top_p":0.95,"typical_p":0.95,"temperature":0.01,"repetition_penalty":1.03,"streaming":true}' \ | ||
-H 'Content-Type: application/json' | ||
``` | ||
|
||
## Values | ||
|
||
| Key | Type | Default | Description | | ||
| ------------------------------- | ------ | ---------------- | ------------------------------- | | ||
| global.HUGGINGFACEHUB_API_TOKEN | string | `""` | Your own Hugging Face API token | | ||
| image.repository | string | `"opea/lvm-tgi"` | | | ||
| service.port | string | `"9000"` | | | ||
| LVM_ENDPOINT | string | `""` | LVM endpoint | | ||
| global.monitoring | bop; | false | Service usage metrics | |
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,9 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Default values for lvm-uservice. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
tgi: | ||
enabled: true |
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,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "lvm-uservice.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "lvm-uservice.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "lvm-uservice.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "lvm-uservice.labels" -}} | ||
helm.sh/chart: {{ include "lvm-uservice.chart" . }} | ||
{{ include "lvm-uservice.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "lvm-uservice.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "lvm-uservice.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "lvm-uservice.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "lvm-uservice.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
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,28 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "lvm-uservice.fullname" . }}-config | ||
labels: | ||
{{- include "lvm-uservice.labels" . | nindent 4 }} | ||
data: | ||
{{- if .Values.LVM_ENDPOINT }} | ||
LVM_ENDPOINT: {{ .Values.LVM_ENDPOINT | quote}} | ||
{{- else }} | ||
LVM_ENDPOINT: "http://{{ .Release.Name }}-tgi" | ||
{{- end }} | ||
HUGGINGFACEHUB_API_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}} | ||
HF_HOME: "/tmp/.cache/huggingface" | ||
{{- if .Values.global.HF_ENDPOINT }} | ||
HF_ENDPOINT: {{ .Values.global.HF_ENDPOINT | quote}} | ||
{{- end }} | ||
http_proxy: {{ .Values.global.http_proxy | quote }} | ||
https_proxy: {{ .Values.global.https_proxy | quote }} | ||
{{- if and (not .Values.LVM_ENDPOINT) (or .Values.global.http_proxy .Values.global.https_proxy) }} | ||
no_proxy: "{{ .Release.Name }}-tgi,{{ .Values.global.no_proxy }}" | ||
{{- else }} | ||
no_proxy: {{ .Values.global.no_proxy | quote }} | ||
{{- end }} | ||
LOGFLAG: {{ .Values.LOGFLAG | quote }} |
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,88 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "lvm-uservice.fullname" . }} | ||
labels: | ||
{{- include "lvm-uservice.labels" . | nindent 4 }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
selector: | ||
matchLabels: | ||
{{- include "lvm-uservice.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
labels: | ||
{{- include "lvm-uservice.selectorLabels" . | nindent 8 }} | ||
spec: | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
containers: | ||
- name: {{ .Release.Name }} | ||
envFrom: | ||
- configMapRef: | ||
name: {{ include "lvm-uservice.fullname" . }}-config | ||
{{- if .Values.global.extraEnvConfig }} | ||
- configMapRef: | ||
name: {{ .Values.global.extraEnvConfig }} | ||
optional: true | ||
{{- end }} | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 12 }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
ports: | ||
- name: lvm-uservice | ||
containerPort: 9399 | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /tmp | ||
name: tmp | ||
{{- if .Values.livenessProbe }} | ||
livenessProbe: | ||
{{- toYaml .Values.livenessProbe | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.readinessProbe }} | ||
readinessProbe: | ||
{{- toYaml .Values.readinessProbe | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.startupProbe }} | ||
startupProbe: | ||
{{- toYaml .Values.startupProbe | nindent 12 }} | ||
{{- end }} | ||
resources: | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
volumes: | ||
- name: tmp | ||
emptyDir: {} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.evenly_distributed }} | ||
topologySpreadConstraints: | ||
- maxSkew: 1 | ||
topologyKey: kubernetes.io/hostname | ||
whenUnsatisfiable: ScheduleAnyway | ||
labelSelector: | ||
matchLabels: | ||
{{- include "lvm-uservice.selectorLabels" . | nindent 14 }} | ||
{{- end }} |
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,18 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "lvm-uservice.fullname" . }} | ||
labels: | ||
{{- include "lvm-uservice.labels" . | nindent 4 }} | ||
spec: | ||
type: {{ .Values.service.type }} | ||
ports: | ||
- port: {{ .Values.service.port }} | ||
targetPort: 9399 | ||
protocol: TCP | ||
name: lvm-uservice | ||
selector: | ||
{{- include "lvm-uservice.selectorLabels" . | nindent 4 }} |
18 changes: 18 additions & 0 deletions
18
helm-charts/common/lvm-uservice/templates/servicemonitor.yaml
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,18 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
{{- if .Values.global.monitoring }} | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
name: {{ include "lvm-uservice.fullname" . }} | ||
labels: | ||
release: {{ .Values.global.prometheusRelease }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
{{- include "lvm-uservice.selectorLabels" . | nindent 6 }} | ||
endpoints: | ||
- port: lvm-uservice | ||
interval: 5s | ||
{{- end }} |
30 changes: 30 additions & 0 deletions
30
helm-charts/common/lvm-uservice/templates/tests/test-pod.yaml
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,30 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: "{{ include "lvm-uservice.fullname" . }}-testpod" | ||
labels: | ||
{{- include "lvm-uservice.labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": test | ||
#"helm.sh/hook-delete-policy": "hook-succeeded, hook-failure" | ||
spec: | ||
containers: | ||
- name: curl | ||
image: python:3.10.14 | ||
command: ['bash', '-c'] | ||
args: | ||
- | | ||
max_retry=20; | ||
for ((i=1; i<=max_retry; i++)); do | ||
curl http://{{ include "lvm-uservice.fullname" . }}:{{ .Values.service.port }}/v1/lvm -sS --fail-with-body \ | ||
-X POST \ | ||
-d '{"image":"iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mP8/5+hnoEIwDiqkL4KAcT9GO0U4BxoAAAAAElFTkSuQmCC","prompt":"What is this?"}' \ | ||
-H 'Content-Type: application/json' && break; | ||
curlcode=$? | ||
if [[ $curlcode -eq 7 ]]; then sleep 10; else echo "curl failed with code $curlcode"; exit 1; fi; | ||
done; | ||
if [ $i -gt $max_retry ]; then echo "test failed with maximum retry"; exit 1; fi | ||
restartPolicy: Never |
Oops, something went wrong.