Q: How do you pass sensitive configuration (like DB passwords) to a pod without hardcoding them?
Use Kubernetes Secrets:
#Kubernetes #Advanced Scenarios #L2 #Container Orchestration #K8s
🎙️ Candidate Opening & Architectural Context
""Kubernetes is a declarative desired state system; understanding the reconciliation loop is how you diagnose this quickly. When addressing this question, I walk the interviewer through our production incident runbook: isolating the blast radius, checking diagnostic logs and metrics, and applying a safe fix.""
Advertisement
🛠️ Production Runbook & Step-by-Step Resolution
1️⃣
Initial Diagnostics & Root Cause Analysis
Use Kubernetes Secrets:
- Create a secret:
kubectl create secret generic db-creds --from-literal=password=mypassword - Reference in pod as env var:
2️⃣
Remediation & Permanent Safeguards
Or mount as a file: File mounting is more secure — env vars can leak in logs and process listings. Also avoid printing env vars in app error messages.
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-creds
key: password
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Create a secret: kubectl create secret generic db-creds --from-literal=password=mypassword."
⚡ 60-Second Elevator Pitch Talking Points
- Create a secret: kubectl create secret generic db-creds --from-literal=password=mypassword
- Reference in pod as env var:
Advertisement