For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
File store with the CSI driver
Read an LLM provider API key from HashiCorp Vault through a file store backed by the Kubernetes Secrets Store CSI Driver.
Read an LLM provider API key from HashiCorp Vault through a file store that is backed by the Kubernetes Secrets Store CSI Driver, so that the key is never stored as a Kubernetes Secret.
About
In this guide, you set up a complete, hands-on example of the external secret file store:
- Install the Secrets Store CSI Driver and HashiCorp Vault, with the Vault CSI provider.
- Store an OpenAI API key in Vault and let the CSI driver project it onto the agentgateway controller as a file.
- Configure a file store that reads the mounted file, and create an
EnterpriseAgentgatewayExternalSecretthat materializes the key. - Reference the materialized key from an LLM provider backend, then send a request that authenticates to OpenAI.
When a request reaches the backend, Solo Enterprise for agentgateway authenticates to OpenAI by using the materialized key, without ever reading a Kubernetes Secret. For more information about how external secrets work, see the External secrets concept.
Before you begin
- Install the Solo Enterprise for agentgateway control plane by following the quick start guide.
Have an OpenAI API key available, and save it in an environment variable.
export OPENAI_API_KEY=<your-openai-api-key>
Step 1: Install the Secrets Store CSI Driver
Install the Secrets Store CSI Driver, which mounts external secrets as files in pods.
Add the Secrets Store CSI Driver Helm repository.
helm repo add secrets-store-csi-driver https://kubernetes-sigs.github.io/secrets-store-csi-driver/charts helm repo updateInstall the driver.
helm upgrade -i secrets-store-csi-driver secrets-store-csi-driver/secrets-store-csi-driver \ -n csi-secrets-store \ --create-namespace \ --version 1.6.0Verify that the driver pods are running.
kubectl -n csi-secrets-store get pods -l app.kubernetes.io/name=secrets-store-csi-driver
Step 2: Install HashiCorp Vault
Install HashiCorp Vault in development mode, along with the Vault CSI provider that bridges Vault secrets to the CSI driver. For more information, see the HashiCorp Vault docs.
Warning
Development mode runs an in-memory, unsealed Vault server with a hardcoded root token. Use it for demos only, not in production.
Add the HashiCorp Helm repository.
helm repo add hashicorp https://helm.releases.hashicorp.com helm repo updateInstall Vault with the development server and the Vault CSI provider enabled.
helm upgrade -i vault hashicorp/vault \ -n vault \ --create-namespace \ --version 0.33.0 \ --set "server.dev.enabled=true" \ --set "server.dev.devRootToken=root" \ --set "injector.enabled=false" \ --set "csi.enabled=true"Verify that the Vault server and the Vault CSI provider pods are running.
kubectl -n vault get podsExample output:
NAME READY STATUS RESTARTS AGE vault-0 1/1 Running 0 1m vault-csi-provider-abcde 2/2 Running 0 1m
Step 3: Store the API key in Vault
Store your OpenAI API key in Vault, then configure Kubernetes authentication so that the agentgateway controller can read it.
Store the API key, enable Kubernetes authentication, and create a policy and role that let the controller’s service account read the key. The role binds to the enterprise-agentgateway service account in the agentgateway-system namespace.
kubectl -n vault exec -i vault-0 -- sh <<EOF
export VAULT_TOKEN=root
vault kv put secret/openai-api-key api-key="$OPENAI_API_KEY"
vault auth enable kubernetes 2>/dev/null || true
vault write auth/kubernetes/config kubernetes_host="https://\$KUBERNETES_PORT_443_TCP_ADDR:443"
vault policy write openai - <<'POLICY'
path "secret/data/openai-api-key" { capabilities = ["read"] }
POLICY
vault write auth/kubernetes/role/agentgateway \
bound_service_account_names=enterprise-agentgateway \
bound_service_account_namespaces=agentgateway-system \
policies=openai ttl=20m
EOF| Command | Description |
|---|---|
vault kv put secret/openai-api-key api-key=... | Store the API key under the api-key field of the secret/openai-api-key KV path. |
vault auth enable kubernetes | Enable Kubernetes authentication so workloads can authenticate with their service account tokens. |
vault policy write openai | Grant read access to the API key’s KV v2 data path, secret/data/openai-api-key. |
vault write auth/kubernetes/role/agentgateway | Bind the policy to the controller’s service account in your installation namespace. |
Example output:
======= Secret Path =======
secret/data/openai-api-key
======= Metadata =======
Key Value
--- -----
created_time 2026-06-29T16:41:18.729027376Z
custom_metadata <nil>
deletion_time n/a
destroyed false
version 2
Success! Data written to: auth/kubernetes/config
Success! Uploaded policy: openaiStep 4: Create a SecretProviderClass
Create a SecretProviderClass that tells the Vault CSI provider which secret to mount and as what file name. Apply it into your installation namespace before you mount the volume in the next step, because the controller’s CSI volume prevents the pod from starting until this object exists.
kubectl apply -f- <<EOF
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: openai-vault
namespace: agentgateway-system
spec:
provider: vault
parameters:
vaultAddress: "http://vault.vault.svc:8200"
roleName: "agentgateway"
objects: |
- objectName: "openai-api-key"
secretPath: "secret/data/openai-api-key"
secretKey: "api-key"
EOF| Setting | Description |
|---|---|
apiVersion | The API group and version of the SecretProviderClass custom resource. Note that here in the CR, the API group is secrets-store.csi.x-k8s.io. In the CSI driver name that you reference in the volume’s csi.driver field, the name is secrets-store.csi.k8s.io. The names look similar, but are not the same. |
parameters.vaultAddress | The in-cluster address of the Vault server. |
parameters.roleName | The Vault Kubernetes-auth role to authenticate as, created in the previous step. |
parameters.objects[].objectName | The name of the file that the provider mounts. The file store reads this file. |
parameters.objects[].secretPath | The Vault KV v2 data path to read. |
parameters.objects[].secretKey | The field within the Vault secret to read. |
Step 5: Configure a file store
Define an installation-global file store in the enterprise-agentgateway Helm values, and mount the CSI volume that projects the Vault secret onto the controller pod.
Create a
storage-values.yamlfile with the external secret store and the CSI volume mount. The storepathmust match theextraVolumeMountsmountPath, and both must be under the fixed files root/var/run/secrets/agentgateway-external-secrets.externalSecrets: # Installation-global stores referenced by EnterpriseAgentgatewayExternalSecret storeRef.name. stores: - name: llm-secrets file: path: /var/run/secrets/agentgateway-external-secrets/llm controller: # Mount the CSI volume that projects the Vault secret as a file. extraVolumes: - name: llm-secrets csi: driver: secrets-store.csi.k8s.io readOnly: true volumeAttributes: secretProviderClass: openai-vault extraVolumeMounts: - name: llm-secrets mountPath: /var/run/secrets/agentgateway-external-secrets/llm readOnly: trueSetting Description externalSecrets.stores[].nameThe name of the store, referenced by an EnterpriseAgentgatewayExternalSecretstoreRef.name.externalSecrets.stores[].file.pathThe directory that the file store reads, which must match the mountPathof the CSI volume.controller.extraVolumesThe CSI volume that projects the Vault secret, using the SecretProviderClassfrom the previous step.controller.extraVolumeMountsMounts the CSI volume into the controller at the store’s path.Upgrade your Solo Enterprise for agentgateway installation with the storage values file.
helm upgrade -i enterprise-agentgateway oci://us-docker.pkg.dev/solo-public/enterprise-agentgateway/charts/enterprise-agentgateway \ -n agentgateway-system \ --version v2026.10.2 \ --reuse-values \ -f storage-values.yamlVerify that the controller rolls out successfully and that the store configuration is rendered into the config ConfigMap.
kubectl -n agentgateway-system rollout status deploy/enterprise-agentgateway kubectl -n agentgateway-system get configmap enterprise-agentgateway-config -o jsonpath='{.data.stores\.yaml}'Example output:
stores: - file: path: /var/run/secrets/agentgateway-external-secrets/llm name: llm-secretsWarning
A missing or invalid stores file fails controller startup. While a bad configuration blocks the rollout, the existing pods keep serving traffic.
Step 6: Create an external secret
Create an EnterpriseAgentgatewayExternalSecret that materializes the OpenAI API key from the file store.
Apply the following resource. It maps the
openai-api-keyfile from thellm-secretsstore to a materialized credential under theAuthorizationkey.kubectl apply -f- <<EOF apiVersion: enterpriseagentgateway.solo.io/v1alpha1 kind: EnterpriseAgentgatewayExternalSecret metadata: name: openai-external-secret namespace: agentgateway-system spec: storeRef: name: llm-secrets refreshInterval: 1h data: - materializedKey: Authorization remoteRef: key: openai-api-key EOFSetting Description storeRef.nameThe store to read from, matching a nameinexternalSecrets.stores.refreshIntervalHow often to refresh the credential. Optional, minimum 15m, defaults to1h. For file stores, agentgateway also re-materializes immediately when the mounted files change.data[].materializedKeyThe data key that backends and policies read. The LLM provider’s API key authentication reads the token from the Authorizationkey.data[].remoteRef.keyThe provider object to read. For a file store, this is a path relative to the store root. Here, it names the openai-api-keyfile, which is materialized as raw bytes becausepropertyis omitted.Verify that the external secret is accepted. The
Acceptedcondition reportsTruewhen the spec resolves against the store and the referenced files.kubectl -n agentgateway-system get enterpriseagentgatewayexternalsecret openai-external-secret -o yamlExample output:
status: conditions: - lastTransitionTime: "2026-06-24T14:21:24Z" message: external secret spec, store, and referenced provider object(s) resolved observedGeneration: 1 reason: Accepted status: "True" type: Accepted observedGeneration: 1Note
If the
Acceptedcondition reportsFalsewith reasonStoreValidationFailed, check that thestoreRef.namematches a store in your Helm values. If it reportsReferencedObjectNotFound, check that the file exists at the store path on the controller pod.
Step 7: Reference the external secret from a backend
Create an LLM provider backend that reads its API key from the external secret instead of a Kubernetes Secret.
Create an
AgentgatewayBackendfor OpenAI. Theauth.secretRefpoints at theEnterpriseAgentgatewayExternalSecretbygroupandkind, so the credential resolver returns the materializedAuthorizationvalue.kubectl apply -f- <<EOF apiVersion: agentgateway.dev/v1alpha1 kind: AgentgatewayBackend metadata: name: openai namespace: agentgateway-system spec: ai: groups: - providers: - name: openai openai: model: gpt-3.5-turbo policies: auth: secretRef: group: enterpriseagentgateway.solo.io kind: EnterpriseAgentgatewayExternalSecret name: openai-external-secret EOFSetting Description ai.groups[].providers[].openaiDefines the OpenAI provider and the model to use. policies.auth.secretRef.groupandkindIdentify the credential as an EnterpriseAgentgatewayExternalSecretinstead of the default KubernetesSecret.policies.auth.secretRef.nameThe name of the EnterpriseAgentgatewayExternalSecretto read the API key from.Create an HTTPRoute that routes the
/openaipath to the backend.kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: openai namespace: agentgateway-system spec: parentRefs: - name: agentgateway-proxy namespace: agentgateway-system rules: - matches: - path: type: PathPrefix value: /openai backendRefs: - name: openai namespace: agentgateway-system group: agentgateway.dev kind: AgentgatewayBackend EOF
Step 8: Verify the external secret
Send a request through the gateway and confirm that Solo Enterprise for agentgateway authenticates to OpenAI by using the materialized key.
Get the external address of the gateway and save the
/openaiendpoint in theOPENAI_URLenvironment variable. The request in the next step reuses this variable, so it works for both connection types.export INGRESS_GW_ADDRESS=$(kubectl get svc -n agentgateway-system agentgateway-proxy -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}") echo $INGRESS_GW_ADDRESS export OPENAI_URL="http://${INGRESS_GW_ADDRESS}/openai" echo $OPENAI_URLOpen a port-forward in a separate terminal.
kubectl port-forward -n agentgateway-system svc/agentgateway-proxy 8080:80Then set the endpoint variable.
export OPENAI_URL="http://localhost:8080/openai"
Send a chat completion request to the
/openairoute.curl "$OPENAI_URL" -H content-type:application/json -d '{ "model": "", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Say hello in exactly three words."} ] }'Verify that you get back a successful chat completion response. The request succeeded because agentgateway authenticated to OpenAI with the API key that was materialized from the Vault-backed file store.
{ "model": "gpt-3.5-turbo-0125", "choices": [ { "message": { "role": "assistant", "content": "Greetings, friend!" }, "index": 0, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 24, "completion_tokens": 4, "total_tokens": 28 }, "object": "chat.completion" }
Cleanup
You can optionally remove the resources that you set up as part of this guide.Delete the routing and secret resources.
kubectl -n agentgateway-system delete httproute openai kubectl -n agentgateway-system delete agentgatewaybackend openai kubectl -n agentgateway-system delete enterpriseagentgatewayexternalsecret openai-external-secret kubectl -n agentgateway-system delete secretproviderclass openai-vaultUninstall Vault and the CSI driver.
helm uninstall vault -n vault helm uninstall secrets-store-csi-driver -n csi-secrets-storeTo remove the store, delete the
externalSecretsandcontroller.extraVolumessections from yourstorage-values.yamlfile and run thehelm upgradecommand again.helm upgrade -i enterprise-agentgateway oci://us-docker.pkg.dev/solo-public/enterprise-agentgateway/charts/enterprise-agentgateway \ -n agentgateway-system \ --version v2026.10.2 \ --reuse-values \ -f storage-values.yaml