Secret managers
Last updated: 2026-11-27T14:42:00-03:00 (UTC-3)
The gateway reads every credential by name: database URL, token hashes, session and encryption keys, provider keys. By default the name is an environment variable. A secret manager lets those values live in your vault instead, so the gateway’s own environment holds only the credential it uses to reach the vault.
Each credential is resolved in this order:
- The environment variable itself.
<NAME>_FILE: a mounted file, with thesecret_filesflag. This covers Kubernetes and Docker secrets and the Vault Agent.- The secret manager: with the
secret_managerflag, for the names insecret_manager.names.
Supported managers
Section titled “Supported managers”The secret_manager block picks its store with kind:
kind |
Store | Gateway credential |
|---|---|---|
hashicorp_vault |
KV v2 | auth: approle (role_id_env, secret_id_env) or auth: token (token_env) |
cyberark_conjur |
Conjur variables | account, login, api_key_env |
aws_secrets_manager |
AWS Secrets Manager (region required) |
credential (see below), or profile |
gcp_secret_manager |
Google Secret Manager (project required) |
credential (see below) |
azure_key_vault |
Azure Key Vault (address is https://<name>.vault.azure.net) |
credential (see below) |
CyberArk Conjur takes three keys of its own:
| Key | What it does |
|---|---|
secret_manager.account |
The Conjur account (organization) the variables belong to |
secret_manager.login |
The host or user identity the gateway authenticates as, such as host/gateway |
secret_manager.api_key_env |
Variable holding that identity’s Conjur API key |
| Key | What it does |
|---|---|
secret_manager.region |
AWS region of the Secrets Manager store (required for aws_secrets_manager) |
secret_manager.profile |
AWS shared-configuration profile the gateway’s identity comes from, instead of credential |
secret_manager.project |
Google Cloud project of the Secret Manager store (required for gcp_secret_manager) |
secret_manager.credential |
Where the gateway’s own cloud identity comes from (below) |
For the three cloud stores, credential picks where the gateway’s own identity comes from: auto (the default chain), env, web_identity, container, cli, client_secret, workload_identity or managed_identity. That identity is never read from the store itself. field picks one key from a JSON secret.
HashiCorp Vault
Section titled “HashiCorp Vault”This example was run end to end on 2026-11-07 with the Quickstart stack and Vault 2.2.1, with TLS and AppRole:
features: secret_manager: truesecret_manager: kind: hashicorp_vault address: https://vault:8200 # https; http only on loopback with allow_insecure_http ca_file: /var/run/gateway/vault-ca.pem # your private CA, if Vault's certificate is not public auth: approle role_id_env: VAULT_ROLE_ID secret_id_env: VAULT_SECRET_ID mount: secret # the KV v2 mount (default secret) path_prefix: gateway # read secret/data/gateway/<NAME> field: key # the field holding the value (default key) refresh_seconds: 60 # 10 to 86400 names: [GATEWAY_DATABASE_URL, GATEWAY_UI_ADMIN_SHA256, GATEWAY_UI_VIEWER_SHA256, GATEWAY_UI_SESSION_KEY, GATEWAY_PROVIDER_ENCRYPTION_KEY, GATEWAY_CLIENT_KEY_SHA256, OPENAI_API_KEY]| Key | Default | What it does |
|---|---|---|
secret_manager.address |
required | Vault’s address; HTTPS |
secret_manager.ca_file |
system roots | PEM file of the CA that signed Vault’s certificate |
secret_manager.allow_insecure_http |
false |
Allows http:// to a loopback address, for local testing only |
secret_manager.auth |
required | approle or token |
secret_manager.role_id_env |
required with approle |
Variable holding the AppRole role ID |
secret_manager.secret_id_env |
required with approle |
Variable holding the AppRole secret ID |
secret_manager.approle_mount |
approle |
Mount path of the AppRole auth method, one plain path segment |
secret_manager.token_env |
required with token |
Variable holding a Vault token, for auth: token |
secret_manager.mount |
secret |
The KV v2 mount, one plain path segment |
secret_manager.namespace |
empty | Vault Enterprise namespace the reads and the login go to |
secret_manager.path_prefix |
empty | Folder under the mount where each name is a secret |
secret_manager.field |
key |
Field of the secret that holds the value |
secret_manager.refresh_seconds |
300 |
How often each name is read again, 10–86400 |
secret_manager.names |
required | The variable names the manager supplies; any other name keeps coming from the environment |
The manager’s own login material (role_id_env, secret_id_env, token_env, api_key_env) is always read from the environment: a manager cannot hold the key that opens it.
Store one secret per name, with the value in key, and give the AppRole a read-only policy on that path:
vault kv put -mount=secret gateway/OPENAI_API_KEY key=- # value from stdin, never on the command lineprintf 'path "secret/data/gateway/*" { capabilities = ["read"] }' | vault policy write gateway-read -vault auth enable approlevault write auth/approle/role/gateway token_policies=gateway-read token_ttl=10mvault read -field=role_id auth/approle/role/gateway/role-idvault write -f -field=secret_id auth/approle/role/gateway/secret-idThe gateway’s environment then needs only VAULT_ROLE_ID and VAULT_SECRET_ID, in the Compose env file or the Kubernetes Secret. With Compose, mount the CA next to the configuration; with Helm, use gateway.existingTrustSecret, which mounts files at /var/run/gateway/trust.
The gateway logs in again by itself when its token expires.
Several values in one secret
Section titled “Several values in one secret”When the store already keeps several values in one secret, paths points each name at a path#field, instead of one secret per name:
secret_manager: kind: hashicorp_vault # ... address and auth as above paths: OPENAI_API_KEY: "app#openai_token" # field openai_token of secret/data/app GEMINI_API_KEY: "app#gemini_token" # same secret, another field GATEWAY_DATABASE_URL: "shared/db" # no #field: the field setting (default key)- Path: taken as written, without
path_prefix. It follows each store’s naming: slash paths for Vault and Conjur, a secret name or full ARN for AWS, a bare secret ID for Google, a secret name (letters, digits and dashes) for Azure. In Vault it is relative to the mount, asvault kv get -mount=secret apptakes it: writeapp, notsecret/data/app, which would read/v1/secret/data/secret/data/appand reportnot_found. - Field: a key of the secret’s data (Vault) or of its JSON value (AWS, Google, Azure). A Conjur variable holds a single value, so it takes no
#field. - Names: every name in
pathsis allowed, even whennameslists others; names outside both keep the per-name layout. Settings & sources → Secret manager and the startup error show each name’spath#field. - Reads: each name is cached and refreshed on its own, so two names on one path are two reads per refresh interval. Rotating one field applies to that name only. Measured on 2026-11-08 with Vault and real OpenAI and Gemini keys in one secret: both providers answered; a rotated OpenAI field was refused 12 s later (
refresh_seconds: 10) while Gemini kept answering.
On a multi-node Kubernetes cluster
Section titled “On a multi-node Kubernetes cluster”Run on 2026-11-20 (T176) on GKE 1.36.4, three replicas in three zones, with Vault 2.2.1 in the cluster in server mode (official chart 0.34.1, integrated storage on a persistent volume, TLS from a private CA mounted through gateway.existingTrustSecret, AppRole). Every credential the gateway reads came from Vault: the admin and viewer token digests, the session and provider encryption keys, the client key digest and 16 provider keys; the Kubernetes Secret held only the database URL and password and the AppRole VAULT_ROLE_ID/VAULT_SECRET_ID. With refresh_seconds: 10:
- Client key digest rotated in Vault: the new token was accepted by the three replicas after 11.6, 13.0 and 14.4 s, and the old one refused; no restart.
- A provider key replaced by an invalid value, then restored: every replica returned the provider’s 401 within 6–7 s, then 200 again within 6–10 s.
- Vault Pod restarted: it came back sealed with its data (Raft), the replicas kept answering 200 with their last good values and logged
secret_refresh_failed(error_class: unreachable,serving_last_good_value: true) once; after the unseal the refresh recovered. - A refresh is lazy. A value is fetched again on its first use after
refresh_seconds, in the background, and that first request still uses the cached value. After a quiet period longer than the interval, a rotated credential is therefore honored from the second use on; send any request (or use Fetch all now) right after a rotation to make it apply at once.
Behavior
Section titled “Behavior”- Startup: the first read of each name waits for the manager. When a required credential cannot be read, the gateway does not start, and the error names the manager and the cause, for example
secret manager hashicorp_vault at https://vault:8200 could not provide GATEWAY_UI_ADMIN_SHA256 (timeout). With Compose’srestartpolicy or Kubernetes, it starts as soon as the manager answers. - Refresh: a value older than
refresh_secondsis fetched again in the background on its next use. Requests never wait for the manager after the first read. To apply a rotation immediately, use Fetch all now in Settings & sources → Secret manager, orPOST /api/v1/admin/secret-manager/refresh. - Rotation: a rotated value applies without a restart. That includes the client key digests of the YAML (
sha256_env); measured, a digest rotated in Vault was honored within one refresh interval, and the old token was refused. - Outage: a value that cannot be refreshed keeps its last good value, so requests keep working. Measured, every call returned 200 with Vault paused. A name never read successfully resolves to nothing, and its feature fails closed.
Watching it
Section titled “Watching it”| Signal | What it says |
|---|---|
Log secret_refresh_failed (Warn) |
A name’s refresh started failing: name, kind, error_class (timeout, unreachable, denied, unavailable, not_found, …) and serving_last_good_value. Logged once per outage, not per retry |
Log secret_refresh_recovered (Info) |
The name refreshed again |
gateway_secret_manager_failing_secrets |
How many names currently fail to refresh; alert when it stays above 0 |
gateway_secret_manager_secrets |
How many names the gateway has read |
| Settings & sources → Secret manager | Each name with its last fetch, last failure and error class |
No value, token, role ID or secret ID appears in logs, metrics, telemetry or API answers; the status shows names and times only.
Deploying with Argo CD
Section titled “Deploying with Argo CD”With Argo CD, Vault values reach the gateway in one of two ways, and the two combine:
| argocd-vault-plugin | secret_manager |
|
|---|---|---|
| Who reads Vault | Argo CD’s repo server, when it renders the manifests | The gateway, while it runs |
| What the cluster holds | A Kubernetes Secret with the values | Only the gateway’s Vault credential |
| A rotated value | Reaches the Secret only after a hard refresh and a sync: the repo server caches rendered manifests per commit, so a normal refresh does not run the plugin again. Pods read the Secret at start, so restart them | Applies about refresh_seconds after the rotation, on the next use, with no sync and no restart |
Both were run end to end on 2026-11-07 with Argo CD v3.5.7, argocd-vault-plugin v1.18.1 and Vault 2.2.1. Measured:
- Plugin path: a rotated value reached the Secret 7 seconds after a hard refresh. The running Pods kept the old value until
kubectl rollout restart. secret_managerpath: a rotated provider key applied in 10 to 13 seconds withrefresh_seconds: 10, with no restart.
No value appeared in the Application, the events or the Argo CD logs.
The placeholders
Section titled “The placeholders”The gateway’s YAML never holds a credential: it names variables (api_key_env, sha256_env, database_url_env). The placeholders therefore go in the Secret those variables come from, not in config/gateway.yaml. One Vault secret can hold every field:
apiVersion: v1kind: Secretmetadata: {name: gateway-secrets}type: OpaquestringData: GATEWAY_DATABASE_URL: <path:secret/data/gateway#GATEWAY_DATABASE_URL> GATEWAY_DATABASE_PASSWORD: <path:secret/data/gateway#GATEWAY_DATABASE_PASSWORD> GATEWAY_UI_ADMIN_SHA256: <path:secret/data/gateway#GATEWAY_UI_ADMIN_SHA256> GATEWAY_UI_VIEWER_SHA256: <path:secret/data/gateway#GATEWAY_UI_VIEWER_SHA256> GATEWAY_UI_SESSION_KEY: <path:secret/data/gateway#GATEWAY_UI_SESSION_KEY> GATEWAY_PROVIDER_ENCRYPTION_KEY: <path:secret/data/gateway#GATEWAY_PROVIDER_ENCRYPTION_KEY> GATEWAY_CLIENT_KEY_SHA256: <path:secret/data/gateway#GATEWAY_CLIENT_KEY_SHA256> OPENAI_API_KEY: <path:secret/data/gateway#OPENAI_API_KEY>With the chart’s bundled analytics store (analyticsStore.bundled.enabled), add GATEWAY_ANALYTICS_STORE_PASSWORD the same way. Up to 0.0.1-rc.2 the two password fields were GATEWAY_POSTGRES_PASSWORD and GATEWAY_CLICKHOUSE_PASSWORD: when upgrading, add the new fields to the Vault secret with the same values and map them here, keep the old fields until a rollback is no longer possible, and do not patch the Kubernetes Secret directly, since the plugin (or an operator such as External Secrets) rewrites it at its next sync (upgrading from 0.0.1-rc.2).
A file such as a CA certificate goes in data with the plugin’s base64encode modifier: vault-ca.pem: <path:secret/data/gateway#VAULT_CA | base64encode>. The chart mounts gateway.existingTrustSecret at /var/run/gateway/trust, so secret_manager.ca_file is then /var/run/gateway/trust/vault-ca.pem. The Kustomize base has no such mount; add one in your overlay.
Kustomize
Section titled “Kustomize”Run the plugin as a config management plugin sidecar of the repo server that pipes Kustomize into it. The sidecar authenticates to Vault with the plugin’s AVP_* variables (for AppRole: AVP_TYPE=vault, AVP_AUTH_TYPE=approle, AVP_ROLE_ID, AVP_SECRET_ID, plus VAULT_ADDR), from a Secret given to the sidecar with envFrom; give that role read access to the gateway’s secret only.
apiVersion: argoproj.io/v1alpha1kind: ConfigManagementPluginmetadata: {name: argocd-vault-plugin-kustomize}spec: discover: find: command: [sh, -c, "find . -name kustomization.yaml"] generate: command: [sh, -c, "kustomize build . | argocd-vault-plugin generate -"]Your environment’s kustomization.yaml lists this repository’s root and the Secret file. Apply deploy/base/namespace.yaml first, or let Argo CD create the namespace (CreateNamespace=true).
The chart holds no credential either: it reads gateway.existingSecret, and files from gateway.existingTrustSecret. Let Argo CD render the chart with its own Helm, and pass only the Secrets through the plugin, in one multi-source Application:
spec: sources: - repoURL: <your repository> path: deploy/helm/gateway helm: releaseName: ai-gateway valueFiles: [$repo/envs/production/values.yaml] - repoURL: <your repository> ref: repo - repoURL: <your repository> path: envs/production # kustomization.yaml listing secret.yaml plugin: {name: argocd-vault-plugin-kustomize} syncPolicy: automated: {prune: true, selfHeal: true} syncOptions: [CreateNamespace=true, ServerSideApply=true]Both together
Section titled “Both together”The plugin can deliver what the gateway needs to start, such as the database URL and the AppRole VAULT_ROLE_ID/VAULT_SECRET_ID. secret_manager then reads the keys you rotate often, such as OPENAI_API_KEY, which then never appears in a Kubernetes Secret. Leave those names out of the Secret, unlike the full example above: a non-empty variable wins over the manager.
Admin API routes
Section titled “Admin API routes”Every route below needs a console session or an admin Bearer token, the role’s permission and, for writes, the X-CSRF-Token header; the full contract is in the API reference.
| Route | What it does |
|---|---|
GET /api/v1/admin/secret-manager |
The manager’s status: kind, address, refresh period, the selectors the kind uses under their YAML names (names, paths, mount, namespace, field, auth, approle_mount, account, login, region, profile, project, credential; names was allowlist) and the state of each name it supplies, never a value, an environment variable name or ca_file. Settings & sources → Secret manager shows them read-only |