Usually if a resource needs to be updated in place in Kubernetes, A few options are available. If the resource was created using kubectl create/apply -f
, one just need to update the yaml file and apply -f
it again. I see this option is used mostly.
However, I have a secret
created --from-literal
before. I didn’t have a yaml file for it. In this case, lots of articles suggest to kubectl patch
it. Looking at the documentation, oh boy, I don’t know you my friend, I literally have a headache.
So I quickly moved on and figured this little but nice trick to complete the task:
kubectl create secret generic my-super-password --from-literal=password=12345678 --dry-run --output yaml | k apply -f -