{{- /* StatefulSet is used for: sqlite mode with persistence enabled and no existingClaim */}} {{- $useStatefulSet := and (eq .Values.storage.mode "sqlite") .Values.storage.persistence.enabled (not .Values.storage.persistence.existingClaim) }} {{- if $useStatefulSet }} {{- if not .Values.image.tag }} {{- fail "ERROR: image.tag is required. Please specify the Bifrost image version (e.g., --set image.tag=v1.3.36). See available tags at https://hub.docker.com/r/maximhq/bifrost/tags" }} {{- end }} {{- include "bifrost.validate" . }} apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "bifrost.fullname" . }} namespace: {{ .Release.Namespace }} labels: {{- include "bifrost.labels" . | nindent 4 }} {{- with .Values.deploymentLabels }} {{- toYaml . | nindent 4 }} {{- end }} {{- with .Values.deploymentAnnotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: serviceName: {{ include "bifrost.fullname" . }}-headless {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} {{- end }} selector: matchLabels: {{- include "bifrost.serverSelectorLabels" . | nindent 6 }} template: metadata: annotations: checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} labels: {{- include "bifrost.labels" . | nindent 8 }} app.kubernetes.io/component: server {{- with .Values.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ include "bifrost.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} {{- if .Values.terminationGracePeriodSeconds }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} {{- end }} {{- with .Values.initContainers }} initContainers: {{- toYaml . | nindent 8 }} {{- end }} containers: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} {{- with .Values.lifecycle }} lifecycle: {{- toYaml . | nindent 12 }} {{- end }} ports: - name: http containerPort: {{ .Values.bifrost.port }} protocol: TCP {{- if .Values.bifrost.cluster.enabled }} - name: gossip containerPort: {{ .Values.bifrost.cluster.gossip.port }} protocol: TCP - name: gossip-udp containerPort: {{ .Values.bifrost.cluster.gossip.port }} protocol: UDP {{- if .Values.bifrost.cluster.grpc }} - name: grpc containerPort: {{ .Values.bifrost.cluster.grpc.port }} protocol: TCP {{- end }} {{- end }} env: - name: APP_DIR value: {{ .Values.bifrost.appDir | quote }} - name: APP_PORT value: {{ .Values.bifrost.port | quote }} - name: APP_HOST value: {{ .Values.bifrost.host | quote }} - name: LOG_LEVEL value: {{ .Values.bifrost.logLevel | quote }} - name: LOG_STYLE value: {{ .Values.bifrost.logStyle | quote }} {{- if .Values.bifrost.encryptionKeySecret.name }} - name: BIFROST_ENCRYPTION_KEY valueFrom: secretKeyRef: name: {{ .Values.bifrost.encryptionKeySecret.name }} key: {{ .Values.bifrost.encryptionKeySecret.key }} {{- end }} {{- if and .Values.bifrost.plugins.semanticCache.enabled .Values.bifrost.plugins.semanticCache.secretRef .Values.bifrost.plugins.semanticCache.secretRef.name }} - name: SEMANTIC_CACHE_API_KEY valueFrom: secretKeyRef: name: {{ .Values.bifrost.plugins.semanticCache.secretRef.name }} key: {{ .Values.bifrost.plugins.semanticCache.secretRef.key | default "api-key" }} {{- end }} {{- /* PostgreSQL password from existing secret */ -}} {{- if and .Values.postgresql.external.enabled .Values.postgresql.external.existingSecret }} - name: BIFROST_POSTGRES_PASSWORD valueFrom: secretKeyRef: name: {{ .Values.postgresql.external.existingSecret }} key: {{ .Values.postgresql.external.passwordKey | default "password" }} {{- else if and .Values.postgresql.enabled (not .Values.postgresql.external.enabled) .Values.postgresql.auth.existingSecret }} - name: BIFROST_POSTGRES_PASSWORD valueFrom: secretKeyRef: name: {{ .Values.postgresql.auth.existingSecret }} key: {{ .Values.postgresql.auth.passwordKey | default "password" }} {{- end }} {{- /* Redis password from existing secret */ -}} {{- if and .Values.vectorStore.enabled (eq .Values.vectorStore.type "redis") .Values.vectorStore.redis.external.enabled .Values.vectorStore.redis.external.existingSecret }} - name: BIFROST_REDIS_PASSWORD valueFrom: secretKeyRef: name: {{ .Values.vectorStore.redis.external.existingSecret }} key: {{ .Values.vectorStore.redis.external.passwordKey | default "password" }} {{- end }} {{- /* Weaviate API key from existing secret */ -}} {{- if and .Values.vectorStore.enabled (eq .Values.vectorStore.type "weaviate") .Values.vectorStore.weaviate.external.enabled .Values.vectorStore.weaviate.external.existingSecret }} - name: BIFROST_WEAVIATE_API_KEY valueFrom: secretKeyRef: name: {{ .Values.vectorStore.weaviate.external.existingSecret }} key: {{ .Values.vectorStore.weaviate.external.apiKeyKey | default "api-key" }} {{- end }} {{- /* Qdrant API key from existing secret */ -}} {{- if and .Values.vectorStore.enabled (eq .Values.vectorStore.type "qdrant") .Values.vectorStore.qdrant.external.enabled .Values.vectorStore.qdrant.external.existingSecret }} - name: BIFROST_QDRANT_API_KEY valueFrom: secretKeyRef: name: {{ .Values.vectorStore.qdrant.external.existingSecret }} key: {{ .Values.vectorStore.qdrant.external.apiKeyKey | default "api-key" }} {{- end }} {{- /* Pinecone API key from existing secret */ -}} {{- if and .Values.vectorStore.enabled (eq .Values.vectorStore.type "pinecone") .Values.vectorStore.pinecone.external.enabled .Values.vectorStore.pinecone.external.existingSecret }} - name: BIFROST_PINECONE_API_KEY valueFrom: secretKeyRef: name: {{ .Values.vectorStore.pinecone.external.existingSecret }} key: {{ .Values.vectorStore.pinecone.external.apiKeyKey | default "api-key" }} {{- end }} {{- /* Object storage credentials from existing secret */ -}} {{- if and .Values.storage.logsStore.enabled .Values.storage.logsStore.objectStorage .Values.storage.logsStore.objectStorage.enabled .Values.storage.logsStore.objectStorage.existingSecret }} {{- if eq .Values.storage.logsStore.objectStorage.type "s3" }} - name: BIFROST_OBJECT_STORAGE_ACCESS_KEY_ID valueFrom: secretKeyRef: name: {{ .Values.storage.logsStore.objectStorage.existingSecret }} key: {{ .Values.storage.logsStore.objectStorage.accessKeyIdKey | default "access-key-id" }} optional: true - name: BIFROST_OBJECT_STORAGE_SECRET_ACCESS_KEY valueFrom: secretKeyRef: name: {{ .Values.storage.logsStore.objectStorage.existingSecret }} key: {{ .Values.storage.logsStore.objectStorage.secretAccessKeyKey | default "secret-access-key" }} optional: true - name: BIFROST_OBJECT_STORAGE_SESSION_TOKEN valueFrom: secretKeyRef: name: {{ .Values.storage.logsStore.objectStorage.existingSecret }} key: {{ .Values.storage.logsStore.objectStorage.sessionTokenKey | default "session-token" }} optional: true - name: BIFROST_OBJECT_STORAGE_ROLE_ARN valueFrom: secretKeyRef: name: {{ .Values.storage.logsStore.objectStorage.existingSecret }} key: {{ .Values.storage.logsStore.objectStorage.roleArnKey | default "role-arn" }} optional: true {{- end }} {{- if eq .Values.storage.logsStore.objectStorage.type "gcs" }} - name: BIFROST_OBJECT_STORAGE_CREDENTIALS_JSON valueFrom: secretKeyRef: name: {{ .Values.storage.logsStore.objectStorage.existingSecret }} key: {{ .Values.storage.logsStore.objectStorage.credentialsJsonKey | default "credentials-json" }} {{- end }} {{- end }} {{- /* Maxim API key from existing secret */ -}} {{- if and .Values.bifrost.plugins.maxim.enabled .Values.bifrost.plugins.maxim.secretRef .Values.bifrost.plugins.maxim.secretRef.name }} - name: BIFROST_MAXIM_API_KEY valueFrom: secretKeyRef: name: {{ .Values.bifrost.plugins.maxim.secretRef.name }} key: {{ .Values.bifrost.plugins.maxim.secretRef.key | default "api-key" }} {{- end }} {{- /* MCP client connection strings from existing secrets (one per client with secretRef.name set) */ -}} {{- if .Values.bifrost.mcp.enabled }} {{- range $idx, $client := .Values.bifrost.mcp.clientConfigs }} {{- if and $client.secretRef $client.secretRef.name }} - name: BIFROST_MCP_{{ regexReplaceAll "[^A-Z0-9]+" (upper $client.name) "_" }}_CONNECTION_STRING valueFrom: secretKeyRef: name: {{ $client.secretRef.name }} key: {{ $client.secretRef.connectionStringKey | default "connection-string" }} {{- end }} {{- end }} {{- end }} {{- /* Governance auth credentials from existing secret */ -}} {{- if and .Values.bifrost.governance .Values.bifrost.governance.authConfig .Values.bifrost.governance.authConfig.existingSecret }} - name: BIFROST_ADMIN_USERNAME valueFrom: secretKeyRef: name: {{ .Values.bifrost.governance.authConfig.existingSecret }} key: {{ .Values.bifrost.governance.authConfig.usernameKey | default "username" }} - name: BIFROST_ADMIN_PASSWORD valueFrom: secretKeyRef: name: {{ .Values.bifrost.governance.authConfig.existingSecret }} key: {{ .Values.bifrost.governance.authConfig.passwordKey | default "password" }} {{- end }} {{- /* Top-level auth credentials from existing secret (reuses same env vars as governance) */ -}} {{- if and .Values.bifrost.authConfig .Values.bifrost.authConfig.existingSecret (not (and .Values.bifrost.governance .Values.bifrost.governance.authConfig .Values.bifrost.governance.authConfig.existingSecret)) }} - name: BIFROST_ADMIN_USERNAME valueFrom: secretKeyRef: name: {{ .Values.bifrost.authConfig.existingSecret }} key: {{ .Values.bifrost.authConfig.usernameKey | default "username" }} - name: BIFROST_ADMIN_PASSWORD valueFrom: secretKeyRef: name: {{ .Values.bifrost.authConfig.existingSecret }} key: {{ .Values.bifrost.authConfig.passwordKey | default "password" }} {{- end }} {{- /* Provider secrets */ -}} {{- range $provider := (.Values.bifrost.providerSecrets | keys | sortAlpha) }} {{- $secret := index $.Values.bifrost.providerSecrets $provider }} {{- if and $secret.existingSecret $secret.envVar }} - name: {{ $secret.envVar }} valueFrom: secretKeyRef: name: {{ $secret.existingSecret }} key: {{ $secret.key | default "api-key" }} {{- end }} {{- end }} {{- with .Values.env }} {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.extraEnv }} {{- range $name := keys . | sortAlpha }} - name: {{ $name }} value: {{ index $.Values.extraEnv $name | quote }} {{- end }} {{- end }} {{- with .Values.envFrom }} envFrom: {{- toYaml . | nindent 12 }} {{- end }} livenessProbe: {{- toYaml .Values.livenessProbe | nindent 12 }} readinessProbe: {{- toYaml .Values.readinessProbe | nindent 12 }} resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: - name: data mountPath: {{ .Values.bifrost.appDir }} - name: config mountPath: {{ .Values.bifrost.appDir }}/config.json subPath: config.json readOnly: true {{- with .Values.volumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} volumes: - name: config configMap: name: {{ include "bifrost.fullname" . }}-config {{- with .Values.volumes }} {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} volumeClaimTemplates: - metadata: name: data labels: {{- /* Keep volumeClaimTemplates labels immutable-safe. Do not include bifrost.labels here because chart/app version labels change between releases and StatefulSet volumeClaimTemplates are immutable. */}} {{- include "bifrost.selectorLabels" . | nindent 10 }} app.kubernetes.io/component: server spec: accessModes: - {{ .Values.storage.persistence.accessMode }} {{- if .Values.storage.persistence.storageClass }} {{- if (eq "-" .Values.storage.persistence.storageClass) }} storageClassName: "" {{- else }} storageClassName: {{ .Values.storage.persistence.storageClass }} {{- end }} {{- end }} resources: requests: storage: {{ .Values.storage.persistence.size }} {{- end }}