<p>I would to deploy, through kubernetes, two applications in <strong>local</strong> docker images (no docker hub/artifactory). I want them to see each other through name (no ip), so I should deploy them in the same POD and load the name of the first as system environment variable in the second container.</p>

<p>They should be both visible from the external, so I need NodePort deploy and I would be able to choose the port.</p>

<p>I know how to reach this goal through kubectl cli commands, but I would to have the result through a YAML configuration file so I can apply with the command <code>kubectl apply -f deploy.yml</code></p>

Andrean
<p>Technically, You can deploy multiple app containers in same POD but you should avoid that as </p>

<ul>
<li>you want to scale them independently (X replicas of APP1 and Y replicas of APP2) </li>
<li>also to keep resource allocation dedicated to one kind of application</li>
<li>and many more benefits of isolation</li>
</ul>

<p>As far as communicating them via name (no IP) kubernetes has the concept of <code>services</code> to achieve that with ease.</p>

<p>All of this can be written in YAML format</p>

<p>You can see this: </p>

<p><a href="https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/</a></p>

<p><a href="https://kubernetes.io/docs/tutorials/stateless-application/guestbook/" rel="nofollow noreferrer">https://kubernetes.io/docs/tutorials/stateless-application/guestbook/</a></p>

<p>BUT STILL If you want to do this........
Then containers inside same pod can communicate with each other using <code>localhost</code> and in YML can you define spec for multiple container</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
  - name: app1-container
    image: app1
  - name: .... for app 2
    image: app2
</code></pre>
