Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions charts/agentevals/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: agentevals
description: agentevals web UI, gRPC API, OTLP HTTP+gRPC receivers, and MCP (Streamable HTTP)
type: application
# The release workflow sets version and appVersion to the release tag when it publishes the chart.
version: 0.14.1
appVersion: "0.14.1"
version: 0.15.0
appVersion: "0.15.0"
2 changes: 1 addition & 1 deletion charts/agentevals/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{- if .Values.grpcApi.auth.enabled }}

gRPC API callers send a ServiceAccount token for audience "{{ .Values.grpcApi.auth.audience }}" as "authorization: Bearer <token>" metadata.
Allowed ServiceAccounts: {{ join ", " .Values.grpcApi.auth.allowedServiceAccounts }}. Health checks need no token.
Allowed ServiceAccounts: {{ include "agentevals.allowedServiceAccounts" . | fromJsonArray | join ", " }}. Health checks need no token.
{{- if not .Values.grpcApi.only }}
WARNING: authentication covers only the gRPC API. The UI, REST API, OTLP receivers and MCP stay unauthenticated; set grpcApi.only=true to keep them on 127.0.0.1.
{{- end }}
Expand Down
26 changes: 21 additions & 5 deletions charts/agentevals/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
{{- define "agentevals.image" -}}
{{- $registry := (.Values.global | default dict).imageRegistry | default .Values.image.registry | default .Values.registry -}}
{{- $tag := .Values.image.tag | default .Values.tag | default .Chart.AppVersion -}}
{{- $ref := printf "%s:%s" .Values.image.repository $tag -}}
{{- if .Values.image.digest -}}
{{- $ref = printf "%s@%s" .Values.image.repository .Values.image.digest -}}
{{- end -}}
{{- if $registry -}}
{{- printf "%s/%s:%s" $registry .Values.image.repository $tag -}}
{{- printf "%s/%s" $registry $ref -}}
{{- else -}}
{{- printf "%s:%s" .Values.image.repository $tag -}}
{{- $ref -}}
{{- end -}}
{{- end }}

Expand Down Expand Up @@ -109,6 +113,18 @@ ClusterRole and ClusterRoleBinding name for TokenReviews; cluster scoped, so it
{{- printf "%s-%s-tokenreview" (include "agentevals.namespace" .) (include "agentevals.fullname" .) -}}
{{- end -}}

{{/*
grpcApi.auth.allowedServiceAccounts as a JSON list, each entry rendered with tpl, so a parent chart
can name its own namespace and release in an entry.
*/}}
{{- define "agentevals.allowedServiceAccounts" -}}
{{- $rendered := list -}}
{{- range .Values.grpcApi.auth.allowedServiceAccounts -}}
{{- $rendered = append $rendered (tpl (toString .) $ | trim) -}}
{{- end -}}
{{- toJson $rendered -}}
{{- end -}}

{{/*
Fail the render on a gRPC API setup the server would refuse, or one that grants the TokenReview
permission to the namespace's default ServiceAccount.
Expand All @@ -128,9 +144,9 @@ permission to the namespace's default ServiceAccount.
{{- if empty $api.auth.allowedServiceAccounts -}}
{{- fail "grpcApi.auth.enabled needs grpcApi.auth.allowedServiceAccounts (namespace/name): any pod can mint a token for any audience, so the audience alone authorizes nothing" -}}
{{- end -}}
{{- range $api.auth.allowedServiceAccounts -}}
{{- if not (regexMatch "^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?/[a-z0-9]([-a-z0-9.]{0,251}[a-z0-9])?$" (toString .)) -}}
{{- fail (printf "grpcApi.auth.allowedServiceAccounts: %q is not namespace/name" (toString .)) -}}
{{- range include "agentevals.allowedServiceAccounts" . | fromJsonArray -}}
{{- if not (regexMatch "^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?/[a-z0-9]([-a-z0-9.]{0,251}[a-z0-9])?$" .) -}}
{{- fail (printf "grpcApi.auth.allowedServiceAccounts: %q is not namespace/name" .) -}}
{{- end -}}
{{- end -}}
{{- if and (not .Values.serviceAccount.create) (empty .Values.serviceAccount.name) -}}
Expand Down
2 changes: 1 addition & 1 deletion charts/agentevals/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ spec:
- name: AGENTEVALS_API_GRPC_AUTH_AUDIENCE
value: {{ .Values.grpcApi.auth.audience | quote }}
- name: AGENTEVALS_API_GRPC_AUTH_ALLOWED_SERVICE_ACCOUNTS
value: {{ join "," .Values.grpcApi.auth.allowedServiceAccounts | quote }}
value: {{ include "agentevals.allowedServiceAccounts" . | fromJsonArray | join "," | quote }}
{{- end }}
{{- if .Values.ephemeralVolume.enabled }}
- name: TMPDIR
Expand Down
5 changes: 4 additions & 1 deletion charts/agentevals/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ image:
repository: agentevals-dev/agentevals
# -- Container image tag (defaults to global tag, then Chart.appVersion)
tag: ""
# -- Container image digest, e.g. "sha256:...". Takes precedence over the tag.
digest: ""
# -- Container image pull policy (defaults to imagePullPolicy)
pullPolicy: ""

Expand Down Expand Up @@ -189,7 +191,8 @@ grpcApi:
audience: agentevals
# -- ServiceAccounts allowed to call the API, as namespace/name. Required when
# enabled: any pod can mint a token for any audience, so the audience alone
# authorizes nothing.
# authorizes nothing. Entries are templates, so a parent chart can write
# "{{ .Release.Namespace }}/{{ .Release.Name }}-caller".
allowedServiceAccounts: []

# ==============================================================================
Expand Down
10 changes: 10 additions & 0 deletions docs/grpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,13 @@ grpcApi:
```

The chart then adds a ClusterRole and ClusterRoleBinding that let its ServiceAccount create TokenReviews. It refuses to render with an empty `allowedServiceAccounts`, or without `serviceAccount.create` or `serviceAccount.name`, so the permission never goes to the namespace's `default` ServiceAccount.

Entries in `allowedServiceAccounts` are templates. A parent chart that ships agentevals as a subchart can name its own caller without knowing the namespace in advance:

```yaml
agentevals:
grpcApi:
auth:
allowedServiceAccounts:
- "{{ .Release.Namespace }}/{{ .Release.Name }}-controller"
```