feat: Add vault-fetcher CLI tool (Phase 2)#380
Draft
Alan-Cha wants to merge 1 commit into
Draft
Conversation
Implement standalone CLI tool for fetching secrets from Vault at pod startup. This completes Phase 2 of the Vault pattern implementation. vault-fetcher is an init container that: - Authenticates to Vault using SPIFFE JWT-SVID (or K8s SA, or token) - Fetches configured secrets from Vault - Writes secrets to files with secure permissions - Supports multiple output formats (individual files, env file, JSON) Features: - Uses authlib/vault library for all Vault operations - Configuration via YAML file with env var overrides - Retry logic for authentication (3 attempts with backoff) - Fail-fast with clear error messages - Minimal container image (distroless, ~20MB) - Runs as non-root (UID 65532) Files added: - vault-fetcher/main.go (330 lines) — CLI implementation - vault-fetcher/config.yaml.example — Example configuration - vault-fetcher/Dockerfile — Multi-stage distroless image - vault-fetcher/README.md (450+ lines) — Complete documentation - vault-fetcher/go.mod, go.sum — Go module files - go.work — Updated workspace to include vault-fetcher Usage: vault-fetcher --config=/etc/vault-fetcher/config.yaml Next steps (Phase 3): - Webhook integration for automatic injection - Demo scenario with real agent - CI/CD pipeline for container image Ref: #vault-pattern Stacked on: #379 Signed-off-by: Alan Cha <Alan.cha1@ibm.com>
Member
Author
|
Closing to recreate as proper stacked PR using gh-stack |
This was referenced May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of the Vault pattern: vault-fetcher CLI tool for fetching secrets from Vault at pod startup.
Stacked on: #379 (Phase 1 - authlib/vault library)
This PR builds the init container that uses the
authlib/vaultlibrary to fetch secrets and write them to files.What This Adds
vault-fetcher CLI Tool
A standalone binary that runs as an init container:
authlib/vaultFeatures
Files Added
Total: ~916 lines added
Usage Example
Configuration
```yaml
/etc/vault-fetcher/config.yaml
vault:
address: "https://vault.example.com"
auth_method: "jwt"
role: "github-agent-role"
secrets:
field: "token"
output: "/shared/secrets/github-token"
mode: "0600"
```
Deployment
```yaml
apiVersion: v1
kind: Pod
spec:
initContainers:
image: ghcr.io/kagenti/kagenti-extensions/vault-fetcher:latest
args:
volumeMounts:
mountPath: /opt
mountPath: /shared/secrets
mountPath: /etc/vault-fetcher
containers:
volumeMounts:
mountPath: /shared/secrets
readOnly: true
App reads /shared/secrets/github-token
```
Output
```bash
[vault-fetcher] Starting vault-fetcher v0.1.0
[vault-fetcher] Loaded config from /etc/vault-fetcher/config.yaml
[vault-fetcher] Created Vault client (address=https://vault.example.com, auth_method=jwt)
[vault-fetcher] Successfully authenticated to Vault
[vault-fetcher] [1/1] Fetching secret: secret/data/github/token (field: token)
[vault-fetcher] [1/1] Secret fetched (lease: 3600s)
[vault-fetcher] [1/1] Written to: /shared/secrets/github-token
[vault-fetcher] All secrets fetched successfully
```
Testing
```bash
$ cd authbridge/vault-fetcher
$ go build -o vault-fetcher .
$ ./vault-fetcher --version
vault-fetcher version 0.1.0
```
Stacked PR Structure
```
main
└─> feat/vault-integration (PR #379) ← Phase 1: authlib/vault library
└─> feat/vault-fetcher-cli (THIS PR) ← Phase 2: vault-fetcher CLI
```
Merge order:
Next Steps (Not in This PR)
Review Notes
Key areas to review:
Questions for reviewers:
Assisted-By: Claude (Anthropic AI) noreply@anthropic.com