ConfigMap from env-file with patch op

Build a CM from KEY=VALUE file, then JSON-patch it into a container's envFrom

kubectl create configmap <name> --from-env-file=app.env -n <ns> --dry-run=client -o yaml | kubectl apply -f -; kubectl patch deploy/<name> -n <ns> --type=json -p='[{"op":"add","path":"/spec/template/spec/containers/0/envFrom/-","value":{"configMapRef":{"name":"<name>"}}}]'

tool
kubectl73 commands
tags
kubectlsecretsgitopsk8s

More kubectl commands

  • kubectl get pods -A -o wide

    All pods with node placement and IPs

  • kubectl describe pod <name> -n <ns>

    Full details: events, conditions, volume mounts

  • kubectl logs -f <pod> -n <ns>

    Stream logs in real time; add -c <container> for multi-container pods

  • kubectl logs <pod> --previous -n <ns>

    Logs from the last crashed/restarted container instance

  • kubectl exec -it <pod> -n <ns> -- bash

    Interactive shell inside a running container

all 73 kubectl commands