Passing secrets to Pods via environment variables is easy, but it leaves risks around update propagation and persistence. The Vault CSI Driver uses the Secrets Store CSI Driver together with the Vault Provider to securely mount secrets into a Pod's tmpfs as files.
This article covers the questions operators actually wrestle with — whether to synchronize, how rotation works, and how to design permissions — while distilling the points that operations-track exams ask about most. The behavior described assumes the stable defaults documented in the official Vault docs.
The Vault CSI Driver lets you mount secrets into Pods as files. Files live in the node's tmpfs and are removed when the Pod terminates, so you avoid leaving plaintext in Kubernetes' etcd.
Combining this with the Secrets Store CSI Driver's sync feature lets you replicate secrets into a Kubernetes Secret when needed. The trade-off is that plaintext now sits in etcd, so the choice depends on your operational policy.
The Secrets Store CSI Driver's Node plugin talks to Vault through the Vault Provider. The Pod only reads files via the CSI volume — it never calls the Vault API directly. Authentication typically uses Vault's Kubernetes auth method with the Pod ServiceAccount's JWT.
A typical data flow looks like this:
Vault CSI Driver: secret injection flow into Pods
Install both the Secrets Store CSI Driver core and the Vault Provider in the cluster. The Vault server must be reachable from Kubernetes and have the Kubernetes auth method enabled. On the Vault side, bind Pod ServiceAccounts to Vault roles and define the minimum policies required.
On the network side, every node needs outbound connectivity to the Vault address. The CA used to verify the certificate must be provided through Vault Provider configuration or installed in the node's trust store.
The SecretProviderClass declares the Vault endpoint, auth role, and the secrets to fetch. On the Pod side, you mount a CSI volume and optionally enable synchronization to a Kubernetes Secret (remember: enabling sync puts plaintext in etcd).
Below is a representative configuration. Parameter names and details vary by Vault Provider version, so always cross-check against the official documentation for the version you deploy.
Minimal SecretProviderClass + Pod example (YAML)
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: vault-db-creds
namespace: app
spec:
provider: vault
parameters:
vaultAddress: "https://vault.example.com"
roleName: "app-readonly"
# VaultのKubernetes認証メソッドのマウントパス(環境に合わせて調整)
# vaultKubernetesMountPath: "kubernetes"
# Vault Enterpriseで名前空間を使う場合
# namespace: "platform/app"
# 取得対象(objectNameはファイル名になる)
objects: |
- objectName: "db-username"
secretPath: "database/creds/readonly"
secretKey: "username"
- objectName: "db-password"
secretPath: "database/creds/readonly"
secretKey: "password"
# 同期が必要な場合のみ設定(Kubernetes Secretに複製される)
secretObjects:
- secretName: db-creds
type: Opaque
data:
- objectName: "db-username"
key: username
- objectName: "db-password"
key: password
---
apiVersion: v1
kind: Pod
metadata:
name: app
namespace: app
spec:
serviceAccountName: app-sa
containers:
- name: web
image: ghcr.io/example/app:1.0
volumeMounts:
- name: secrets-store
mountPath: "/mnt/secrets"
readOnly: true
# K8s Secretへ同期した場合のみ、環境変数で参照可能
envFrom:
- secretRef:
name: db-creds
volumes:
- name: secrets-store
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: "vault-db-creds"Rotation rides on two wheels: the driver's refresh cycle and Vault's TTL plus role configuration. File contents can update without restarting the Pod, but nothing reaches the application unless it reloads the file. Choose a reload strategy that suits the app — signal-based reload, inotify-based watching, and so on.
Whether to synchronize to a Kubernetes Secret depends on the use case. You gain the same ergonomics as ConfigMaps and Secrets, but plaintext is now persisted in etcd. Design encryption-at-rest, RBAC, and audit logging together with that decision.
| Approach | Delivery Form | Plaintext in etcd | Rotation Propagation |
|---|---|---|---|
| Vault CSI Driver (no sync) | File inside the Pod (tmpfs) | None | Driver refresh + app reload |
| Vault CSI Driver (with sync) | File in Pod + Kubernetes Secret | Yes | Sync updates the Secret (app behavior depends on how it consumes it) |
| Vault Agent Injector | Sidecar emits files / rendered templates | None (depends on configuration) | Reflected via the Agent's template re-render |
| Kubernetes Secret only | Environment variables or volume | Yes | Secret updates exist, but Pod restarts are often required |
Operations-track exams keep coming back to the same questions: where secrets are stored, who can fetch them with what permissions, and how they are updated. Being able to pick the right answer on whether to sync, on file delivery vs. environment variables, and on binding ServiceAccounts to Vault roles is what scores points.
Common failure modes include namespace mismatches between the ServiceAccount and the Vault role, insufficient Vault policies, TLS verification failures because the Vault CA was not configured, and apps that never reload the updated file.
Ops
問題 1
An operations team wants to distribute Vault dynamic database credentials safely to application Pods in Kubernetes. The requirements are mandatory: rotation must reflect without restarting Pods, and no plaintext may remain in etcd. Which configuration is most appropriate?
正解: A
The requirements are rotation without Pod restart and no plaintext in etcd. The Vault CSI Driver with sync disabled delivers files on tmpfs and never persists to etcd, so it fits. B and D both involve replication into a Kubernetes Secret, which violates the requirement. C does not use Vault at all and leaves plaintext in etcd.
Can secrets be delivered directly as environment variables?
Vault CSI Driver itself delivers secrets as files. If you want them as environment variables, enable synchronization to a Kubernetes Secret and reference it via envFrom or valueFrom. Be aware, though, that this stores plaintext in etcd.
Do secret updates require a Pod restart to take effect?
When the driver's rotation feature is enabled, file contents update without restarting the Pod. The application must still be able to reload the file, however. Implement reload mechanisms such as SIGHUP handling or inotify-based watches.
Can the same Vault secret be referenced from multiple namespaces?
Yes. Prepare a Vault role and policy per ServiceAccount in each namespace, granting access on a least-privilege basis. If you use Vault Enterprise namespaces, configure the namespace field in the SecretProviderClass correctly.
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...