Skip to content
Latest (currently 2026.10.2) has the newest features, bug fixes, and CVE patches of Solo Enterprise for agentgateway.

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

Page as Markdown

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:

  1. Install the Secrets Store CSI Driver and HashiCorp Vault, with the Vault CSI provider.
  2. Store an OpenAI API key in Vault and let the CSI driver project it onto the agentgateway controller as a file.
  3. Configure a file store that reads the mounted file, and create an EnterpriseAgentgatewayExternalSecret that materializes the key.
  4. 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

  1. Install the Solo Enterprise for agentgateway control plane by following the quick start guide.
  2. 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.

  1. 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 update
  2. Install 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.0
  3. Verify 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.

  1. Add the HashiCorp Helm repository.

    helm repo add hashicorp https://helm.releases.hashicorp.com
    helm repo update
  2. Install 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"
  3. Verify that the Vault server and the Vault CSI provider pods are running.

    kubectl -n vault get pods

    Example 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
Review the following table to understand this configuration.
CommandDescription
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 kubernetesEnable Kubernetes authentication so workloads can authenticate with their service account tokens.
vault policy write openaiGrant read access to the API key’s KV v2 data path, secret/data/openai-api-key.
vault write auth/kubernetes/role/agentgatewayBind 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: openai

Step 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
Review the following table to understand this configuration.
SettingDescription
apiVersionThe 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.vaultAddressThe in-cluster address of the Vault server.
parameters.roleNameThe Vault Kubernetes-auth role to authenticate as, created in the previous step.
parameters.objects[].objectNameThe name of the file that the provider mounts. The file store reads this file.
parameters.objects[].secretPathThe Vault KV v2 data path to read.
parameters.objects[].secretKeyThe 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.

  1. Create a storage-values.yaml file with the external secret store and the CSI volume mount. The store path must match the extraVolumeMounts mountPath, 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: true
    SettingDescription
    externalSecrets.stores[].nameThe name of the store, referenced by an EnterpriseAgentgatewayExternalSecret storeRef.name.
    externalSecrets.stores[].file.pathThe directory that the file store reads, which must match the mountPath of the CSI volume.
    controller.extraVolumesThe CSI volume that projects the Vault secret, using the SecretProviderClass from the previous step.
    controller.extraVolumeMountsMounts the CSI volume into the controller at the store’s path.
  2. 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.yaml
  3. Verify 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-secrets

    Warning

    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.

  1. Apply the following resource. It maps the openai-api-key file from the llm-secrets store to a materialized credential under the Authorization key.

    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
    EOF
    SettingDescription
    storeRef.nameThe store to read from, matching a name in externalSecrets.stores.
    refreshIntervalHow often to refresh the credential. Optional, minimum 15m, defaults to 1h. 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 Authorization key.
    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-key file, which is materialized as raw bytes because property is omitted.
  2. Verify that the external secret is accepted. The Accepted condition reports True when the spec resolves against the store and the referenced files.

    kubectl -n agentgateway-system get enterpriseagentgatewayexternalsecret openai-external-secret -o yaml

    Example 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: 1

    Note

    If the Accepted condition reports False with reason StoreValidationFailed, check that the storeRef.name matches a store in your Helm values. If it reports ReferencedObjectNotFound, 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.

  1. Create an AgentgatewayBackend for OpenAI. The auth.secretRef points at the EnterpriseAgentgatewayExternalSecret by group and kind, so the credential resolver returns the materialized Authorization value.

    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
    EOF
    SettingDescription
    ai.groups[].providers[].openaiDefines the OpenAI provider and the model to use.
    policies.auth.secretRef.group and kindIdentify the credential as an EnterpriseAgentgatewayExternalSecret instead of the default Kubernetes Secret.
    policies.auth.secretRef.nameThe name of the EnterpriseAgentgatewayExternalSecret to read the API key from.
  2. Create an HTTPRoute that routes the /openai path 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.

  1. Get the external address of the gateway and save the /openai endpoint in the OPENAI_URL environment 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_URL
    1. Open a port-forward in a separate terminal.

      kubectl port-forward -n agentgateway-system svc/agentgateway-proxy 8080:80
    2. Then set the endpoint variable.

      export OPENAI_URL="http://localhost:8080/openai"
  2. Send a chat completion request to the /openai route.

    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.
  1. 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-vault
  2. Uninstall Vault and the CSI driver.

    helm uninstall vault -n vault
    helm uninstall secrets-store-csi-driver -n csi-secrets-store
  3. To remove the store, delete the externalSecrets and controller.extraVolumes sections from your storage-values.yaml file and run the helm upgrade command 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