Lijing Zhang
Lijing Zhang

Reputation: 63

In K8S, how to use data from existed secret when creating new secret?

We got an existed secret in K8S(suppose it is "secret_1") and we want to write a yaml to create a new secret "secret_2", using some values from secret_1.

That is, in this yaml we'd like to

  1. Read values from other secret
  2. Store values to new secret

Is it possible to do this? It will be great help if a sample can be provided.

Thanks in advance.

Upvotes: 0

Views: 132

Answers (1)

coderanger
coderanger

Reputation: 54211

You cannot do this directly in YAML. You would need to write a script of some kind to do the steps you described, though you can use kubectl get secret -o yaml (or -o json) for a lot of the heavy lifting, possibly with jq for the reformatting.

Upvotes: 1

Related Questions