<p>I have a rest api where I have the databases in azure and the application with docker + kubernetes, so alright.</p>

<p>I have more than 10 clients and each client owns a database, I did not want to have a docker image for each client, just have a base image where for each client would have a connect string, the proposed solution was to make a <strong>setenv.sh</strong> to make the connections</p>

<p><strong>setenv.sh</strong></p>

<pre><code>#!/bin/bash

dbuser="xxx@iafox"
dbpassword="mypassword"
dbconnectstring="jdbc:sqlserver://xxx.database.windows.net:1433;database=ts-demo1;user=xxx@iafox;password=mypassword;encrypt=true;trustServerCertificate=true;hostNameInCertificate=*.database.windows.net;loginTimeout=30;"
dburl="jdbc:sqlserver://xxx.database.windows.net:1433;database=ts-demo1;"

export CATALINA_OPTS=" ${SYSTEM_PROPS} -Ddbuser='${dbuser}' -Ddbpassword=${dbpassword} -Ddbconnectstring='${dbconnectstring}' -Ddburl='${dburl}'"
</code></pre>

<p><strong>server.xml</strong></p>

<pre><code>&lt;Realm className="org.apache.catalina.realm.JDBCRealm" connectionURL="${dbconnectstring}" driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver" roleNameCol="role" userCredCol="password" userNameCol="login" userRoleTable="userRole" userTable="v_login"/&gt;
</code></pre>

<p>Until then everything is working. But now I do not know the next step, if for every <strong>setenv</strong> that I create I will have a <strong>configmap</strong> in kubernetes, or if I will have all the connect strings in the same <strong>setenv</strong> .... I wanted a help in this</p>

Bruno Luis
<p>You can set multiple environment variables from one <code>configMap</code> as documented <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#configure-all-key-value-pairs-in-a-configmap-as-container-environment-variables" rel="nofollow noreferrer">here</a>.</p>

<p>But I would recommend storing passwords and connection strings with sensitive information in a <code>secret</code>.</p>

<p>You can <a href="https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables" rel="nofollow noreferrer">reference Kubernetes secrets in a similar way</a> to set the container's environment vars.</p>
