Interview Prep/DevSecOps/Secrets management: Vault, External Secrets and SOPS

Vault becomes slow, requests time out with `context deadline exceeded`, and `vault.expire.num_leases` is at 4 million

AdvancedTroubleshootingSecrets management: Vault, External Secrets and SOPS
Answer

Likely causes → A lease explosion. Some client logs in or requests dynamic credentials on every request (a CronJob, Lambda or app with no token caching). Each request creates a token or lease that lives until its TTL expires.

Diagnose →

vault read sys/internal/counters/activity
vault list sys/leases/lookup/auth/kubernetes/login | wc -l
vault read sys/metrics -format=json | jq '.Gauges[] | select(.Name|test("num_leases"))'

Fix → Find the offending role in the audit log and fix the client to reuse its token (Vault Agent auto-auth with caching). Shorten that role's token_ttl. Revoke the excess with vault lease revoke -prefix auth/kubernetes/login, carefully and in batches.

Prevent → Set lease count quotas (vault write sys/quotas/lease-count/k8s max_leases=50000 path=auth/kubernetes) and alert on lease growth.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Secrets management: Vault, External Secrets and SOPS