ragflow/helm/templates/api.yaml
2025-11-03 15:03:46 +08:00

162 lines
5.6 KiB
YAML

{{- $component := "api" }}
{{- $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.api.replicaCount }}
{{- with .Values.ragflow.api.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.api.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- $globalPullSecrets := .Values.imagePullSecrets }}
{{- $basePullSecrets := .Values.ragflow.image.pullSecrets }}
{{- $apiImage := default (dict) .Values.ragflow.api.image }}
{{- $componentPullSecrets := default list $apiImage.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 }}
containers:
- name: {{ $component }}
workingDir: /ragflow
{{- $imageRepository := default .Values.ragflow.image.repository $apiImage.repository }}
{{- $imageTag := default .Values.ragflow.image.tag $apiImage.tag }}
image: {{ printf "%s:%s" $imageRepository $imageTag }}
{{- $pullPolicy := default .Values.ragflow.image.pullPolicy $apiImage.pullPolicy }}
{{- with $pullPolicy }}
imagePullPolicy: {{ . }}
{{- end }}
command:
- /bin/bash
- -lc
- |
set -eo pipefail
cd /ragflow
export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/"
exec python3 api/ragflow_server.py{{- range $arg := .Values.ragflow.api.extraArgs }} {{ $arg | quote }}{{- end }}
ports:
- name: http
containerPort: 9380
{{- $probes := default (dict) .Values.ragflow.api.probes }}
{{- if $probes.liveness }}
livenessProbe:
{{- toYaml $probes.liveness | nindent 12 }}
{{- else }}
livenessProbe:
httpGet:
path: /v1/system/healthz
port: http
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
{{- end }}
{{- if $probes.readiness }}
readinessProbe:
{{- toYaml $probes.readiness | nindent 12 }}
{{- else }}
readinessProbe:
httpGet:
path: /v1/system/healthz
port: http
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
successThreshold: 1
{{- end }}
{{- if $probes.startup }}
startupProbe:
{{- toYaml $probes.startup | nindent 12 }}
{{- else }}
startupProbe:
httpGet:
path: /v1/system/healthz
port: http
periodSeconds: 10
failureThreshold: 30
{{- end }}
envFrom:
- secretRef:
name: {{ include "ragflow.fullname" . }}-env-config
env:
- name: FLASK_ENV
value: {{ ternary "development" "production" (default false .Values.ragflow.api.debug) | quote }}
- name: FLASK_DEBUG
value: {{ ternary "1" "0" (default false .Values.ragflow.api.debug) | quote }}
{{- with .Values.ragflow.api.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- 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.api.deployment.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: service-conf-volume
configMap:
name: ragflow-service-config
---
apiVersion: v1
kind: Service
metadata:
name: {{ $name }}
labels:
{{- include "ragflow.labels" . | nindent 4 }}
app.kubernetes.io/component: {{ $component }}
spec:
type: {{ .Values.ragflow.api.service.type }}
selector:
{{- include "ragflow.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: {{ $component }}
{{- if gt (int .Values.ragflow.api.replicaCount) 1 }}
sessionAffinity: ClientIP
{{- end }}
ports:
- name: http
port: {{ .Values.ragflow.api.service.port }}
targetPort: http