title: Openshift oc new-app how to maps secrets of another pod?
body: <p>I have a project/namespace in Openshift 3.9. It has one Mysql db pod, the credentials details are stored as <code>secrets</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/2fXQP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2fXQP.png" alt="enter image description here"></a></p>
  
  <p>While deploying my Springboot application, in Openshift UI, I change the <code>Deployment Configuration</code> to map the dynamic variables from my APP to Mysql secrets.</p>
  
  <p><a href="https://i.stack.imgur.com/cO6xA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cO6xA.png" alt="enter image description here"></a></p>
  
  <p>Now I want to automate this step, and how do I mention/pass these secrets while using the <code>oc new-app</code> cmd. I am using below command, but not sure on how to pass/map variables to secrets.</p>
  
  <pre><code>oc new-app redhat-openjdk18-openshift~https://github.com/xyzasdkjasnda/openshift-mysql
  </code></pre>
  
  <p>Somewhere I saw a workaround like below, </p>
  
  <blockquote>
    <p>oc new-app
    redhat-openjdk18-openshift~<a href="https://github.com/xyzasdkjasnda/openshift-mysql" rel="nofollow noreferrer">https://github.com/xyzasdkjasnda/openshift-mysql</a>
    | jq '.items[] | select(.kind == "DeploymentConfig") |
    .spec.template.spec.containers[0].env +=
    [{"name":"db_name","valueFrom":{"secretKeyRef":{"key":"database-name","name":"mysql"}}},{"name":"db_username","valueFrom":{"secretKeyRef":{"key":"database-user","name":"mysql"}}},{"name":"db_password","valueFrom":{"secretKeyRef":{"key":"database-password","name":"mysql"}}}]'
    | \
        oc apply --filename -</p>
  </blockquote>