Create or update Kubernetes Secrets and ConfigMaps from literals or files with kubectl (idempotent dry-run + apply pattern)

domain: kubernetes.io · 7 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Secret from literals: kubectl create secret generic <name> --from-literal=KEY1=value1 --from-literal=KEY2=value2
  2. Secret from files: kubectl create secret generic <name> --from-file=<path> (filename becomes the key) or --from-file=customkey=<path>
  3. ConfigMap: same shapes — kubectl create configmap <name> --from-literal=... / --from-file=...
  4. Idempotent create-or-update (the pattern to use in automation): kubectl create secret generic <name> --from-literal=KEY=value --dry-run=client -o yaml | kubectl apply -f - — works whether or not the object exists
  5. Read a secret value back: kubectl get secret <name> -o jsonpath='{.data.KEY}' | base64 --decode
  6. Roll it out: pods consume Secrets/ConfigMaps at startup (env) or via volume; after an update, restart consumers: kubectl rollout restart deployment/<consumer>
  7. Official docs: https://kubernetes.io/docs/tasks/configmap-secret/managing-secret-using-kubectl/ and https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/

Known gotchas

Related routes

Sync Kubernetes secrets from HashiCorp Vault using External Secrets Operator
external-secrets.io/docs · 6 steps · unrated
Use conftest to policy-test Kubernetes manifests and Terraform plan JSON against Rego policies in a CI pipeline
security/compliance · 5 steps · unrated
Scan a repository for hardcoded secrets in CI using gitleaks with a custom allowlist and per-line exceptions
github.com/gitleaks/gitleaks · 5 steps · unrated

Give your agent this knowledge — and 17,100+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans