How would you set up HashiCorp Vault so Kubernetes workloads authenticate without any static token?
AdvancedScenarioSecrets and Identity Management
Answer
Situation read → The bootstrap secret problem: the app needs a credential to fetch credentials. Kubernetes auth uses the service account token as identity.
What I'd do →
- Enable the auth method:
vault auth enable kubernetes
vault write auth/kubernetes/config kubernetes_host=https://$K8S_API:443
vault write auth/kubernetes/role/orders \
bound_service_account_names=orders-sa \
bound_service_account_namespaces=orders \
policies=orders-read ttl=1h
- Write a narrow policy:
path "kv/data/orders/*" { capabilities = ["read"] }. - Use the Vault Agent injector or Vault Secrets Operator to deliver secrets to pods.
- Use projected, audience-bound service account tokens, and enable Vault audit devices.
Why → Identity comes from the platform; nothing long-lived is ever written into a manifest.
Interview tip → Name it "secret zero" and explain how platform identity solves it.
More on Secrets and Identity Management
A team stores database passwords in a `.env` file committed to a private repo. How do you migrate them out?BeginnerYour CI pipeline uses long-lived AWS access keys stored as repository secrets. How do you replace them?IntermediateAn auditor asks how often you rotate database credentials. You currently never do. What do you build?IntermediatePods need AWS access. A developer mounted an IAM user's keys as a Kubernetes Secret. What do you propose instead?BeginnerShould you use Kubernetes Secrets, Sealed Secrets, External Secrets Operator or the Secrets Store CSI driver?IntermediateA Slack webhook URL and a Stripe live key were posted in a public GitHub issue. What is your response sequence?Beginner