{{- if .Values.api.enabled }} apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "hindsight.fullname" . }}-api labels: {{- include "hindsight.api.labels" . | nindent 4 }} spec: {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.api.replicaCount }} {{- end }} selector: matchLabels: {{- include "hindsight.api.selectorLabels" . | nindent 6 }} template: metadata: annotations: {{- if not .Values.existingSecret }} checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} {{- end }} {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} labels: {{- include "hindsight.api.selectorLabels" . | nindent 8 }} spec: {{- if .Values.serviceAccount.create }} serviceAccountName: {{ include "hindsight.serviceAccountName" . }} {{- end }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: - name: api securityContext: {{- toYaml .Values.securityContext | nindent 10 }} image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Values.version | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.api.image.pullPolicy }} ports: - name: http containerPort: {{ .Values.api.service.targetPort }} protocol: TCP {{- if .Values.existingSecret }} envFrom: - secretRef: name: {{ .Values.existingSecret }} {{- end }} env: {{- /* POSTGRES_PASSWORD must be defined before DATABASE_URL for $(VAR) interpolation */}} {{- if not .Values.postgresql.enabled }} - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: {{ include "hindsight.secretName" . }} key: postgres-password {{- end }} - name: HINDSIGHT_API_DATABASE_URL value: {{ include "hindsight.databaseUrl" . | quote }} {{- /* Disable internal worker when dedicated workers are enabled */}} {{- if .Values.worker.enabled }} - name: HINDSIGHT_API_WORKER_ENABLED value: "false" {{- end }} {{- /* Explicitly set port to override K8s service discovery env var (HINDSIGHT_API_PORT) */}} - name: HINDSIGHT_API_PORT value: {{ .Values.api.service.targetPort | quote }} {{- range $key, $value := .Values.api.env }} - name: {{ $key }} value: {{ $value | quote }} {{- end }} {{- if .Values.tei.reranker.enabled }} - name: HINDSIGHT_API_RERANKER_PROVIDER value: "tei" - name: HINDSIGHT_API_RERANKER_TEI_URL value: "http://{{ include "hindsight.fullname" . }}-tei-reranker:{{ .Values.tei.reranker.port }}" {{- end }} {{- if .Values.tei.embedding.enabled }} - name: HINDSIGHT_API_EMBEDDINGS_PROVIDER value: "tei" - name: HINDSIGHT_API_EMBEDDINGS_TEI_URL value: "http://{{ include "hindsight.fullname" . }}-tei-embedding:{{ .Values.tei.embedding.port }}" {{- end }} {{- /* Only use api.secrets when not using existingSecret (for chart-managed secrets) */}} {{- if not .Values.existingSecret }} {{- range $key, $value := .Values.api.secrets }} - name: {{ $key }} valueFrom: secretKeyRef: name: {{ include "hindsight.secretName" $ }} key: {{ $key }} {{- end }} {{- end }} livenessProbe: {{- toYaml .Values.api.livenessProbe | nindent 10 }} readinessProbe: {{- toYaml .Values.api.readinessProbe | nindent 10 }} resources: {{- toYaml .Values.api.resources | nindent 10 }} {{- if or .Values.api.persistence.modelCache.enabled .Values.api.extraVolumeMounts }} volumeMounts: {{- if .Values.api.persistence.modelCache.enabled }} - name: model-cache mountPath: /home/hindsight/.cache {{- end }} {{- with .Values.api.extraVolumeMounts }} {{- toYaml . | nindent 8 }} {{- end }} {{- end }} {{- if or .Values.api.persistence.modelCache.enabled .Values.api.extraVolumes }} volumes: {{- if .Values.api.persistence.modelCache.enabled }} - name: model-cache persistentVolumeClaim: claimName: {{ include "hindsight.fullname" . }}-api-model-cache {{- end }} {{- with .Values.api.extraVolumes }} {{- toYaml . | nindent 6 }} {{- end }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with (.Values.api.affinity | default .Values.affinity) }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} {{- end }}