Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy kubernetes one secrets value to another secretes within same namespace

I am using kubernetes and its resources like secrets. During deployment one secret has been created (say test-secret) with some values inside it. Now I need to renamed this secretes (dev-secret) within the same namespace. How can I rename the secret or how can I copy test-secret value to dev-secret.

Please let me know the correct approach for this.

like image 359
Still Learning Avatar asked Dec 08 '25 15:12

Still Learning


1 Answers

There is no specific way to do this. The Kubernetes API does not have "rename" as an operation. In this particular case you would kubectl get secret test-secret -o yaml, clean up the metadata: sections that don't apply anymore, edit the name of the secret, and kubectl apply it again.

like image 128
coderanger Avatar answered Dec 11 '25 01:12

coderanger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!