-
Notifications
You must be signed in to change notification settings - Fork 5
[beta] Add an optional deployment for AI Gateway #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brianvans (brianvans)
merged 6 commits into
main
from
brianvans/ai-gateway-initial-deployment
Jun 23, 2026
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
24f5f1e
[beta] Add an optional deployment for AI Gateway
brianvans 04af477
Fix helm unit github action
brianvans 3e310fe
Set GATEWAY_URL if AI Gateway is deployed
brianvans b2e6ab3
Derive AI Gateway OTLP endpoint from braintrustAppUrl.
brianvans cfa04ab
Split AI Gateway deploy from API routing via useGateway.
brianvans 5504cf2
Remove `otlpHttpEndpoint` override
brianvans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| {{- if .Values.aiGateway.enabled }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: {{ .Values.aiGateway.name }} | ||
| namespace: {{ include "braintrust.namespace" . }} | ||
| {{- with (merge (deepCopy .Values.aiGateway.labels) .Values.global.labels) }} | ||
| labels: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| {{- with .Values.aiGateway.annotations.configmap }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| data: | ||
| GATEWAY_ENV: "production" | ||
| {{- if .Values.aiGateway.region }} | ||
| GATEWAY_REGION: {{ .Values.aiGateway.region | quote }} | ||
| {{- end }} | ||
| BRAINTRUST_APP_URL: {{ .Values.aiGateway.braintrustAppUrl | quote }} | ||
| BRAINTRUST_API_URL: {{ default (include "braintrust.apiInternalUrl" .) .Values.aiGateway.braintrustApiUrl | quote }} | ||
| GATEWAY_JSON_LOGS: "true" | ||
| GATEWAY_TELEMETRY: {{ .Values.global.controlPlaneTelemetry | quote }} | ||
| {{- $appUrl := .Values.aiGateway.braintrustAppUrl | trimSuffix "/" }} | ||
| OTLP_HTTP_ENDPOINT: {{ default (printf "%s/api/pulse/otel" $appUrl) .Values.aiGateway.otlpHttpEndpoint | quote }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| {{- if .Values.aiGateway.enabled }} | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: {{ .Values.aiGateway.name }} | ||
| namespace: {{ include "braintrust.namespace" . }} | ||
| {{- with (merge (deepCopy .Values.aiGateway.labels) .Values.global.labels) }} | ||
| labels: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| {{- with .Values.aiGateway.annotations.deployment }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| spec: | ||
| replicas: {{ .Values.aiGateway.replicas }} | ||
| strategy: | ||
| type: RollingUpdate | ||
| rollingUpdate: | ||
| maxSurge: 100% | ||
| maxUnavailable: 0 | ||
| selector: | ||
| matchLabels: | ||
| app: {{ .Values.aiGateway.name }} | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: {{ .Values.aiGateway.name }} | ||
| {{- with (merge (deepCopy .Values.aiGateway.podLabels) .Values.aiGateway.labels .Values.global.labels) }} | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| annotations: | ||
| checksum/config: {{ include (print $.Template.BasePath "/ai-gateway-configmap.yaml") . | sha256sum }} | ||
| {{- with .Values.aiGateway.annotations.pod }} | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| spec: | ||
| {{- with .Values.aiGateway.nodeSelector }} | ||
| nodeSelector: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- with .Values.aiGateway.tolerations }} | ||
| tolerations: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- with .Values.aiGateway.affinity }} | ||
| affinity: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| containers: | ||
| - name: ai-gateway | ||
| image: "{{ .Values.aiGateway.image.repository }}:{{ .Values.aiGateway.image.tag }}" | ||
| imagePullPolicy: {{ .Values.aiGateway.image.pullPolicy }} | ||
| ports: | ||
| - containerPort: {{ .Values.aiGateway.service.port }} | ||
| resources: | ||
| {{- toYaml .Values.aiGateway.resources | nindent 12 }} | ||
| {{- with .Values.aiGateway.livenessProbe }} | ||
| livenessProbe: | ||
| {{- toYaml . | nindent 12 }} | ||
| {{- end }} | ||
| {{- with .Values.aiGateway.readinessProbe }} | ||
| readinessProbe: | ||
| {{- toYaml . | nindent 12 }} | ||
| {{- end }} | ||
| envFrom: | ||
| - configMapRef: | ||
| name: {{ .Values.aiGateway.name }} | ||
| env: | ||
| - name: COMPLETIONS_CACHE_REDIS_URL | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: braintrust-secrets | ||
| key: REDIS_URL | ||
| - name: AUTH_CACHE_REDIS_URL | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: braintrust-secrets | ||
| key: REDIS_URL | ||
| - name: BRAINSTORE_LICENSE_KEY | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: braintrust-secrets | ||
| key: BRAINSTORE_LICENSE_KEY | ||
| {{- if .Values.aiGateway.extraEnvVars }} | ||
| {{- toYaml .Values.aiGateway.extraEnvVars | nindent 12 }} | ||
| {{- end }} | ||
| {{- with .Values.aiGateway.extraContainers }} | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| volumes: | ||
| {{- with .Values.aiGateway.extraVolumes }} | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- else }} | ||
| [] | ||
| {{- end }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| {{- if .Values.aiGateway.enabled }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: {{ .Values.aiGateway.service.name | default .Values.aiGateway.name }} | ||
| namespace: {{ include "braintrust.namespace" . }} | ||
| {{- with (merge (deepCopy .Values.aiGateway.labels) .Values.global.labels) }} | ||
| labels: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| {{- with .Values.aiGateway.annotations.service }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| spec: | ||
| selector: | ||
| app: {{ .Values.aiGateway.name }} | ||
| ports: | ||
| - name: {{ .Values.aiGateway.service.portName }} | ||
| protocol: TCP | ||
| port: {{ .Values.aiGateway.service.port }} | ||
| targetPort: {{ .Values.aiGateway.service.port }} | ||
| type: {{ .Values.aiGateway.service.type }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| suite: test AI gateway configmap template | ||
| templates: | ||
| - ai-gateway-configmap.yaml | ||
| tests: | ||
| - it: should not render when ai-gateway is disabled | ||
| values: | ||
| - __fixtures__/base-values.yaml | ||
| release: | ||
| namespace: "braintrust" | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| - it: should render ai-gateway configmap when enabled | ||
| values: | ||
| - __fixtures__/base-values.yaml | ||
| set: | ||
| aiGateway.enabled: true | ||
| release: | ||
| namespace: "braintrust" | ||
| asserts: | ||
| - isKind: | ||
| of: ConfigMap | ||
| - equal: | ||
| path: metadata.name | ||
| value: braintrust-ai-gateway | ||
| - equal: | ||
| path: data.GATEWAY_ENV | ||
| value: "production" | ||
| - isNull: | ||
| path: data.GATEWAY_REGION | ||
| - equal: | ||
| path: data.BRAINTRUST_APP_URL | ||
| value: "https://www.braintrust.dev" | ||
| - equal: | ||
| path: data.BRAINTRUST_API_URL | ||
| value: "http://braintrust-api.braintrust:8000" | ||
| - equal: | ||
| path: data.GATEWAY_JSON_LOGS | ||
| value: "true" | ||
| - equal: | ||
| path: data.GATEWAY_TELEMETRY | ||
| value: "status,metrics" | ||
| - equal: | ||
| path: data.OTLP_HTTP_ENDPOINT | ||
| value: "https://www.braintrust.dev/api/pulse/otel" | ||
|
|
||
| - it: should set GATEWAY_REGION when region is provided | ||
| values: | ||
| - __fixtures__/base-values.yaml | ||
| set: | ||
| aiGateway.enabled: true | ||
| aiGateway.region: "us-east-1" | ||
| release: | ||
| namespace: "braintrust" | ||
| asserts: | ||
| - equal: | ||
| path: data.GATEWAY_REGION | ||
| value: "us-east-1" | ||
|
|
||
| - it: should use global controlPlaneTelemetry for GATEWAY_TELEMETRY | ||
| values: | ||
| - __fixtures__/base-values.yaml | ||
| set: | ||
| aiGateway.enabled: true | ||
| aiGateway.region: "us-east-1" | ||
| global.controlPlaneTelemetry: "status,metrics,usage,logs" | ||
| release: | ||
| namespace: "braintrust" | ||
| asserts: | ||
| - equal: | ||
| path: data.GATEWAY_TELEMETRY | ||
| value: "status,metrics,usage,logs" | ||
|
|
||
| - it: should use custom braintrustApiUrl when provided | ||
| values: | ||
| - __fixtures__/base-values.yaml | ||
| set: | ||
| aiGateway.enabled: true | ||
| aiGateway.region: "us-east-1" | ||
| aiGateway.braintrustApiUrl: "https://api.example.com" | ||
| release: | ||
| namespace: "braintrust" | ||
| asserts: | ||
| - equal: | ||
| path: data.BRAINTRUST_API_URL | ||
| value: "https://api.example.com" | ||
|
|
||
| - it: should derive OTLP_HTTP_ENDPOINT from braintrustAppUrl | ||
| values: | ||
| - __fixtures__/base-values.yaml | ||
| set: | ||
| aiGateway.enabled: true | ||
| aiGateway.braintrustAppUrl: "https://control.example.com" | ||
| release: | ||
| namespace: "braintrust" | ||
| asserts: | ||
| - equal: | ||
| path: data.OTLP_HTTP_ENDPOINT | ||
| value: "https://control.example.com/api/pulse/otel" | ||
|
|
||
| - it: should derive OTLP_HTTP_ENDPOINT from braintrustAppUrl with trailing slash | ||
| values: | ||
| - __fixtures__/base-values.yaml | ||
| set: | ||
| aiGateway.enabled: true | ||
| aiGateway.braintrustAppUrl: "https://control.example.com/" | ||
| release: | ||
| namespace: "braintrust" | ||
| asserts: | ||
| - equal: | ||
| path: data.OTLP_HTTP_ENDPOINT | ||
| value: "https://control.example.com/api/pulse/otel" | ||
|
|
||
| - it: should use custom otlpHttpEndpoint when provided | ||
| values: | ||
| - __fixtures__/base-values.yaml | ||
| set: | ||
| aiGateway.enabled: true | ||
| aiGateway.braintrustAppUrl: "https://control.example.com" | ||
| aiGateway.otlpHttpEndpoint: "https://otel.example.com/v1" | ||
| release: | ||
| namespace: "braintrust" | ||
| asserts: | ||
| - equal: | ||
| path: data.OTLP_HTTP_ENDPOINT | ||
| value: "https://otel.example.com/v1" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have have separate config for deploying gateway and configuring GATEWAY_URL. I'm worried about the initial deploy where the pods are still deploying (hopefully without issue but sometimes there are surprises) and the API gets configured with a url before the service is stable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Added
aiGateway.useGatewaybool in cfa04ab to allow customers to do a two-phase deploy like you described