Skip to content

Commit

Permalink
Add tts and speecht5 components helm chart
Browse files Browse the repository at this point in the history
Signed-off-by: Dolpher Du <Dolpher.Du@intel.com>
  • Loading branch information
yongfengdu committed Jul 17, 2024
1 parent 9def61a commit 9d14652
Show file tree
Hide file tree
Showing 19 changed files with 716 additions and 0 deletions.
23 changes: 23 additions & 0 deletions helm-charts/common/speecht5/.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/speecht5/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: speecht5
description: The Helm chart for deploying speecht5 as microservice
type: application
version: 0.8.0
# The speecht5 microservice server version
appVersion: "1.0.0"
31 changes: 31 additions & 0 deletions helm-charts/common/speecht5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# speecht5

Helm chart for deploying speecht5 service.

## Installing the Chart

To install the chart, run the following:

```console
export MODELDIR=/mnt/opea-models
helm install speecht5 speecht5 --set global.modelUseHostPath=${MODELDIR}
```

## Verify

Use port-forward to access it from localhost.

```console
kubectl port-forward service/speecht5 1234:7055 &
curl http://localhost:1234/v1/tts \
-XPOST \
-d '{"text": "Who are you?"}' \
-H 'Content-Type: application/json'
```

## Values

| Key | Type | Default | Description |
| ---------------- | ------ | ------------------------ | ----------- |
| image.repository | string | `"opea/speecht5:latest"` | |
| service.port | string | `"7055"` | |
66 changes: 66 additions & 0 deletions helm-charts/common/speecht5/gaudi-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

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

replicaCount: 1

# TTS_MODEL_PATH: "microsoft/speecht5_tts"
# VOCODE_MODEL: "microsoft/speecht5_hifigan"

image:
repository: opea/speecht5-gaudi: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: false
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 1000
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault

service:
type: ClusterIP
# The default port for speecht5 service is 7055
port: 7055

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:
modelUseHostPath: /mnt/opea-models
62 changes: 62 additions & 0 deletions helm-charts/common/speecht5/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "speecht5.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 "speecht5.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 "speecht5.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "speecht5.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "speecht5.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions helm-charts/common/speecht5/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "speecht5.fullname" . }}-config
labels:
{{- include "speecht5.labels" . | nindent 4 }}
data:
EASYOCR_MODULE_PATH: "/tmp/.EasyOCR"
# TTS_MODEL_PATH: {{ .Values.TTS_MODEL_PATH | quote }}
http_proxy: {{ .Values.global.http_proxy | quote }}
https_proxy: {{ .Values.global.https_proxy | quote }}
no_proxy: {{ .Values.global.no_proxy | quote }}
HF_HOME: "/tmp/.cache/huggingface"
HUGGINGFACE_HUB_CACHE: "/data"
77 changes: 77 additions & 0 deletions helm-charts/common/speecht5/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "speecht5.fullname" . }}
labels:
{{- include "speecht5.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "speecht5.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "speecht5.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 "speecht5.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: speecht5
containerPort: 7055
protocol: TCP
volumeMounts:
- mountPath: /data
name: model-volume
- mountPath: /tmp
name: tmp
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: model-volume
{{- if .Values.global.modelUseHostPath }}
hostPath:
path: {{ .Values.global.modelUseHostPath }}
type: Directory
{{- else }}
emptyDir: {}
{{- end }}
- 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/speecht5/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 "speecht5.fullname" . }}
labels:
{{- include "speecht5.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 7055
protocol: TCP
name: speecht5
selector:
{{- include "speecht5.selectorLabels" . | nindent 4 }}
25 changes: 25 additions & 0 deletions helm-charts/common/speecht5/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 "speecht5.fullname" . }}-testpod"
labels:
{{- include "speecht5.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 -sS --fail-with-body http://{{ include "speecht5.fullname" . }}:{{ .Values.service.port }}/v1/tts \
-X POST \
-d '{"text": "Who are you?"}' \
-H 'Content-Type: application/json'
restartPolicy: Never
Loading

0 comments on commit 9d14652

Please sign in to comment.