Interview Prep/Shell Scripting/Scenarios: text processing and scheduling decisions

Convert a `.env` file into a Kubernetes Secret manifest without committing plaintext.

BeginnerScenarioScenarios: text processing and scheduling decisions
Answer

Situation read → kubectl can build the manifest; encryption must happen before it reaches Git.

What I'd do →

kubectl create secret generic api-env --from-env-file=.env -n prod --dry-run=client -o yaml > secret.yaml
kubeseal --format yaml < secret.yaml > sealed-secret.yaml && rm -f secret.yaml   # Sealed Secrets
# or: sops --encrypt --in-place secret.yaml
  1. --from-env-file handles KEY=value lines and base64-encodes values.
  2. Commit only the sealed or SOPS-encrypted file.

Why → Kubernetes Secrets are only base64, not encryption; committing them is committing plaintext.

Interview tip → Mention External Secrets Operator as the alternative that keeps secrets in AWS Secrets Manager or Vault.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Scenarios: text processing and scheduling decisions