Vault Agent is a client-side daemon that automates authentication, token renewal, secret retrieval, and template output on behalf of your application.
It runs as a Kubernetes sidecar or a long-lived VM process, and can hand secrets to your app safely via either file output or a local HTTP listener.
Vault Agent is a lightweight daemon separate from the Vault server. It lives on the client side and handles authentication (Auto-Auth), automatic token renewal, secret retrieval, and template generation (file output). Your application never has to deal with Vault authentication or API details directly — it just reads the local artifacts (a file or local HTTP) that Agent produces.
There are two typical usage patterns. 1) Use the template feature to emit secrets as a file that the app reads. 2) Enable the local HTTP listener so the app reaches Vault through Agent as a caching proxy. In both cases Agent owns token management, renewing or refetching according to TTL.
The most common pattern is the Kubernetes sidecar. Agent runs alongside the application container in the same Pod and obtains/renews tokens using Kubernetes auth with a ServiceAccount. Templates write secrets to a file shared via emptyDir or expose a local listener on localhost.
On VMs/bare metal, run Agent as a systemd service and authenticate with AppRole or a similar method. To share across multiple processes, distribute secrets via file output (with strict permissions) or a 127.0.0.1 listener.
Big-picture view of the sidecar setup
Auto-Auth automatically logs in to Vault using a configured auth method (e.g., Kubernetes, AppRole, AWS IAM) and obtains/renews a client token. Agent watches the token's TTL and tries to renew before expiry. If renewal fails, it re-authenticates.
Depending on your use case, the token can be 1) written out to a file (sink), or 2) kept internally by the local HTTP listener and attached to proxied requests. With the caching proxy, the client sends requests to Agent's local listener without thinking about tokens, and Agent forwards them upstream to Vault using the Auto-Auth token.
| Auth Method | Trust Anchor | Typical Deployment / Prerequisites | Operational Notes |
|---|---|---|---|
| Kubernetes | Pod's ServiceAccount JWT | Kubernetes (sidecar / DaemonSet) | Minimize Role-to-SA bindings. Track automatic SA JWT rotation. |
| AppRole | RoleID + SecretID (manage issuance/delivery) | VM / bare metal / batch | Lock down the SecretID delivery channel. Either pull or push works. |
| AWS IAM | IAM role signatures (sts:AssumeRole, etc.) | EC2 / Lambda / ECS on AWS | Leverage temporary credentials via instance metadata. Make role boundaries and Vault role mappings explicit. |
The template feature periodically retrieves secrets from Vault and writes them out as files in the format you specify. The template language follows Consul Template, and for KV v2 the keys live under Data.data. Tighten file permissions and let the app read them as read-only.
If your app supports reload, you can run a command after the file update (for example, send SIGHUP). That lets you apply secret rotation without downtime.
Sample Vault Agent config (Kubernetes auth + template + cache)
# agent.hcl
vault {
address = "https://vault.example.local:8200"
}
# Local HTTP listener (Pod/host only)
listener "tcp" {
address = "127.0.0.1:8200" # do not expose externally
tls_disable = true # only when strictly local to the Pod/host
}
# Automate authentication to Vault
auto_auth {
method "kubernetes" {
mount_path = "auth/kubernetes"
config = {
role = "app-role"
# Read the Pod SA token from the default path (adjust per environment)
token_path = "/var/run/secrets/kubernetes.io/serviceaccount/token"
}
}
# Add a sink if you need to write out the token (e.g., file)
sink "file" {
config = {
path = "/run/secrets/.vault-token"
mode = "0400"
}
}
}
# Enable cache and reach upstream using the Auto-Auth token
cache {
use_auto_auth_token = true
}
# Use a template to render KV v2 secrets to a file
# Reference keys under Data.data
# Hot-reload by sending SIGHUP to the app
template {
destination = "/run/secrets/app-config.env"
perms = 0400
command = "/usr/bin/pkill -HUP myapp || true"
contents = <<EOH
# generated by vault-agent; do not edit
{{ with secret "kv/data/app/config" -}}
API_KEY={{ .Data.data.api_key }}
DB_USER={{ .Data.data.db_user }}
DB_PASS={{ .Data.data.db_pass }}
{{- end }}
EOH
}
Enable the caching proxy and Agent holds secret responses locally, renewing them before expiry per the TTL. That cuts the number of queries to the Vault server and stabilizes behavior during traffic spikes. The app just points at the 127.0.0.1 listener instead of the Vault endpoint, and gets token injection and caching for free.
From an availability standpoint, even during a transient upstream Vault outage, requests can still be served by cache hits as long as the TTL is valid. Leases past their TTL cannot be returned, so for critical paths plan TTLs carefully and consider retry and fallback strategies (for example, whether the app can keep running with the previously loaded config).
Stick rigorously to least privilege. Use policies that allow only the paths the template references, keep TTLs short with automatic renewal, and plan token rotation/revocation strategy. Restrict output file permissions to the owner and, on shared volumes, prevent reads by other processes.
For the exam, remember that Agent is a client-side helper, not a server feature; Auto-Auth handles authentication and token renewal; templates produce file output; and the caching proxy reduces QPS and helps availability. Expect questions on pairings like Kubernetes -> sidecar + SA auth, and VM -> AppRole.
Associate / Ops
問題 1
An application on Kubernetes has no Vault SDK and only reads credentials from an environment variable file. Secrets are rotated periodically. Which approach best balances operational overhead and security?
正解: A
Sidecar Vault Agent with Kubernetes auth + template output automates token management and rotation, and the app just reads a file. Embedding the root token is out of the question, and shipping configs from the server side over NFS is not standard Vault operation. Delegating to Agent is safer and more maintainable than handling AppRole directly in app code.
Does Vault Agent need to run as a privileged (root) user?
Not at all. All it needs is network reachability to Vault and permission to create the output files. Run it as a least-privileged user and lock down the permissions on the output paths.
Is there still a benefit to using Vault Agent when the app can renew tokens by itself?
Yes. You get safe file output via templates, fewer QPS to Vault through the caching proxy, and a battle-tested retry/backoff and auto-renew implementation you can reuse. That said, if your SDK integration is robust and already meets your requirements, Agent is not mandatory.
How does Agent behave during a Vault outage?
If caching is enabled, Agent can serve cache hits as long as the secret's TTL has not expired. Once the TTL is past, it cannot answer, so retry/fallback policies and proper TTL design matter. Once Vault recovers, Agent re-authenticates and renews automatically.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Vault Core Concepts: Sealed/Unsealed, Auth, Secrets (2026)
Vault fundamentals — sealed/unsealed state, auth methods, se...
Vault Operations Professional (VOP-003): Complete Guide (2026)
Pass the Vault Operations Professional exam — enterprise pat...
Vault Path-Based Routing: API URL Structure (2026)
How Vault's path-based routing works — mount points, sub-pat...
Vault Tokens: Auth Token Mechanics (2026)
Token fundamentals — service vs. batch tokens, accessor, ren...
Vault Token Types: Service, Batch, Periodic (2026)
Service vs. batch tokens compared — performance, ACL behavio...