<p>How can I use secret <code>X</code> key <code>my-key</code> in an other secret <code>Y</code> as <code>some-other-key</code>? Both secrets have other keys as well.</p>

<p>Rational: 
The mysql instance generates a secret containing the passwords for the users with keys <code>mysql-password</code> and <code>mysql-root-password</code>.
A custom resource <code>DbInstance</code> expects the name of a secret, which contains the keys <code>user</code> and <code>password</code>. (I use <a href="https://github.com/kloeckner-i/db-operator" rel="nofollow noreferrer">https://github.com/kloeckner-i/db-operator</a>)
How can I put the value from one into the other?</p>

<p>Of course I can do it manually, by copying the encoded value from <code>kubectl get secret mysql-generated-secret</code> and paste it in <code>kubectl edit secret dbinstance-secret</code>.
Is there a better way? A reference in k8s if possible, or a nice automation. (I will find a way like <code>pwd=$(kubectl get secret -o yaml ... | yq .data.mysql-password | base64 -d) &amp;&amp; helm update --set password=$pwd ...; unset pwd</code>, but is this the best way?)</p>

<p>similar:
<a href="https://stackoverflow.com/questions/57713006/using-kubernetes-secrets-in-a-configmap">Using kubernetes secrets in a configmap</a></p>

simohe
<p>Best way to automate this is by using an operator. listen on secret mysql-generated-secret, on creation or modification trigger -> create dbinstance-secret </p>

<p>Here is an operator who sync secrets between namespaces, you can use the same base code and modify it to your needs.</p>

<p><a href="https://github.com/zakkg3/ClusterSecret" rel="nofollow noreferrer">https://github.com/zakkg3/ClusterSecret</a></p>
