<p>Part of my deployment looks like this</p>

<pre><code>client -- main service  __ service 1
                       |__ service 2
</code></pre>

<p><strong>NOTE:</strong> Each of these 4 services is a container and I'm trying to do this where each is in it's own Pod (without using multi container pod)</p>

<p>Where main service must make a call to service 1, get results then send those results to service 2, get that result and send it back to the web client</p>

<p>main service operates in this order</p>

<ul>
<li>receive request from web client pot :80</li>
<li>make request to <a href="http://localhost:8000" rel="nofollow noreferrer">http://localhost:8000</a> (service 1)</li>
<li>make request to <a href="http://localhost:8001" rel="nofollow noreferrer">http://localhost:8001</a> (service 2)</li>
<li>merge results</li>
<li>respond to web client with result</li>
</ul>

<p>My deployments for service 1 and 2 look like this</p>

<p>SERVICE 1</p>

<pre><code>apiVersion: v1 
kind: Service 
metadata: 
  name: serviceone 
spec: 
  selector: 
    run: serviceone 
  ports: 
    - port: 80 
      targetPort: 5050 

--- 

apiVersion: apps/v1 
kind: Deployment 
metadata: 
  name: serviceone-deployment 
spec: 
  replicas: 1 
  selector: 
    matchLabels: 
      run: serviceone 
  template: 
    metadata: 
      labels: 
        run: serviceone 
    spec: 
      containers: 
      - name: serviceone 
        image: test.azurecr.io/serviceone:v1 
        imagePullPolicy: IfNotPresent 
        ports: 
        - containerPort: 5050 
</code></pre>

<p>SERVICE 2</p>

<pre><code>apiVersion: v1 
kind: Service 
metadata: 
  name: servicetwo
spec: 
  selector: 
    run: servicetwo 
  ports: 
    - port: 80 
      targetPort: 5000 

--- 

apiVersion: apps/v1 
kind: Deployment 
metadata: 
  name: servicetwo-deployment 
spec: 
  replicas: 1 
  selector: 
    matchLabels: 
      run: servicetwo 
  template: 
    metadata: 
      labels: 
        run: servicetwo 
    spec: 
      containers: 
      - name: servicetwo 
        image: test.azurecr.io/servicetwo:v1 
        imagePullPolicy: IfNotPresent 
        ports: 
        - containerPort: 5000 
</code></pre>

<p>But I don't know what the service and deployment would look like for the main service that has to make request to two other services.</p>

<p><strong>EDIT:</strong> This is my attempt at the service/deployment for main service</p>

<pre><code>apiVersion: v1 
kind: Service 
metadata: 
  name: mainservice
spec: 
  selector: 
    run: mainservice 
  ports: 
    - port: 80 # incoming traffic from web client pod
      targetPort: 80 # traffic goes to container port 80
  selector: 
    run: serviceone 
  ports: 
    - port: ?
      targetPort: 8000 # the port the container is hardcoded to send traffic to service one
  selector: 
    run: servicetwo 
  ports: 
    - port: ? 
      targetPort: 8001  # the port the container is hardcoded to send traffic to service two  

--- 

apiVersion: apps/v1 
kind: Deployment 
metadata: 
  name: mainservice-deployment 
spec: 
  replicas: 1 
  selector: 
    matchLabels: 
      run: mainservice 
  template: 
    metadata: 
      labels: 
        run: mainservice 
    spec: 
      containers: 
      - name: mainservice 
        image: test.azurecr.io/mainservice:v1 
        imagePullPolicy: IfNotPresent 
        ports: 
        - containerPort: 80
</code></pre>

<p><strong>EDIT 2:</strong> alternate attempt at the service after finding this <a href="https://kubernetes.io/docs/concepts/services-networking/service/#multi-port-services" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#multi-port-services</a></p>

<pre><code>apiVersion: v1 
kind: Service 
metadata: 
  name: mainservice
spec: 
  selector: 
    run: mainservice 
  ports: 
    - name: incoming
      port: 80 # incoming traffic from web client pod
      targetPort: 80 # traffic goes to container port 80
    - name: s1
      port: 8080
      targetPort: 8000 # the port the container is hardcoded to send traffic to service one
    - name: s2
      port: 8081
      targetPort: 8001  # the port the container is hardcoded to send traffic to service two  
</code></pre>

erotavlas
<p>The main service doesn't need to know anything about the services it calls other than their names. Simply access those services using the name of the <code>Service</code>, i.e. <code>service1</code> and <code>service2</code> (<a href="http://service1:80" rel="nofollow noreferrer">http://service1:80</a>) and the requests will be forwarded to the correct pod.</p>

<p>Reference: <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/</a></p>
