<p>I have a service for which a helm chart has been generated. This helm chart spins off zookeeper and mysql containers with which the service communicates. 
I now want to create a helm chart that spins off a platform of services of which the above service is one. When i attempt to do this, I use tags to disable the above service's dependencies that are listed in the helm chart, like so:</p>

<pre><code>tags:
  service-zookeeper: false
  service-mysql: false
</code></pre>

<p>Now, i have a few init containers(liquibase) that populate the mysql instances created via dependencies whenever the service is deployed. I need to pass a separate, stand alone mysql container as the instance of mysql that this init container needs to populate. A similar chroots job for zookeeper exists. 
The problem I need help tackling is that I can't seem to find a way to pass the separate mysql container as the container that needs to be populated by the first service's liquibase init-container. Is there any way to do so? Any help/insights are appreciated.</p>

hisdudeness
<p>You just need the MySQL Service's hostname and credentials for this.</p>

<p>Remember that the Helm YAML templates can use everything in the <a href="https://godoc.org/text/template" rel="nofollow noreferrer">Go text/template language</a>.  That includes conditionals <code>{{ if ... }}...{{ else }}...{{ end }}</code>, among other control structures, plus most of the support functions in the <a href="http://masterminds.github.io/sprig/" rel="nofollow noreferrer">Sprig</a> library.  This can become verbose, but neatly solves this class of problem.</p>

<p>For the host name, one approach is to assert a single service name, whether installed by your chart itself or the wrapper chart.  (If the top-level chart installs MySQL, and also installs your service, they will have the same Helm release name and the same generated hostname, independently of whether MySQL is a direct dependency of your chart.)</p>

<pre><code>- name: MYSQL_HOST
  value: {{ printf "%s-mysql.%s.svc.cluster.local" .Release.Name .Release.Namespace | quote }}
</code></pre>

<p>Another is to pass it in the <code>values.yaml</code> configuration, optionally.  The <a href="http://masterminds.github.io/sprig/defaults.html" rel="nofollow noreferrer">Sprig <code>default</code> function</a> is useful here.</p>

<pre><code>- name: MYSQL_HOST
  value: {{ .Values.mysqlHostname | default (printf "%s-mysql.%s.svc.cluster.local" .Release.Name .Release.Namespace) | quote }}
</code></pre>

<p>You can use a similar approach to either find the Secret the MySQL installation saves its passwords in or reconstruct it from configuration.</p>
