<p>I have two docker images <code>Mosquitto</code> &amp; <code>user-info</code>. <code>userInfo</code> is a container which performs some logic and then send the result to <code>mosquitto</code>. Mosquitto then use this information to send it to IOT hub. Inside <code>user-info</code> I have mentioned to use <code>hostname=mosquitto</code> so the <code>user-info</code> send all data to mosquitto</p>

<p>I started first by creating a pods with these 2 containers. So I wrote a yaml file with <code>kind: Pod</code> and everything went ok. As these container were inside the same pod, so they were easily able to communicate to each other and hence <code>user-info</code> was able to send data to <code>mosquitto</code>.</p>

<p>Now going forward I do not want to create pods and would like to go with <code>kind: Deployment</code> but I wonder creating multiple pods is not possible in deployment. So if I create two deployment files for <code>mosquitto-deployment.yaml</code> &amp; <code>user-info-deployment.yaml</code>, they both will create two different pods. So how can I make these pods communicate?</p>

<p>I read about service and we can communicate using service but I am having hard time with services. If I create a service for mosquitto, do I need to create service for <code>user-info</code> or it can directly communicate to mosquitto service. Also, is it not possible to use single deployment.yaml file for creating all the pods rather than using 2-3 deployment.yaml files.</p>

<p>A quote from the book "Up and running with Kubernetes" should give you a hint;</p>

<blockquote>
  <p>In general, the right question to ask yourself when designing Pods is,
  “Will these containers work correctly if they land on different
  machines?” If the answer is “no,” a Pod is the correct grouping for
  the containers. If the answer is “yes,” multiple Pods is probably the
  correct solution.</p>
</blockquote>

<p>From what I've read about your project, those two containers would be more of a fit for a single pod - and that way they can communicate through localhost.</p>

<p>In general, you will never need a k8 manifest with the kind pod, thats just for experimental purposes.</p>

<p>For a typical app you will need an deployment and service object.</p>

<p>Tom</p>
