{{- if .Values.model.download.enabled }} apiVersion: batch/v1 kind: Job metadata: name: {{ .Release.Name }}-download-model annotations: "helm.sh/hook": pre-install,pre-upgrade # 在安装/升级前执行 "helm.sh/hook-weight": "-10" # 优先执行 "helm.sh/hook-delete-policy": hook-succeeded spec: template: spec: restartPolicy: OnFailure containers: - name: downloader image: {{ .Values.model.download.image }} env: - name: HF_ENDPOINT value: https://hf-mirror.com - name: HUGGING_FACE_HUB_TOKEN value: {{ .Values.model.huggingfaceToken }} command: - sh - -c - | DEST_DIR="{{ .Values.model.localMountPath }}/{{ .Values.model.huggingfaceName }}" if [ -d "$DEST_DIR" ]; then echo "Model already exists at $DEST_DIR" else echo "Downloading model {{ .Values.model.huggingfaceName }} to $DEST_DIR" wget https://hf-mirror.com/hfd/hfd.sh chmod a+x hfd.sh apt install aria2 -y ./hfd.sh {{ .Values.model.huggingfaceName }} --local-dir "$DEST_DIR" # huggingface-cli download {{ .Values.model.huggingfaceName }} --local-dir "$DEST_DIR" fi volumeMounts: - name: model-storage mountPath: {{ .Values.model.localMountPath }} volumes: - name: model-storage persistentVolumeClaim: claimName: nfs-pvc-model # 复用之前的 PVC {{- end }}