Skip to content
tezvyn:

How do you inject secrets from an external store at runtime?

Source: interviewHardHow cards are made

Summary

external secret-management patterns.

Key points

use a sidecar injector or CSI driver that authenticates via the Pod's ServiceAccount token, fetches secrets at runtime, and mounts them on tmpfs.

What's really being asked

Whether you can design a secrets architecture that satisfies a no-secrets-in-etcd policy while still delivering credentials to workloads, and whether you understand workload identity.

The full answer

The core challenge is bootstrapping trust without a static credential. The pattern uses the Pod's projected ServiceAccount token as its identity. With Vault, the Kubernetes auth method validates that token against the cluster's TokenReview API and returns a short-lived Vault token scoped by policy. A Vault Agent Injector mutating webhook adds an init and sidecar container that authenticates, fetches secrets, and renders them to a shared in-memory tmpfs volume that the app container reads as files, with automatic renewal and re-rendering on rotation. An alternative is the Secrets Store CSI driver, which mounts secrets from Vault, AWS Secrets Manager, or Azure Key Vault directly as a volume; on AWS, IRSA maps the ServiceAccount to an IAM role so no static keys exist. Crucially, secrets live only in memory in the Pod, never persisted to etcd.

The mistakes people make

Using External Secrets Operator to sync values into native Kubernetes Secrets, which reintroduces plaintext to etcd and violates the policy. Embedding a long-lived Vault token or AWS access key in the manifest. Writing secrets to a hostPath or persistent disk.

What usually comes next

How does the ServiceAccount token get validated? How are secrets refreshed without restarting the Pod? Trade-offs between sidecar injection and the CSI driver? How do you audit access in Vault?

A concrete example

Annotate a Deployment with vault.hashicorp.com/agent-inject and a role; the injector adds a sidecar that logs into Vault using the Pod's ServiceAccount token, reads database creds, and writes them to /vault/secrets/db on tmpfs, which the app reads at startup and which is re-rendered when the lease renews.

Interview question

An external-secrets design must keep plaintext out of etcd. Which approach satisfies that requirement?

  • a.Bake a long-lived Vault token into the container image
  • b.Mount secrets via a CSI driver onto in-memory tmpfs at runtimeCorrect
  • c.Sync Vault values into native Kubernetes Secret objects
  • d.Store secrets in a ConfigMap referenced by the Pod
Why?

Fetching secrets at runtime and mounting them on tmpfs keeps them only in Pod memory, never in etcd. Syncing into Kubernetes Secrets or using a ConfigMap persists plaintext to etcd, violating the policy.

Just read this? Test yourself on what you have been reading.

Read the original → developer.hashicorp.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.

See open roles