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
1 change: 1 addition & 0 deletions .github/workflows/fast-path.yml
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ jobs:
make local-acceptance-test PYTHON=python3
python3 ci/agent-relay/test_control_webapp_names.py -v
python3 ci/agent-relay/test_eks_alb_ingress.py -v
python3 ci/agent-relay/test_site_values.py -v
python3 ci/agent-relay/test_traefik_ingress.py -v
python3 ci/agent-relay/test_gate_relayfacts_routes.py -v
python3 ci/agent-relay/test_release_candidate.py -v
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ jobs:
make local-acceptance-test PYTHON=python3
python3 ci/agent-relay/test_control_webapp_names.py -v
python3 ci/agent-relay/test_eks_alb_ingress.py -v
python3 ci/agent-relay/test_site_values.py -v
python3 ci/agent-relay/test_traefik_ingress.py -v
python3 ci/agent-relay/test_gate_relayfacts_routes.py -v
python3 ci/agent-relay/test_release_candidate.py -v
Expand Down
2 changes: 1 addition & 1 deletion charts/agent-relay/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: agent-relay
description: Self-hosted Agent Relay messaging and sessions suite
type: application
version: 0.7.85
version: 0.7.86
appVersion: "0.1.0"
kubeVersion: ">=1.28.0-0"
annotations:
Expand Down
80 changes: 79 additions & 1 deletion charts/agent-relay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,82 @@ off by default; see `docs/self-hosted-durable-actors.md`. Relay Chief
Requires Helm 3.10 or newer: the relay-control subchart uses
`{{ continue }}`, which older Helm versions cannot parse.

## Site values

Set each site fact once, at the top level of your values file, and the chart
fills every component value that repeats it:

```yaml
site:
domain: relay.acme.com # <domain>, api., cast., history.<domain>
region: us-east-1 # S3 bucket (and OpenSearch) region
sessionsBucket: acme-agent-relay-sessions
opensearchUrl: https://vpc-agent-relay-abc123.us-east-1.es.amazonaws.com
orgId: org_acme # never change it after the first upload
orgName: Acme
adminEmail: admin@acme.com
rds: true # databases on RDS in region: chart-managed CA
# hosts: { dashboard: app.acme.com } # optional: replace one hostname
```

| `site.` | Fills |
|---|---|
| `domain` (or `hosts.dashboard/api/cast/history`) | `relaycast.baseUrl`; `relay-control` `publicUrl`, `dashboardUrl`, `services.relaycastPublicUrl`, `services.sessionReadApiPublicUrl`, `introspection.audiences`; `relay-webapp.runtime.publicUrl`; in `sessions-pipeline`: `sessionReadApi.origin`, `sessionReadApi.cors.allowedOrigins`, `ingestEdge.origin`, `alleyoop.auth.historyOrigin` (and `nativeRouting.origin` when enabled); `eksIngress.domain`/`hosts`, `gkeIngress.hosts`, `traefikIngress.hosts` when that edge is enabled |
| `region` | every `locker.region` (`worker`, `alleyoop`, `ingestEdge`, `searchIndexer`, `nativeConsumer`), the read API's `LOCKER_REGION`, and both `search.opensearch.region` values when `opensearchUrl` is set |
| `sessionsBucket` | every `locker.bucket` and the read API's `LOCKER_BUCKET` |
| `opensearchUrl` | `sessionReadApi.search.opensearch.url` and `searchIndexer.search.opensearch.url` |
| `orgId` | `global.tenant.orgId`, in every chart |
| `orgName`, `adminEmail` | `relay-control.bootstrap.orgName` and `.adminEmail` |
| `rds: true` (with `region`) | `global.rdsCa.bundle` in every chart: the chart-managed RDS CA for that region ([Chart-managed RDS CA](#chart-managed-rds-ca)). An explicit `global.rdsCa.bundle` (another region, or `global`) wins |

A site key you leave out fills nothing, and a component that is off is left
alone. In single-host mode (`global.singleHost.host`) the single host derives
the dashboard and api URLs: the chart empties a profile placeholder in
`relay-control.publicUrl` and `relay-webapp.runtime.publicUrl`, and takes
`relay-control.dashboardUrl` and the read API's CORS origin from the single
host.

The GKE and AKS guides' `values.yaml` keep the long form until their pinned
release carries site values (they install a released chart with the
checkout's files); `ci/agent-relay/fixtures/gcp-site-values.yaml` is the GKE
file in the short form.

**Explicit values still work.** A file with every value spelled out (the long
form, before site values) renders exactly as it did. With `site:` set:

- A component value that is empty, or still the example the chart's own
profile ships (`values-eks.yaml`'s `placeholder.company` hosts,
`example-agent-relay-sessions`, `example-org`), gets the site value. A
profile region such as `us-west-2` counts as an example only while the bucket
or OpenSearch URL next to it is also an example.
- Where a value may differ (`search.opensearch.region` for an OpenSearch domain
in another region, `cors.allowedOrigins`, `introspection.audiences`, and
`relay-control.bootstrap`, which only Control reads), your value wins.
- Where it must agree (hosts, bucket, bucket region, OpenSearch URL, org ID),
a different value fails the render, naming both:
`sessions-pipeline.worker.locker.bucket = "old-bucket" contradicts
site.sessionsBucket`. Delete the component value.

**Every values problem in one report.** Before any component renders, the chart
checks the site values, the contradictions above and the checks that the
components otherwise make one at a time (the public History origin, OpenSearch
URLs, the shared bucket, matching origins), and fails once with the full list:
each value's path, what is wrong and the fix. Checks it does not cover still
come from the component, one at a time, once the list is clear. To see the list
without a cluster, run `scripts/selfhost/check-values.sh` with the same `-f`
files as the helm command; it also points out example values (the
`examples/aws` domain, bucket, org, email) left in your own files, by line.

How it works: Helm only lets a parent chart pass `global` to its subcharts, so
the umbrella fills the values instead, from
`templates/site/runs-before-subcharts/1/2/3/4/5/site.yaml`. Helm renders the
deepest template path first and gives each subchart the same values map the
umbrella sees, so that template sets the values before any subchart reads
them. `ci/agent-relay/test_site_values.py` fails if another template becomes
as deep, or if the report stops coming out before a subchart's own failure.
The release keeps the values you supplied (`helm get values` shows `site:`,
not the filled values).

## Customer-neutral GCP template

`values-gcp.yaml` is the customer-neutral starting point for a full GKE
Expand Down Expand Up @@ -385,7 +461,9 @@ helm template agent-relay charts/agent-relay \
-f <private-site-values.yaml> >/dev/null
```

The private overlay must replace every copy marked `REQUIRED OVERRIDE`: the
[Site values](#site-values) (`site:`) fill the domain, bucket, region,
OpenSearch URL and org copies below from one line each. Otherwise the private
overlay must replace every copy marked `REQUIRED OVERRIDE`: the
organization ID, public origins, S3 bucket and region, the RDS CA (set
`global.rdsCa.bundle` to the RDS region, or override every RDS CA SHA-256),
OpenSearch endpoint/backend ID/region, ALB subnet CIDRs, first owner details,
Expand Down
163 changes: 163 additions & 0 deletions charts/agent-relay/templates/_site.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{{- /*
Site values (top-level `site:`) and the aggregated values check.

templates/site/runs-before-subcharts/1/2/3/4/5/site.yaml includes
"agent-relay.site.run" once. That file is the deepest template path in the
chart, and Helm renders templates deepest path first (engine sortTemplates),
so it runs before every subchart template. It:

1. fills each subchart value that site derives (domain, hosts, region,
sessionsBucket, opensearchUrl, orgId, orgName, adminEmail) when the value
is empty or still the chart/profile default, by setting it in .Values.
A subchart's .Values is the same map as the umbrella's .Values.<subchart>,
so the subcharts render with the filled values. Globals are copied per
chart, so global.tenant.orgId is set in every chart's copy.
2. collects every problem it can see (site values, a per-component value
that contradicts site, and the subchart checks mirrored here) and fails
once with the whole list.

ci/agent-relay/test_site_values.py keeps both properties honest: it fails
when any template in the built chart is as deep as site.yaml, and when an
aggregated failure does not come out before a subchart's own.
*/ -}}

{{- /* agent-relay.site.get: {"found": bool, "v": value} at .path (a list of
keys) under .root. */ -}}
{{- define "agent-relay.site.get" -}}
{{- $node := .root -}}
{{- $found := true -}}
{{- range $k := .path -}}
{{- if and $found (kindIs "map" $node) (hasKey $node $k) -}}
{{- $node = index $node $k -}}
{{- else -}}
{{- $found = false -}}
{{- end -}}
{{- end -}}
{{- toJson (dict "found" $found "v" (ternary $node nil $found)) -}}
{{- end -}}

{{- /* agent-relay.site.put: sets .value at .path under .root, creating maps. */ -}}
{{- define "agent-relay.site.put" -}}
{{- $node := .root -}}
{{- range $k := initial .path -}}
{{- if not (kindIs "map" (index $node $k)) }}{{ $_ := set $node $k (dict) }}{{ end -}}
{{- $node = index $node $k -}}
{{- end -}}
{{- $_ := set $node (last .path) .value -}}
{{- end -}}

{{- /* agent-relay.site.same: "true" when .a and .b are the same value, ignoring
one trailing slash on strings (https://x/ and https://x name one origin). */ -}}
{{- define "agent-relay.site.same" -}}
{{- if and (kindIs "string" .a) (kindIs "string" .b) -}}
{{- if eq (trimSuffix "/" .a) (trimSuffix "/" .b) }}true{{ end -}}
{{- else if eq (toJson .a) (toJson .b) }}true{{ end -}}
{{- end -}}

{{- /* agent-relay.site.problem: appends one problem to .st.problems.
.where (the value's path), .value (its current value, or nil), .why, .fix.
.mirror: a mirrored subchart check, skipped when .value came from a site value
already reported (.st.bad). */ -}}
{{- define "agent-relay.site.problem" -}}
{{- if not (and .mirror (has (toString .value) (.st.bad | default (list)))) -}}
{{- $_ := set .st "problems" (append .st.problems (dict "where" .where "value" .value "why" .why "fix" .fix)) -}}
{{- end -}}
{{- end -}}

{{- /* agent-relay.site.unset: "true" when the value at .path under .root
counts as not set: missing or empty, one of .defaults (a subchart default such
as us-east-1), or what a values-*.yaml profile the chart ships has at the same
path (values-eks.yaml's placeholder.company hosts, example bucket and region).
With .pair (the path of the bucket or URL a region belongs to), a profile value
counts only while the pair is unset too: us-west-2 is a placeholder next to the
example bucket, and a real region next to a real one. */ -}}
{{- define "agent-relay.site.unset" -}}
{{- $got := include "agent-relay.site.get" (dict "root" .root "path" .path) | fromJson -}}
{{- $cur := $got.v -}}
{{- $unset := or (not $got.found) (empty $cur) -}}
{{- if not $unset -}}
{{- range $d := (.defaults | default (list)) }}{{ if include "agent-relay.site.same" (dict "a" $cur "b" $d) }}{{ $unset = true }}{{ end }}{{ end -}}
{{- end -}}
{{- if not $unset -}}
{{- $profile := false -}}
{{- range $p := .st.profiles -}}
{{- $v := include "agent-relay.site.get" (dict "root" $p "path" $.path) | fromJson -}}
{{- if and $v.found (not (empty $v.v)) (include "agent-relay.site.same" (dict "a" $cur "b" $v.v)) }}{{ $profile = true }}{{ end -}}
{{- end -}}
{{- if and $profile .pair -}}
{{- $profile = include "agent-relay.site.unset" (dict "st" .st "root" .root "path" .pair) -}}
{{- end -}}
{{- $unset = $profile -}}
{{- end -}}
{{- if $unset }}true{{ end -}}
{{- end -}}

{{- /* agent-relay.site.derive: one derived value.
.st state: problems, profiles (the chart's values-*.yaml, parsed)
.root .Values
.path list of keys under .root
.value the site-derived value (skipped when empty)
.from the site key it comes from, for messages (site.domain, ...)
.must true: the value must equal the site value (an explicit value that
differs is a contradiction); false: an explicit value wins
.defaults, .pair see agent-relay.site.unset
.clear instead of .value: empty a profile placeholder (single-host mode)
An unset value gets the site value. */ -}}
{{- define "agent-relay.site.derive" -}}
{{- if .clear -}}
{{- /* .clear: a profile placeholder here is emptied (an explicit value stays). */ -}}
{{- $got := include "agent-relay.site.get" (dict "root" .root "path" .path) | fromJson -}}
{{- if and $got.found (not (empty $got.v)) (include "agent-relay.site.unset" .) -}}
{{- include "agent-relay.site.put" (dict "root" .root "path" .path "value" "") -}}
{{- end -}}
{{- else if .value -}}
{{- if include "agent-relay.site.unset" . -}}
{{- include "agent-relay.site.put" (dict "root" .root "path" .path "value" .value) -}}
{{- else -}}
{{- $cur := (include "agent-relay.site.get" (dict "root" .root "path" .path) | fromJson).v -}}
{{- if and .must (not (include "agent-relay.site.same" (dict "a" $cur "b" .value))) -}}
{{- include "agent-relay.site.problem" (dict "st" .st "where" (join "." .path) "value" $cur
"why" (printf "contradicts %s, which sets it to %s" .from (toJson .value))
"fix" (printf "delete %s (%s sets it), or change %s so the two agree" (join "." .path) .from .from)) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- /* agent-relay.site.setGlobal: sets global.<.path> = .value in .ctx's
values and in every subchart's copy below it. */ -}}
{{- define "agent-relay.site.setGlobal" -}}
{{- if not (kindIs "map" .ctx.Values.global) }}{{ $_ := set .ctx.Values "global" (dict) }}{{ end -}}
{{- include "agent-relay.site.put" (dict "root" .ctx.Values.global "path" .path "value" .value) -}}
{{- range $name, $sub := (.ctx.Subcharts | default dict) -}}
{{- include "agent-relay.site.setGlobal" (dict "ctx" $sub "path" $.path "value" $.value) -}}
{{- end -}}
{{- end -}}

{{- /* agent-relay.site.publicHost: "" when .host is a public DNS name the
History, Control and ingest charts accept, else why not. */ -}}
{{- define "agent-relay.site.publicHost" -}}
{{- $h := toString .host -}}
{{- if not (regexMatch "^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]([a-z0-9-]{0,61}[a-z0-9])?$" $h) -}}
must be a lowercase DNS name with at least two labels (letters, digits and inner hyphens), with no scheme, port or path
{{- else if gt (len $h) 245 -}}
must be at most 245 characters (history.<domain> must fit in 253)
{{- else if regexMatch "\\.(localhost|local|internal|lan|invalid|test|example|home\\.arpa|onion)$" $h -}}
is a private or reserved name (.internal, .local, .lan, .test, .example, .localhost, .invalid, .home.arpa, .onion); the History origin, the ingest edge and Control's public URLs must be public DNS names that clients resolve, so use a name under a domain you own
{{- else if regexMatch "(^|\\.)(example\\.(com|net|org)|placeholder\\.company)$" $h -}}
is a documentation placeholder (example.com/.net/.org, placeholder.company); use your own domain
{{- end -}}
{{- end -}}

{{- /* agent-relay.site.message: the fail message for .problems. */ -}}
{{- define "agent-relay.site.message" -}}
{{- $n := len .problems -}}
agent-relay: {{ $n }} values {{ ternary "problem" "problems" (eq $n 1) }}. Nothing was installed. Fix {{ ternary "it" "all of them" (eq $n 1) }}, then run helm again
(scripts/selfhost/check-values.sh lists them without a cluster):
{{- range $i, $p := .problems }}

{{ add1 $i }}. {{ $p.where }}{{ if not (kindIs "invalid" $p.value) }} = {{ toJson $p.value }}{{ end }}
{{ $p.why }}
fix: {{ $p.fix }}
{{- end }}
{{- end -}}
Loading
Loading