Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

feat(helm): turn agent management on from the chart's values (#674)

Louis Amaudruzd046b4aee65c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ce0e8cf60..a083c9497 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,6 +44,17 @@ version of their own to them without also giving them a release of their own.
### [Unreleased]
+#### Added
+- **The Helm chart turns agent management on from its values.**
+ `switchCore.agentManagement.enabled` and `secrets.controllerTokenSecret` (or
+ `CONTROLLER_TOKEN_SECRET` in `secrets.existingSecret`) set
+ `AGENT_MANAGEMENT_ENABLED`, `CONTROLLER_TOKEN_SECRET` and
+ `CONTROLLER_STATUS_INTERVAL_SECONDS` on switch-core and its migration Job. Until
+ now they had to be added with `kubectl set env` after each upgrade, rolling the
+ pods twice. Rendering fails when the secret is missing or shorter than 32
+ characters. Remove variables set by hand before the first upgrade that renders
+ them (see the chart README).
+
#### Fixed
- **The Helm chart's Ingress now routes every agent API path to switch-core.**
`/agent-sessions` (session starts, turn activity, approval requests and their
diff --git a/deploy/remote/helm/switch/README.md b/deploy/remote/helm/switch/README.md
index 16b846299..6e484a0a3 100644
--- a/deploy/remote/helm/switch/README.md
+++ b/deploy/remote/helm/switch/README.md
@@ -184,3 +184,27 @@ required keys are listed above the `secrets:` block in `values.yaml`.
Bridge credentials are **not** among them. Those are entered in the gateway and
stored in the database.
+
+## Agent management
+
+Managed agents, and the agent controllers that run them on users' machines, are
+off by default. To turn them on:
+
+```yaml
+switchCore:
+ agentManagement:
+ enabled: true
+secrets:
+ controllerTokenSecret: "<openssl rand -hex 32>"
+```
+
+With `secrets.existingSecret`, put the token secret in that Secret as
+`CONTROLLER_TOKEN_SECRET` instead. The chart sets `AGENT_MANAGEMENT_ENABLED`,
+`CONTROLLER_TOKEN_SECRET` and `CONTROLLER_STATUS_INTERVAL_SECONDS` on switch-core
+and its migration Job, so enabling it is one rollout. Controllers enroll and
+connect under `/v1`, which `ingress.agentApiPaths` routes to switch-core by default.
+
+A deployment that set these variables with `kubectl set env` should remove them
+before the first upgrade that renders them (`kubectl set env deployment/<release>-switch-core
+AGENT_MANAGEMENT_ENABLED- CONTROLLER_TOKEN_SECRET-`). Otherwise Helm merges its
+`valueFrom` into the live `value` and the API server rejects the Deployment.
diff --git a/deploy/remote/helm/switch/templates/_helpers.tpl b/deploy/remote/helm/switch/templates/_helpers.tpl
index 31e91434f..b0509a837 100644
--- a/deploy/remote/helm/switch/templates/_helpers.tpl
+++ b/deploy/remote/helm/switch/templates/_helpers.tpl
@@ -59,6 +59,13 @@ SECRET_KEYS: {{ required "secrets.secretKeys is required (\"<id>:<secret>\", see
{{- with .Values.secrets.jwtSecretKey }}
JWT_SECRET_KEY: {{ . | b64enc | quote }}
{{- end }}
+{{- if .Values.switchCore.agentManagement.enabled }}
+{{- $controllerSecret := required "secrets.controllerTokenSecret is required when switchCore.agentManagement.enabled" .Values.secrets.controllerTokenSecret }}
+{{- if lt (len $controllerSecret) 32 }}
+{{- fail "secrets.controllerTokenSecret must be at least 32 characters; switch-core refuses to start with a shorter one." }}
+{{- end }}
+CONTROLLER_TOKEN_SECRET: {{ $controllerSecret | b64enc | quote }}
+{{- end }}
GATEWAY_ADMIN_EMAIL: {{ required "secrets.gatewayAdminEmail is required" .Values.secrets.gatewayAdminEmail | b64enc | quote }}
GATEWAY_ADMIN_PASSWORD: {{ required "secrets.gatewayAdminPassword is required" .Values.secrets.gatewayAdminPassword | b64enc | quote }}
{{- if .Values.mattermost.enabled }}
@@ -636,6 +643,19 @@ this one. Drop it once the oldest supported image reads ID_SERVER_NAME. */}}
name: {{ include "switch.secretName" . }}
key: JWT_SECRET_KEY
optional: true
+{{- with .Values.switchCore.agentManagement }}
+{{- if .enabled }}
+- name: AGENT_MANAGEMENT_ENABLED
+ value: "true"
+- name: CONTROLLER_TOKEN_SECRET
+ valueFrom:
+ secretKeyRef:
+ name: {{ include "switch.secretName" $ }}
+ key: CONTROLLER_TOKEN_SECRET
+- name: CONTROLLER_STATUS_INTERVAL_SECONDS
+ value: {{ .statusIntervalSeconds | quote }}
+{{- end }}
+{{- end }}
- name: GATEWAY_ADMIN_EMAIL
valueFrom:
secretKeyRef:
diff --git a/deploy/remote/helm/switch/values.yaml b/deploy/remote/helm/switch/values.yaml
index 13e25716c..a4771e6b8 100644
--- a/deploy/remote/helm/switch/values.yaml
+++ b/deploy/remote/helm/switch/values.yaml
@@ -94,6 +94,7 @@ ingress:
# AGENT_REGISTRATION_TOKEN, SECRET_KEYS, GATEWAY_ADMIN_EMAIL,
# GATEWAY_ADMIN_PASSWORD,
# JWT_SECRET_KEY (optional, legacy — see secrets.jwtSecretKey),
+# CONTROLLER_TOKEN_SECRET (if switchCore.agentManagement.enabled),
# MATTERMOST_ADMIN_PASSWORD + MATTERMOST_USER_PASSWORD (if mattermost.enabled),
# GATEWAY_OIDC_CLIENT_SECRET (if switchCore.oidc.enabled).
secrets:
@@ -124,6 +125,11 @@ secrets:
gatewayAdminPassword: ""
mattermostAdminPassword: ""
mattermostUserPassword: ""
+ # Signs agent controllers' access tokens (required when
+ # switchCore.agentManagement.enabled), at least 32 characters. Kept apart from
+ # secretKeys so rotating either never invalidates the other. Generate one
+ # with: openssl rand -hex 32
+ controllerTokenSecret: ""
# Gateway OIDC client secret (required when switchCore.oidc.enabled).
gatewayOidcClientSecret: ""
# SMTP relay password for invitation e-mails (required when
@@ -283,6 +289,15 @@ switchCore:
# lists them, rather than a 403. The gateway UI does not need it; turn it on
# once every API client authenticating against this deployment handles it.
tenantChoiceEnabled: false
+ # Agent management: managed agents, and the agent controllers (Switch Console,
+ # or switch-agent-controller on a user's own machine) that run them. Needs
+ # secrets.controllerTokenSecret, and `/v1` routed to switch-core
+ # (ingress.agentApiPaths does by default).
+ agentManagement:
+ enabled: false
+ # How often a controller must report; one silent for three of these is
+ # shown as unknown and gets no new placements.
+ statusIntervalSeconds: 60
# Private hosts switch-core may reach at a URL a tenant or agent supplied —
# a Mattermost server, an OpenCode server, an agent icon. Hostnames or CIDRs.
# Anything else that is not a public address is refused, and link-local and