How can I update a secret on Kubernetes when it is generated from a file?

Chris Stryczynski picture Chris Stryczynski · Aug 25, 2017 · Viewed 72.9k times · Source

I've created a secret using

kubectl create secret generic production-tls \
  --from-file=./tls.key \
  --from-file=./tls.crt

If I'd like to update the values - how can I do this?

Answer

Janos Lenart picture Janos Lenart · Aug 25, 2017

This should work:

kubectl create secret generic production-tls \
    --from-file=./tls.key --from-file=./tls.crt --dry-run -o yaml | 
  kubectl apply -f -