167 lines
6 KiB
YAML
167 lines
6 KiB
YAML
{{- $component := "worker" }}
|
|
{{- $name := include "ragflow.componentFullname" (dict "root" . "component" $component) }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ $name }}
|
|
labels:
|
|
{{- include "ragflow.labels" . | nindent 4 }}
|
|
app.kubernetes.io/component: {{ $component }}
|
|
spec:
|
|
replicas: {{ .Values.ragflow.worker.replicaCount }}
|
|
{{- with .Values.ragflow.worker.deployment.strategy }}
|
|
strategy:
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
selector:
|
|
matchLabels:
|
|
{{- include "ragflow.selectorLabels" . | nindent 6 }}
|
|
app.kubernetes.io/component: {{ $component }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
{{- include "ragflow.selectorLabels" . | nindent 8 }}
|
|
app.kubernetes.io/component: {{ $component }}
|
|
{{- with .Values.ragflow.worker.podAnnotations }}
|
|
annotations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
spec:
|
|
{{- $globalPullSecrets := .Values.imagePullSecrets }}
|
|
{{- $basePullSecrets := .Values.ragflow.image.pullSecrets }}
|
|
{{- $workerImage := default (dict) .Values.ragflow.worker.image }}
|
|
{{- $componentPullSecrets := default list $workerImage.pullSecrets }}
|
|
{{- if or (or $globalPullSecrets $basePullSecrets) $componentPullSecrets }}
|
|
imagePullSecrets:
|
|
{{- with $globalPullSecrets }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with $basePullSecrets }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with $componentPullSecrets }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- $localServiceConf := .Values.ragflow.service_conf }}
|
|
{{- $llmFactories := .Values.ragflow.llm_factories }}
|
|
{{- $consumerRange := .Values.ragflow.worker.consumerRange }}
|
|
{{- $rangeEnabled := and $consumerRange $consumerRange.enabled }}
|
|
{{- $consumeBegin := default 0 (and $consumerRange $consumerRange.begin) }}
|
|
containers:
|
|
- name: {{ $component }}
|
|
{{- $imageRepository := default .Values.ragflow.image.repository $workerImage.repository }}
|
|
{{- $imageTag := default .Values.ragflow.image.tag $workerImage.tag }}
|
|
image: {{ printf "%s:%s" $imageRepository $imageTag }}
|
|
{{- $pullPolicy := default .Values.ragflow.image.pullPolicy $workerImage.pullPolicy }}
|
|
{{- with $pullPolicy }}
|
|
imagePullPolicy: {{ . }}
|
|
{{- end }}
|
|
command:
|
|
- /bin/bash
|
|
- -lc
|
|
- |
|
|
set -eo pipefail
|
|
cd /ragflow
|
|
: "${POD_NAME:=$(hostname)}"
|
|
|
|
export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/"
|
|
PY=python3
|
|
JEMALLOC_PATH="$(pkg-config --variable=libdir jemalloc)/libjemalloc.so"
|
|
HOST_ID="${HOST_ID:-${POD_NAME}}"
|
|
CONSUMER_NO=0
|
|
USE_RANGE={{ ternary "1" "0" $rangeEnabled }}
|
|
if [[ "${USE_RANGE}" -eq 1 ]]; then
|
|
CONSUMER_BEGIN={{ $consumeBegin }}
|
|
CONSUMER_NO="${CONSUMER_BEGIN}"
|
|
fi
|
|
|
|
declare -a ARGS
|
|
{{- range $arg := .Values.ragflow.worker.extraArgs }}
|
|
ARGS+=({{ $arg | quote }})
|
|
{{- end }}
|
|
|
|
exec env LD_PRELOAD="${JEMALLOC_PATH}" "${PY}" rag/svr/task_executor.py "${HOST_ID}_${CONSUMER_NO}" "${ARGS[@]}"
|
|
envFrom:
|
|
- secretRef:
|
|
name: {{ include "ragflow.fullname" . }}-env-config
|
|
env:
|
|
- name: POD_NAME
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.name
|
|
{{- with .Values.ragflow.worker.extraEnv }}
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
{{- $probes := default (dict) .Values.ragflow.worker.probes }}
|
|
{{- if $probes.liveness }}
|
|
livenessProbe:
|
|
{{- toYaml $probes.liveness | nindent 12 }}
|
|
{{- else }}
|
|
livenessProbe:
|
|
exec:
|
|
command:
|
|
- /bin/bash
|
|
- -lc
|
|
- |
|
|
ps -p 1 -o cmd= | grep -q "rag/svr/task_executor.py"
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 15
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
successThreshold: 1
|
|
{{- end }}
|
|
{{- if $probes.readiness }}
|
|
readinessProbe:
|
|
{{- toYaml $probes.readiness | nindent 12 }}
|
|
{{- else }}
|
|
readinessProbe:
|
|
exec:
|
|
command:
|
|
- /bin/bash
|
|
- -lc
|
|
- |
|
|
ps -p 1 -o cmd= | grep -q "rag/svr/task_executor.py"
|
|
initialDelaySeconds: 15
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
successThreshold: 1
|
|
{{- end }}
|
|
{{- if $probes.startup }}
|
|
startupProbe:
|
|
{{- toYaml $probes.startup | nindent 12 }}
|
|
{{- else }}
|
|
startupProbe:
|
|
exec:
|
|
command:
|
|
- /bin/bash
|
|
- -lc
|
|
- |
|
|
ps -p 1 -o cmd= | grep -q "rag/svr/task_executor.py"
|
|
periodSeconds: 10
|
|
failureThreshold: 30
|
|
{{- end }}
|
|
volumeMounts:
|
|
- mountPath: /ragflow/conf/service_conf.yaml
|
|
subPath: service_conf.yaml
|
|
name: service-conf-volume
|
|
{{- if $localServiceConf }}
|
|
- mountPath: /ragflow/conf/local.service_conf.yaml
|
|
subPath: local.service_conf.yaml
|
|
name: service-conf-volume
|
|
{{- end }}
|
|
{{- if $llmFactories }}
|
|
- mountPath: /ragflow/conf/llm_factories.json
|
|
subPath: llm_factories.json
|
|
name: service-conf-volume
|
|
{{- end }}
|
|
{{- with .Values.ragflow.worker.deployment.resources }}
|
|
resources:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
volumes:
|
|
- name: service-conf-volume
|
|
configMap:
|
|
name: ragflow-service-config
|