diff --git a/charts/agentevals/Chart.yaml b/charts/agentevals/Chart.yaml index 2f56646..bc3a673 100644 --- a/charts/agentevals/Chart.yaml +++ b/charts/agentevals/Chart.yaml @@ -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" diff --git a/charts/agentevals/templates/NOTES.txt b/charts/agentevals/templates/NOTES.txt index 956cb20..79299e4 100644 --- a/charts/agentevals/templates/NOTES.txt +++ b/charts/agentevals/templates/NOTES.txt @@ -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 " 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 }} diff --git a/charts/agentevals/templates/_helpers.tpl b/charts/agentevals/templates/_helpers.tpl index 3c9aeb7..145d091 100644 --- a/charts/agentevals/templates/_helpers.tpl +++ b/charts/agentevals/templates/_helpers.tpl @@ -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 }} @@ -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. @@ -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) -}} diff --git a/charts/agentevals/templates/deployment.yaml b/charts/agentevals/templates/deployment.yaml index c4da90b..2bd2509 100644 --- a/charts/agentevals/templates/deployment.yaml +++ b/charts/agentevals/templates/deployment.yaml @@ -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 diff --git a/charts/agentevals/values.yaml b/charts/agentevals/values.yaml index f71e586..ab4e09a 100644 --- a/charts/agentevals/values.yaml +++ b/charts/agentevals/values.yaml @@ -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: "" @@ -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: [] # ============================================================================== diff --git a/docs/grpc-api.md b/docs/grpc-api.md index f3f9634..8c5159e 100644 --- a/docs/grpc-api.md +++ b/docs/grpc-api.md @@ -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" +```