<p>I have an application that starts with <code>docker-compose up</code>. Some ssh credentials are provided with a json file, in a volume, in the host machine. I want to run the app in kubernetes, how can I provide the credentials using kubernetes secrets? my json file looks like:</p>

<pre><code>{
  "HOST_USERNAME"="myname",
  "HOST_PASSWORD"="mypass",
  "HOST_IP"="myip"
}
</code></pre>

<p>I created a file named mysecret.yml with base64 and I applied in kubernetes</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: mysecret
type: Opaque
data:
  HOST_USERNAME: c2gaQ=
  HOST_PASSWORD: czMxMDIsdaf0NjcoKik=
  HOST_IP: MTcyLjIeexLjAuMQ==
</code></pre>

<p>How I have to write the volumes in deployment.yml in order to use the secret properly?</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: mypod
    image: redis
    volumeMounts:
    - name: foo
      mountPath: "/etc/foo"
      readOnly: true
  volumes:
  - name: foo
    secret:
      secretName: mysecret

</code></pre>

<p>This is the above example of using secret as volumes. You can use the same to define a deployment.</p>

<p>Please refer to official kubernetes documentation for further info:
<a href="https://kubernetes.io/docs/concepts/configuration/secret/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/secret/</a></p>
