<p>I have a Kubernetes deployment.yml file that includes a container setup for:</p>

<ul>
<li>nginx</li>
<li>php-fpm</li>
<li>mysql </li>
</ul>

<p>I have some environment variables set for my php-fpm container:</p>

<ul>
<li>DB_HOST</li>
<li>DB_DATABASE</li>
<li>DB_USER</li>
<li>DB_PASSWORD</li>
</ul>

<p>I'm wondering how I can set the DB_HOST env var to link to my MySQL container (running in the same pod as my nginx &amp; php-fpm containers).</p>

<p>Or should I create a new pod for my MySQL container as then I can create a 'service' from that pod and refer to the MySQL service name?</p>

<p>Thanks!</p>

mattyh88
<p>It is a real bad practice to setup 2 'business' container in one pod (scale you stuff individually is better than scaling everything, pod can be started on different host, ...). </p>

<p>Anyway, a pod share network across the container, so you can use <code>localhost</code> as hostname if you really want to set everything in one pod.</p>

<p>But yes it is really better to set 1 statefulset for mysql and use the name in php-fpm </p>
