<p>I'm creating a secret with below yaml. My application needs the username and password in plaintext</p>
<pre><code>apiVersion: v1
stringData:
  password: &quot;secret&quot;
  username: &quot;kafka&quot;
kind: Secret
metadata:
  name: kafka-secret
  namespace: kafka
type: Opaque
</code></pre>
<p>However when I apply the yaml it changes to data instead of string data and the values get encoded</p>
<pre><code>apiVersion: v1
data:
  password: a2Fma2Etc2VjcmV0
  username: c2VjcmV0
kind: Secret
metadata:
  creationTimestamp: &quot;2023-07-18T18:41:17Z&quot;
  name: kafka-secret
  namespace: kafka
  resourceVersion: &quot;14336732&quot;
  uid: bc051184-335b-4eca-8120-78d8c431f123
type: Opaque
</code></pre>

DeirdreRodgers
<p>yes this is the nature of a Secret, you can think of a Secret as an encoded configmap all values in the secret should be base64 encoded. If you create a secret e.g. via</p>
<p><code>kubectl create secret generic mysecret --from-literal=password=mypassword123</code></p>
<p>the password will be always base64 encoded!</p>
<p>In the pod you could mount now you secret and utilize it as clear values</p>
<pre><code>kind: Pod
metadata:
  name: mypod
spec:
  containers:
    - name: mypod
      image: redis
      volumeMounts:
        - name: foo
          mountPath: &quot;/etc/foo&quot;
          readOnly: true
  volumes:
    - name: foo
      secret:
        secretName: mysecret
        optional: true
</code></pre>
<p>You can also utilize you value as an env variable which fits to your password username example:</p>
<pre><code>  kind: Pod
  metadata:
    name: envvars-multiple-secrets
  spec:
    containers:
    - name: envars-test-container
      image: nginx
      env:
      - name: BACKEND_USERNAME
        valueFrom:
          secretKeyRef:
            name: backend-user
            key: backend-username
      - name: DB_USERNAME
        valueFrom:
          secretKeyRef:
            name: db-user
            key: db-username
</code></pre>
