157 lines
6.8 KiB
YAML
157 lines
6.8 KiB
YAML
{{- if .Values.aiService.enabled }}
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: {{ include "medical-chatbot.fullname" . }}-ai-service
|
|
labels:
|
|
{{- include "medical-chatbot.labels" . | nindent 4 }}
|
|
data:
|
|
ENVIRONMENT: {{ .Values.global.environment | quote }}
|
|
QDRANT_URL: {{ default (printf "http://%s-qdrant:6333" (include "medical-chatbot.fullname" .)) .Values.qdrant.url | quote }}
|
|
QDRANT_COLLECTION: {{ .Values.aiService.config.qdrantCollection | quote }}
|
|
EMBEDDING_PROVIDER: {{ .Values.aiService.config.embeddingProvider | quote }}
|
|
EMBEDDING_DIMENSIONS: {{ .Values.aiService.config.embeddingDimensions | quote }}
|
|
EVIDENCE_MINIMUM_SCORE: {{ .Values.aiService.config.evidenceMinimumScore | quote }}
|
|
AWS_REGION: {{ .Values.aiService.config.awsRegion | quote }}
|
|
ANSWER_PROVIDER: {{ .Values.aiService.config.answerProvider | quote }}
|
|
ANSWER_MODEL_ID: {{ .Values.aiService.config.answerModelId | quote }}
|
|
RERANK_ENABLED: {{ .Values.aiService.config.rerankEnabled | quote }}
|
|
ENTITIES_PATH: {{ .Values.aiService.config.entitiesPath | quote }}
|
|
METRICS_ENABLED: {{ .Values.aiService.config.metricsEnabled | quote }}
|
|
OTEL_ENABLED: {{ and .Values.observability.enabled .Values.aiService.config.otelEnabled | quote }}
|
|
OTEL_SERVICE_NAME: ai-service
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: {{ printf "http://%s-otel-collector:4318/v1/traces" (include "medical-chatbot.fullname" .) | quote }}
|
|
OTEL_SAMPLE_RATIO: {{ .Values.aiService.config.otelSampleRatio | quote }}
|
|
{{- if .Values.aiService.config.langfuseBaseUrl }}
|
|
LANGFUSE_BASE_URL: {{ .Values.aiService.config.langfuseBaseUrl | quote }}
|
|
{{- end }}
|
|
MAX_WALL_CLOCK_MS: {{ .Values.aiService.config.maxWallClockMs | quote }}
|
|
MAX_LLM_CALLS_PER_TURN: {{ .Values.aiService.config.maxLlmCallsPerTurn | quote }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "medical-chatbot.fullname" . }}-ai-service
|
|
labels:
|
|
{{- include "medical-chatbot.labels" . | nindent 4 }}
|
|
app.kubernetes.io/component: ai-service
|
|
spec:
|
|
replicas: {{ .Values.aiService.replicaCount }}
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
app.kubernetes.io/component: ai-service
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
app.kubernetes.io/component: ai-service
|
|
annotations:
|
|
checksum/runtime-config: {{ dict "config" .Values.aiService.config "environment" .Values.global.environment "qdrantUrl" .Values.qdrant.url "observabilityEnabled" .Values.observability.enabled | toJson | sha256sum | quote }}
|
|
prometheus.io/scrape: "true"
|
|
prometheus.io/path: /metrics
|
|
prometheus.io/port: "8000"
|
|
spec:
|
|
serviceAccountName: {{ include "medical-chatbot.serviceAccountName" . }}
|
|
imagePullSecrets:
|
|
{{- toYaml .Values.global.imagePullSecrets | nindent 8 }}
|
|
{{- if .Values.aiService.migration.enabled }}
|
|
initContainers:
|
|
- name: migrate
|
|
image: {{ include "medical-chatbot.image" (dict "image" .Values.aiService.image "name" "aiService") | quote }}
|
|
imagePullPolicy: {{ .Values.aiService.image.pullPolicy }}
|
|
command: ["python", "migrate.py"]
|
|
envFrom:
|
|
- configMapRef: { name: {{ include "medical-chatbot.fullname" . }}-ai-service }
|
|
env:
|
|
- name: POSTGRES_DSN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "medical-chatbot.secretName" . }}
|
|
key: postgres-dsn
|
|
{{- end }}
|
|
containers:
|
|
- name: ai-service
|
|
image: {{ include "medical-chatbot.image" (dict "image" .Values.aiService.image "name" "aiService") | quote }}
|
|
imagePullPolicy: {{ .Values.aiService.image.pullPolicy }}
|
|
ports:
|
|
- { name: http, containerPort: 8000 }
|
|
envFrom:
|
|
- configMapRef: { name: {{ include "medical-chatbot.fullname" . }}-ai-service }
|
|
env:
|
|
- name: POSTGRES_DSN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "medical-chatbot.secretName" . }}
|
|
key: postgres-dsn
|
|
{{- if .Values.aiService.config.langfuseBaseUrl }}
|
|
# Langfuse keys are real credentials, so they come from the
|
|
# Secret, never the ConfigMap above (which is world-readable to
|
|
# anyone with namespace get access). Both are marked optional so
|
|
# a cluster that sets the base URL before creating the Secret
|
|
# starts anyway, with the exporter simply not added.
|
|
- name: LANGFUSE_PUBLIC_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "medical-chatbot.secretName" . }}
|
|
key: langfuse-public-key
|
|
optional: true
|
|
- name: LANGFUSE_SECRET_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "medical-chatbot.secretName" . }}
|
|
key: langfuse-secret-key
|
|
optional: true
|
|
{{- end }}
|
|
{{- if .Values.aws.region }}
|
|
- name: AWS_REGION
|
|
value: {{ .Values.aws.region | quote }}
|
|
{{- end }}
|
|
{{- if .Values.aws.staticCredentials.enabled }}
|
|
# Only rendered for clusters with no instance role / IRSA; see the
|
|
# `aws` block in values.yaml. Environment variables take precedence
|
|
# over the instance role, so this must stay off on AWS-hosted nodes.
|
|
- name: AWS_ACCESS_KEY_ID
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "medical-chatbot.secretName" . }}
|
|
key: aws-access-key-id
|
|
- name: AWS_SECRET_ACCESS_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "medical-chatbot.secretName" . }}
|
|
key: aws-secret-access-key
|
|
{{- end }}
|
|
readinessProbe:
|
|
httpGet: { path: /ready, port: http }
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
livenessProbe:
|
|
httpGet: { path: /health, port: http }
|
|
initialDelaySeconds: 15
|
|
periodSeconds: 20
|
|
startupProbe:
|
|
httpGet: { path: /health, port: http }
|
|
failureThreshold: 30
|
|
periodSeconds: 5
|
|
resources:
|
|
{{- toYaml .Values.aiService.resources | nindent 12 }}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: {{ include "medical-chatbot.fullname" . }}-ai-service
|
|
labels:
|
|
{{- include "medical-chatbot.labels" . | nindent 4 }}
|
|
app.kubernetes.io/component: ai-service
|
|
spec:
|
|
type: {{ .Values.aiService.service.type }}
|
|
selector:
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
app.kubernetes.io/component: ai-service
|
|
ports:
|
|
- name: http
|
|
port: {{ .Values.aiService.service.port }}
|
|
targetPort: http
|
|
{{- end }}
|