apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Values.engine.namePrefix }} labels: &labels {{ include "deepgram-self-hosted.labels" . | indent 4}} app: deepgram-engine {{- range $key, $val := .Values.engine.additionalLabels }} {{ $key }}: {{ $val | quote }} {{- end}} {{- with .Values.engine.additionalAnnotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: selector: matchLabels: app: deepgram-engine {{ include "deepgram-self-hosted.selectorLabels" . }} {{- if not .Values.engineAutoscaling.enabled }} replicas: {{ .Values.scaling.replicas.engine }} {{- end }} strategy: type: RollingUpdate rollingUpdate: maxUnavailable: {{ .Values.engine.updateStrategy.rollingUpdate.maxUnavailable }} maxSurge: {{ .Values.engine.updateStrategy.rollingUpdate.maxSurge }} template: metadata: labels: *labels annotations: checksum/config: {{ include (print $.Template.BasePath "/engine/engine.config.yaml") . | sha256sum }} spec: nodeSelector: {{- toYaml .Values.engine.nodeSelector | nindent 8 }} terminationGracePeriodSeconds: {{ .Values.global.outstandingRequestGracePeriod }} {{- if .Values.global.pullSecretRef }} imagePullSecrets: - name: {{ .Values.global.pullSecretRef }} {{- end }} affinity: {{- toYaml .Values.engine.affinity | nindent 8 }} tolerations: {{- toYaml .Values.engine.tolerations | nindent 8 }} securityContext: {{- toYaml .Values.licenseProxy.securityContext | nindent 8 }} {{- if or .Values.engine.serviceAccount.create .Values.engine.serviceAccount.name }} serviceAccountName: {{ default (printf "%s-sa" .Values.engine.namePrefix) .Values.engine.serviceAccount.name }} {{- end }} containers: - name: {{ .Values.engine.namePrefix }} image: {{ .Values.engine.image.path }}:{{ .Values.engine.image.tag }} imagePullPolicy: {{ .Values.engine.image.pullPolicy }} envFrom: - secretRef: name: {{ required "Missing Deepgram self-hosted API key - see `global.deepgramSecretRef`" .Values.global.deepgramSecretRef }} {{- if le (int .Values.engine.resources.requests.gpu) 0 }} env: - name: NVIDIA_VISIBLE_DEVICES value: "void" {{- end }} command: [ "impeller" ] args: ["-v", "serve", "/etc/config/engine.toml"] resources: requests: memory: "{{ .Values.engine.resources.requests.memory }}" cpu: "{{ .Values.engine.resources.requests.cpu }}" {{- if gt (int .Values.engine.resources.requests.gpu) 0 }} nvidia.com/gpu: {{ .Values.engine.resources.requests.gpu }} {{- end }} limits: memory: "{{ .Values.engine.resources.limits.memory }}" cpu: "{{ .Values.engine.resources.limits.cpu }}" {{- if gt (int .Values.engine.resources.limits.gpu) 0 }} nvidia.com/gpu: {{ .Values.engine.resources.limits.gpu }} {{- end }} volumeMounts: - name: engine-config-volume mountPath: /etc/config - name: models-volume mountPath: /models ports: - name: primary containerPort: {{ .Values.engine.server.port }} - name: metrics containerPort: {{ .Values.engine.metricsServer.port }} startupProbe: tcpSocket: port: {{ .Values.engine.server.port }} periodSeconds: {{ .Values.engine.startupProbe.periodSeconds }} failureThreshold: {{ .Values.engine.startupProbe.failureThreshold }} livenessProbe: tcpSocket: port: {{ .Values.engine.server.port }} initialDelaySeconds: {{ .Values.engine.livenessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.engine.livenessProbe.periodSeconds }} failureThreshold: {{ .Values.engine.livenessProbe.failureThreshold }} readinessProbe: tcpSocket: port: {{ .Values.engine.server.port }} initialDelaySeconds: {{ .Values.engine.readinessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.engine.readinessProbe.periodSeconds }} failureThreshold: {{ .Values.engine.readinessProbe.failureThreshold }} {{- if .Values.engine.lifecycle }} lifecycle: {{- toYaml .Values.engine.lifecycle | nindent 10 }} {{- end }} volumes: - name: engine-config-volume configMap: name: {{ .Values.engine.namePrefix }}-config - name: models-volume persistentVolumeClaim: {{- $customClaimEnabled := .Values.engine.modelManager.volumes.customVolumeClaim.enabled }} {{- $customClaimName := .Values.engine.modelManager.volumes.customVolumeClaim.name }} {{- $awsEfsEnabled := .Values.engine.modelManager.volumes.aws.efs.enabled }} {{- $gcpGpdEnabled := .Values.engine.modelManager.volumes.gcp.gpd.enabled }} {{- $nova3Enabled := .Values.engine.modelManager.volumes.nova3.enabled }} {{- $nova3MultilingualEnabled := .Values.engine.modelManager.volumes.nova3.multilingual.enabled }} {{- $enabledCount := (int $customClaimEnabled) | add (int $awsEfsEnabled) | add (int $gcpGpdEnabled) }} {{- if eq $enabledCount 0 }} {{- fail "Error: At least one of customVolumeClaim.enabled, aws.efs.enabled, or gcp.gpd.enabled must be set to true." }} {{- else if gt $enabledCount 1 }} {{- fail "Error: Only one of customVolumeClaim.enabled, aws.efs.enabled, or gcp.gpd.enabled can be set to true." }} {{- end }} {{- if $customClaimEnabled }} {{- if not $customClaimName }} {{- fail "Error: customVolumeClaim.name must be set when customVolumeClaim.enabled is true." }} {{- else }} claimName: {{ $customClaimName }} {{- end }} {{- else if $awsEfsEnabled }} claimName: {{ .Values.engine.modelManager.volumes.aws.efs.namePrefix }}-aws-efs-pvc {{- else if and $gcpGpdEnabled $nova3Enabled }} claimName: {{ .Values.engine.modelManager.volumes.gcp.gpd.namePrefix }}-gcp-gpd-pvc-nova3 {{- else if and $gcpGpdEnabled $nova3MultilingualEnabled }} claimName: {{ .Values.engine.modelManager.volumes.gcp.gpd.namePrefix }}-gcp-gpd-pvc-nova3-multilingual {{- else }} claimName: {{ .Values.engine.modelManager.volumes.gcp.gpd.namePrefix }}-gcp-gpd-pvc-v1 {{- end }}