<p>I need to pull the value of the passwords which was defined in the TeamCity .currently I used the secrets.yaml to store the passwords. for implementing it I have converted the password into 64bit code value. and save it.seems its very difficult for me to update it every time. Do we have any options for updating it dynamically?</p>

<p>First thing I have tried like this:</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: mysecret
data:
  CassandraSettings__CassandraPassword: [[ .Environment ]]-abc-cassandra-password
</code></pre>

<p>but it becomes failed during the deployment. later I had tried like this , here I converted the password into 64bit encoded value.</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: mysecret
data:
  CassandraSettings__CassandraPassword: S2V5czJUaGVLMW5nZDBt
</code></pre>

<p>as of now, I get the result.</p>

<p>my question is that, do we have any other option for fetching the value from TeamCity during deployment without converting the values.I need to update secrets.yaml dynamically.
This is the output that i get currently.
<a href="https://i.stack.imgur.com/hJjBO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hJjBO.png" alt="results"></a></p>

<p>is it possible to define the data like this</p>

<pre><code>CassandraSettings__CassandraPassword: [[ .Environment ]]-abc-cassandra-password
</code></pre>

<p>As i understand instead of <code>data</code> you need to work with <code>stringData</code> which will allow you to provide secret data as unencoded strings.</p>

<blockquote>
  <p><code>stringData</code> is a write-only convenience field which is not output when retrieving Secrets</p>
</blockquote>

<p><strong>Example</strong> : </p>

<p>secret.yaml</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: mysecret-test
stringData:
  CassandraSettings__CassandraPassword: Passw0rd
</code></pre>

<p><strong>Create Secret</strong> </p>

<pre><code>$ kubectl create -f secret.yaml
secret/mysecret-test created

$ kubectl describe secrets mysecret-test
Name:         mysecret-test
Namespace:    default
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;

Type:  Opaque

Data
====
CassandraSettings__CassandraPassword:  8 bytes
</code></pre>

<p><strong>Fetch Secret yaml and NOTE the data field is base64 encoded for you</strong>.</p>

<pre><code>$ kubectl get secrets mysecret-test -o yaml

apiVersion: v1
data:
  CassandraSettings__CassandraPassword: UGFzc3cwcmQ=
kind: Secret
metadata:
  creationTimestamp: "2020-01-30T13:24:11Z"
  name: mysecret-test
  namespace: default
  resourceVersion: "3733024"
  selfLink: /api/v1/namespaces/default/secrets/mysecret-test
  uid: 718278c5-0e8e-4861-ae23-7e107209c338
type: Opaque
</code></pre>

<p>Encoded data field value is same as <code>stringData</code> field passed quick check as below</p>

<pre><code>$ echo UGFzc3cwcmQ= | base64 -d
Passw0rd
</code></pre>

<p><strong>Or Use an imperative command</strong> like this to generate a secret.yaml with encoded value of literal passed. Below I defined one of the literal as export variable for test. </p>

<pre><code>$ export PASS=Passw0rd

$ echo $PASS
  Passw0rd

$ kubectl create secret generic mysecret --from-literal=CassandraSettings__CassandraPassword=$PASS--dry-run -o yaml &gt; secret.yaml

$ cat secret.yaml
apiVersion: v1
data:
  CassandraSettings__CassandraPassword: UGFzc3cwcmQ=
kind: Secret
metadata:
  creationTimestamp: null
  name: mysecret
</code></pre>
