Describe secure secret injection into Kubernetes containers during CI/CD

Tests production secret injection hygiene in Kubernetes CI/CD. Strong answers: external secret store at deploy time, volume mounts over env vars, etcd encryption, RBAC least privilege, and rotation.
What's really being asked
The interviewer wants to know if you understand the full attack surface of secrets in a containerized CI/CD pipeline. This includes build-time exposure, transit security, storage at rest in etcd, runtime visibility inside containers, and access control. They are looking for defense-in-depth rather than a single use Kubernetes Secrets answer.
The full answer
First, secret generation and storage should live outside the cluster in a dedicated secret manager such as HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault, and the CI/CD pipeline should never touch the plaintext value directly. Second, use an operator like External Secrets Operator or Sealed Secrets to sync secrets into Kubernetes Secret objects automatically during deployment, avoiding any manual kubectl steps or Git storage. Third, mount secrets as read-only volumes under tmpfs rather than injecting them as environment variables, because environment variables are visible in procfs, process listings, and application crash dumps. Fourth, enable encryption at rest for etcd so that Secret data is not stored in plaintext in the underlying cluster database. Fifth, lock down RBAC so only the specific ServiceAccount running the workload can read the Secret in its own namespace, following least privilege. Sixth, implement rotation through your secret manager and trigger rolling updates or use dynamic secret leasing so credentials expire automatically.
The mistakes people make
Baking secrets into container images via Docker build arguments or layer files. Storing plaintext secrets in Git repositories even if private. Using ConfigMaps for sensitive data because they are not designed for confidentiality. Injecting secrets as environment variables without acknowledging the runtime exposure risk. Giving cluster-admin or broad Secret read access to CI/CD service accounts. Forgetting etcd encryption at rest. Assuming Kubernetes Secrets are encrypted by default without enabling the EncryptionConfiguration.
What usually comes next
How would you rotate a database password without dropping active connections? What happens to a secret when you delete a Pod but not the Deployment? How do you audit who read a Secret? Would you ever use environment variables over volume mounts, and why? How do you handle secrets in a multi-tenant cluster where users should not read each others credentials?
A concrete example
A pipeline builds a generic image with no credentials. ArgoCD or Flux deploys a Helm chart that references an ExternalSecret object. The External Secrets Operator fetches the database password from Vault and writes it to a Kubernetes Secret in the payments namespace. The Deployment mounts that Secret as a volume at /etc/secrets/db-password with readOnly true. The container application reads the file on startup. RBAC grants only the payments ServiceAccount permission to get that Secret. The cluster etcd is configured with a KMS provider to encrypt Secret resources at rest. When Vault rotates the password, the operator syncs the new value and the Deployment rolls out automatically.
Interview question
Which approach best implements defense-in-depth for delivering database credentials to a Kubernetes application through CI/CD?
- a.Place the password in a ConfigMap, expose it as an environment variable, and rely on Kubernetes default secret encryption
- b.Store credentials in a private Git repo, sync them with cluster-admin privileges, and mount them as a volume
- c.Fetch from an external secret manager via an operator, mount as a read-only volume, enforce least-privilege RBAC, and encrypt etcd at restCorrect
- d.Build the password into the container image and inject it via an environment variable at runtime
Why? this is the answer
This combines external secret management, volume mount isolation, least-privilege RBAC, and etcd encryption as the card recommends. Option A is tempting because it uses native Kubernetes objects, but ConfigMaps lack confidentiality design and default etcd encryption is not enabled without an EncryptionConfiguration.
Just read this? Test yourself on what you have been reading.
Read the original → kubernetes.io
- #kubernetes
- #secrets
- #cicd
- #security
- #production
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
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.
We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.
See open roles