Skip to content

Commit

Permalink
Add whisper and asr components
Browse files Browse the repository at this point in the history
Signed-off-by: Dolpher Du <[email protected]>
  • Loading branch information
yongfengdu committed Jul 15, 2024
1 parent 7d3d13f commit 9def61a
Show file tree
Hide file tree
Showing 19 changed files with 735 additions and 0 deletions.
23 changes: 23 additions & 0 deletions helm-charts/common/asr/.helmignore
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/
10 changes: 10 additions & 0 deletions helm-charts/common/asr/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v2
name: asr
description: The Helm chart for deploying asr as microservice
type: application
version: 0.8.0
# The asr microservice server version
appVersion: "1.0.0"
34 changes: 34 additions & 0 deletions helm-charts/common/asr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# asr

Helm chart for deploying asr microservice.

Web retriever depends on whisper, you should set ASR_ENDPOINT endpoints before start.

## Installing the Chart

To install the chart, run the following:

```console
export ASR_ENDPOINT="http://whisper:7066"
helm install asr asr --set ASR_ENDPOINT=${ASR_ENDPOINT}
```

## Verify

Use port-forward to access it from localhost.

```console
kubectl port-forward service/asr 1234:9099 &
curl http://localhost:1234/v1/audio/transcriptions \
-XPOST \
-d '{"byte_str": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"}' \
-H 'Content-Type: application/json'
```

## Values

| Key | Type | Default | Description |
| ---------------- | ------ | ------------------- | ----------- |
| image.repository | string | `"opea/asr:latest"` | |
| service.port | string | `"9099"` | |
| ASR_ENDPOINT | string | `""` | |
62 changes: 62 additions & 0 deletions helm-charts/common/asr/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "asr.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 "asr.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 "asr.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "asr.labels" -}}
helm.sh/chart: {{ include "asr.chart" . }}
{{ include "asr.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "asr.selectorLabels" -}}
app.kubernetes.io/name: {{ include "asr.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "asr.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "asr.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions helm-charts/common/asr/templates/configmap.yaml
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: ConfigMap
metadata:
name: {{ include "asr.fullname" . }}-config
labels:
{{- include "asr.labels" . | nindent 4 }}
data:
{{- if .Values.ASR_ENDPOINT }}
ASR_ENDPOINT: {{ .Values.ASR_ENDPOINT | quote}}
{{- else }}
ASR_ENDPOINT: "http://{{ .Release.Name }}-whisper:7066"
{{- end }}
http_proxy: {{ .Values.global.http_proxy | quote }}
https_proxy: {{ .Values.global.https_proxy | quote }}
no_proxy: {{ .Values.global.no_proxy | quote }}
87 changes: 87 additions & 0 deletions helm-charts/common/asr/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "asr.fullname" . }}
labels:
{{- include "asr.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "asr.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "asr.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 "asr.fullname" . }}-config
{{- if .Values.global.extraEnvConfig }}
- configMapRef:
name: {{ .Values.global.extraEnvConfig }}
optional: true
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: asr
containerPort: 9099
protocol: TCP
volumeMounts:
- mountPath: /tmp
name: tmp
#startupProbe:
# exec:
# command:
# - curl
# {{- if .Values.ASR_ENDPOINT }}
# - {{ .Values.ASR_ENDPOINT }}
# {{- else }}
# - http://{{ .Release.Name }}-whisper
# {{- end }}
# initialDelaySeconds: 5
# periodSeconds: 5
# failureThreshold: 120
# livenessProbe:
# httpGet:
# path: /
# port: 7000
# readinessProbe:
# httpGet:
# path: /
# port: 7000
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 }}
18 changes: 18 additions & 0 deletions helm-charts/common/asr/templates/service.yaml
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 "asr.fullname" . }}
labels:
{{- include "asr.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 9099
protocol: TCP
name: asr
selector:
{{- include "asr.selectorLabels" . | nindent 4 }}
25 changes: 25 additions & 0 deletions helm-charts/common/asr/templates/tests/test-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: Pod
metadata:
name: "{{ include "asr.fullname" . }}-testpod"
labels:
{{- include "asr.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 "asr.fullname" . }}:{{ .Values.service.port }}/v1/audio/transcriptions \
-XPOST \
-d '{"byte_str": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"}' \
-H 'Content-Type: application/json'
restartPolicy: Never
64 changes: 64 additions & 0 deletions helm-charts/common/asr/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

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

replicaCount: 1

ASR_ENDPOINT: ""

image:
repository: opea/asr:latest
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
# tag: "1.0"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 1000
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault

service:
type: ClusterIP
# The default port for asr service is 9099
port: 9099

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

nodeSelector: {}

tolerations: []

affinity: {}

global:
http_proxy:
https_proxy:
no_proxy:
23 changes: 23 additions & 0 deletions helm-charts/common/whisper/.helmignore
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/
10 changes: 10 additions & 0 deletions helm-charts/common/whisper/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v2
name: whisper
description: The Helm chart for deploying whisper as microservice
type: application
version: 0.8.0
# The whisper microservice server version
appVersion: "1.0.0"
Loading

0 comments on commit 9def61a

Please sign in to comment.