<p>So I am setting up an entire stack on Google Cloud and I have several components that need to talk with each other, so I came up with the following flow:</p>

<p>Ingress -> Apache Service -> Apache Deployment (2 instances) -> App Service -> App Deployment (2 instances)</p>

<p>So the Ingress divides the requests nicely among my 2 Apache instances but the Apache Deployments don't divide it nicely among my 2 App deployments.</p>

<p>The services (Apache and App) are in both cases a NodePort service.</p>

<p>What I am trying to achieve is that the services (Apache and App) loadbalance the requests they receive among their linked deployments, but I don't know if NodePort service can even do that, so I was wondering how I could achieve this.</p>

<p>App service yaml looks like this:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: preprocessor-service
  labels:
    app: preprocessor
spec:
  type: NodePort
  selector:
    app: preprocessor
  ports:
  - port: 80
    targetPort: 8081
</code></pre>

darkownage
<p>If you are going through the <strong>clusterIP</strong> and are using the default proxy mode to be <a href="https://kubernetes.io/docs/concepts/services-networking/service/#proxy-mode-iptables" rel="nofollow noreferrer">iptables</a>, then the <code>NodePort</code> service will do a random approach (Kubernetes 1.1 or later), this is called <a href="https://kubernetes.io/docs/concepts/services-networking/service/#proxy-mode-iptables" rel="nofollow noreferrer">iptables proxy mode</a>. For earlier Kubernetes 1.0 the default was <a href="https://kubernetes.io/docs/concepts/services-networking/service/#proxy-mode-userspace" rel="nofollow noreferrer">userspace proxy mode</a> which does round robin.  If you want to control this behavior you can use the <a href="https://kubernetes.io/docs/concepts/services-networking/service/#proxy-mode-ipvs" rel="nofollow noreferrer">ipvs proxy mode</a>.</p>

<p>When I say <strong>clusterIP</strong> I mean the IP address that is only understood by the cluster such as the one below:</p>

<pre><code>$ kubectl get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
http-svc     NodePort    10.109.87.179    &lt;none&gt;        80:30723/TCP     5d
kubernetes   ClusterIP   10.96.0.1        &lt;none&gt;        443/TCP          69d
</code></pre>

<p>When you specify <code>NodePort</code> it should also be a mesh across all of your cluster nodes. In other words, all the nodes in your cluster will listen on their external IP on that particular port, however, you'll get a response from your application or pod if it happens to run on that particular node.  So you can potentially set up an external load balancer that points its backend that specific <code>NodePort</code> and traffic would be forwarded according to a healthcheck on the port.</p>

<p>I'm not sure in your case, is it possible that you are not using the <code>clusterIP</code>?</p>
