From db6c5210687272f622a63e78c1718b11fdebcbac Mon Sep 17 00:00:00 2001 From: a601287411 <601287411@qq.com> Date: Wed, 12 Apr 2023 10:09:30 +0800 Subject: [PATCH] feat: add gpuResource config --- Chart.yaml | 2 +- README.md | 42 +++++++++++++++++++++++++++++++++++++++ templates/_helpers.tpl | 40 +++++++++++++++++++++++++++++++++++++ templates/deployment.yaml | 4 +--- templates/ingress.yaml | 2 +- values.yaml | 12 ++++++++++- 6 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 README.md diff --git a/Chart.yaml b/Chart.yaml index c06c4c8..e2adc29 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.1.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/README.md b/README.md new file mode 100644 index 0000000..be33c6c --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# Helm Chart for AILab demo API + +> 注:所有Demo能力需要部署在`default`命名空间下,才能使用`keda-http-add-on`代理服务。 + +## 快速使用 + +1、指定Demo能力镜像和服务端口 + +```shell +helm upgrade -n default --install hf-gan --set image.repository="artifacts.iflytek.com/docker-private/atp/aicloud/hf_fully_body_anime_gan" \ +--set image.tag="1fc7e9b8c0" --set image.pullPolicy=Always --set service.port=7860 . +``` + +2、指定Demo能力GPU规格 + +> GPU机器需要包含`gpushare`、`gputype`和`gpudrive`等标签。 + +```shell +helm upgrade -n default --install hf-gan --set image.repository="artifacts.iflytek.com/docker-private/atp/aicloud/hf_fully_body_anime_gan" \ +--set image.tag="1fc7e9b8c0" --set image.pullPolicy=Always --set service.port=7860 \ +--set gpuResource.enable=true,gpuResource.type="{t4,p4}",gpuResource.driverVersion="{515}" . +``` + +3、查看渲染后的部署清单 + +```shell +helm template demo01 --set gpuResource.enable=true --set gpuResource.type="{t4}",gpuResource.driverVersion="{515,418}" . +``` + +## 部署清单 + +### 资源列表 + +- ServiceAccount +- Deployment +- Ingress +- Service +- HTTPScaledObject + +## Values + +查看文件[values.yaml](values.yaml)。 diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index f31d94b..7b3f6c7 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -67,3 +67,43 @@ Create the url path of service {{- define "demo-chart.path" -}} {{ .Values.pathPrefix }}/{{ .Release.Name }} {{- end }} + +{{/* +Create the GPUNodeAffinity of service +*/}} +{{- define "demo-chart.GPUNodeAffinity" -}} +{{- if .Values.gpuResource.enable -}} +nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: gpushare + operator: In + values: ["true"] +{{- if .Values.gpuResource.type }} + - key: gputype + operator: In + values: + {{- range .Values.gpuResource.type }} + - {{ . | upper }} + {{- end }} +{{- end }} +{{- if .Values.gpuResource.driverVersion }} + - key: gpudrive + operator: In + values: + {{- range .Values.gpuResource.driverVersion }} + - {{ . | quote }} + {{- end }} +{{- end }} +{{- else -}} +nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - preference: + matchExpressions: + - key: gpushare + operator: NotIn + values: ["true"] + weight: 100 +{{- end }} +{{- end }} \ No newline at end of file diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 7bba8ca..28941c5 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -49,10 +49,8 @@ spec: nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.affinity }} affinity: - {{- toYaml . | nindent 8 }} - {{- end }} + {{- include "demo-chart.GPUNodeAffinity" . | nindent 8 }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} diff --git a/templates/ingress.yaml b/templates/ingress.yaml index 3ab87da..8b69e97 100644 --- a/templates/ingress.yaml +++ b/templates/ingress.yaml @@ -10,7 +10,7 @@ spec: - host: {{ .Values.host }} http: paths: - - path: {{ include "demo-chart.path" . }} + - path: {{ include "demo-chart.path" . }}/ pathType: Prefix backend: service: diff --git a/values.yaml b/values.yaml index 905afb2..55d1f45 100644 --- a/values.yaml +++ b/values.yaml @@ -67,6 +67,15 @@ resources: {} # cpu: 100m # memory: 128Mi +# GPU resource configuration +gpuResource: + # Specifies whether a GPU resource should be requested + enable: false + # Specifies the node GPU type list should be scheduled, maybe T4, P4, A100 + type: [] + # Specifies the GPU driver version list should be scheduled, maybe 418, 440, 515 + driverVersion: [] + autoscaling: http: minReplicas: 0 @@ -76,4 +85,5 @@ nodeSelector: {} tolerations: [] -affinity: {} +# Temporarily unconfigurable +# affinity: {}