8

I have a folder in my server that I want to update inside a cointaier in a pod. How do I do that without deleting the Secret?

I know that the following creates my secret: oc create secret generic privkey --from-file=/opt/privkey

I know that the following deletes the secret:

oc delete secret generic privkey

Is there a way to do that without deleting? I am fine if I have to delete the pod.

zeh
  • 1,197
  • 2
  • 14
  • 29
  • Possible duplicate of [Update k8s ConfigMap or Secret without deleting the existing one](https://stackoverflow.com/questions/38216278/update-k8s-configmap-or-secret-without-deleting-the-existing-one) – Jordan Liggitt Jun 02 '18 at 00:21
  • Yes, it’s a duplicate. Did not see this one. Apologies – zeh Jun 02 '18 at 01:44

1 Answers1

16

try this:

oc create secret generic privkey --from-file=/opt/privkey --dry-run -o yaml | oc replace -f -
Kun Li
  • 2,570
  • 10
  • 15
  • works like a charm. Thanks. I thought that a solution could be writing the yml file. the `-o` with `replace` works great – zeh Jun 01 '18 at 08:10
  • 3
    For newer openshift/OKD versions, when "oc replace -f -" is no longer working, use "oc apply -f -" – Bob Claerhout Jul 25 '19 at 15:31