基于helm-dify 0.23.0 版本初始化
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
{{- if and .Values.api.enabled}}
|
||||
{{- $usePvc := not (or .Values.externalS3.enabled .Values.externalOSS.enabled .Values.externalAzureBlobStorage.enabled .Values.externalGCS.enabled .Values.externalCOS.enabled) -}}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
{{ include "dify.ud.annotations" . | indent 4 }}
|
||||
descriptions: api
|
||||
labels:
|
||||
{{- include "dify.labels" . | nindent 4 }}
|
||||
component: api
|
||||
# app: {{ template "dify.api.fullname" . }}
|
||||
{{ include "dify.ud.labels" . | indent 4 }}
|
||||
name: {{ template "dify.api.fullname" . }}
|
||||
spec:
|
||||
replicas: {{ .Values.api.replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "dify.selectorLabels" . | nindent 6 }}
|
||||
component: api
|
||||
{{/*
|
||||
# Required labels for istio
|
||||
# app: {{ template "dify.api.fullname" . }}
|
||||
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
|
||||
*/}}
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
checksum/api-config: {{ include (print $.Template.BasePath "/api-config.yaml") . | sha256sum }}
|
||||
checksum/api-secret: {{ include (print $.Template.BasePath "/api-secret.yaml") . | sha256sum }}
|
||||
{{ include "dify.ud.annotations" . | indent 8 }}
|
||||
labels:
|
||||
{{- include "dify.selectorLabels" . | nindent 8 }}
|
||||
component: api
|
||||
{{/*
|
||||
# Required labels for istio
|
||||
# app: {{ template "dify.api.fullname" . }}
|
||||
# version: {{ (print "v" .Values.serviceMesh.version) | quote }}
|
||||
*/}}
|
||||
{{ include "dify.ud.labels" . | indent 8 }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "dify.api.serviceAccountName" . }}
|
||||
{{- if eq .Release.Name "dify"}}
|
||||
{{/*
|
||||
Disable service environment variables,
|
||||
otherwise they will clash with `DIFY_PORT` which is needed in entrypoint.sh
|
||||
*/}}
|
||||
enableServiceLinks: false
|
||||
{{- end }}
|
||||
{{- if .Values.image.api.pullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- range .Values.image.api.pullSecrets }}
|
||||
- name: {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.api.podSecurityContext }}
|
||||
securityContext:
|
||||
{{ toYaml .Values.api.podSecurityContext | indent 8 }}
|
||||
{{- end }}
|
||||
initContainers:
|
||||
- name: init
|
||||
image: "{{.Values.image.python.repository }}:{{ default "3.12-slim" .Values.image.python.tag }}"
|
||||
imagePullPolicy: "{{.Values.image.python.pullPolicy }}"
|
||||
command: ["/bin/sh"]
|
||||
args: ["-c", "pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn"]
|
||||
volumeMounts:
|
||||
- name: python-config
|
||||
mountPath: /root/.config/pip
|
||||
containers:
|
||||
- image: "{{ .Values.image.api.repository }}:{{ default .Chart.AppVersion .Values.image.api.tag }}"
|
||||
imagePullPolicy: "{{ .Values.image.api.pullPolicy }}"
|
||||
name: api
|
||||
{{- if .Values.api.customLivenessProbe }}
|
||||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.api.customLivenessProbe "context" $) | nindent 10 }}
|
||||
{{- else if .Values.api.livenessProbe.enabled }}
|
||||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.api.livenessProbe "enabled") "context" $) | nindent 10 }}
|
||||
httpGet:
|
||||
path: /health
|
||||
port: api
|
||||
{{- end }}
|
||||
{{- if .Values.api.customReadinessProbe }}
|
||||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.api.customReadinessProbe "context" $) | nindent 10 }}
|
||||
{{- else if .Values.api.readinessProbe.enabled }}
|
||||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.api.readinessProbe "enabled") "context" $) | nindent 10 }}
|
||||
httpGet:
|
||||
path: /health
|
||||
port: api
|
||||
{{- end }}
|
||||
{{- if .Values.api.customStartupProbe }}
|
||||
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.api.customStartupProbe "context" $) | nindent 10 }}
|
||||
{{- else if .Values.api.startupProbe.enabled }}
|
||||
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.api.startupProbe "enabled") "context" $) | nindent 10 }}
|
||||
tcpSocket:
|
||||
port: api
|
||||
{{- end }}
|
||||
{{- if .Values.api.containerSecurityContext }}
|
||||
securityContext:
|
||||
{{ toYaml .Values.api.containerSecurityContext | indent 10 }}
|
||||
{{- end }}
|
||||
env:
|
||||
{{- if .Values.sandbox.enabled }}
|
||||
- name: CODE_EXECUTION_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "dify.sandbox.fullname" . }}
|
||||
key: "API_KEY"
|
||||
{{- end }}
|
||||
{{- if .Values.api.extraEnv }}
|
||||
{{- toYaml .Values.api.extraEnv | nindent 8 }}
|
||||
{{- end }}
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: {{ template "dify.api.fullname" . }}
|
||||
- secretRef:
|
||||
name: {{ template "dify.api.fullname" . }}
|
||||
ports:
|
||||
- name: api
|
||||
containerPort: 5001
|
||||
protocol: TCP
|
||||
resources:
|
||||
{{- toYaml .Values.api.resources | nindent 12 }}
|
||||
volumeMounts:
|
||||
- name: python-config
|
||||
mountPath: /root/.config/pip
|
||||
{{- if $usePvc }}
|
||||
- name: app-data
|
||||
mountPath: {{ .Values.api.persistence.mountPath | quote }}
|
||||
subPath: {{ .Values.api.persistence.persistentVolumeClaim.subPath | default "" }}
|
||||
{{- end }}
|
||||
{{- if and (.Values.nodeSelector) (not .Values.api.nodeSelector) }}
|
||||
nodeSelector:
|
||||
{{ toYaml .Values.nodeSelector | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.api.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{ toYaml .Values.api.nodeSelector | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if and (.Values.affinity) (not .Values.api.affinity) }}
|
||||
affinity:
|
||||
{{ toYaml .Values.affinity | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.api.affinity }}
|
||||
affinity:
|
||||
{{ toYaml .Values.api.affinity | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if and (.Values.tolerations) (not .Values.api.tolerations) }}
|
||||
tolerations:
|
||||
{{ toYaml .Values.tolerations | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.api.tolerations }}
|
||||
tolerations:
|
||||
{{ toYaml .Values.api.tolerations | indent 8 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: python-config
|
||||
emptyDir: {}
|
||||
{{- if $usePvc }}
|
||||
- name: app-data
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ .Values.api.persistence.persistentVolumeClaim.existingClaim | default (printf "%s" (include "dify.fullname" . | trunc 58)) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user