<p>This is a pretty basic question so I figure I must be missing something obvious, Does openshift service uses round-robin to load balance between pods? Or does it forward requests to the pod with the greatest amount of available resources? Or is it totally random?</p>
<p>My service configuration looks like that:</p>
<pre><code>kind: service
metadata:
  name: temp
  labels:
    app: temp
spec:
  port:
    targetPort: temp-port
  to:
    kind: Service
    name: temp
</code></pre>

Naama L Ackerman
<p>In Kubernetes (OpenShift is just a Kubernetes distribution), Services result in iptables rules. That means for a Service with more than one Pods, traffic is distributed / redirected via iptables to the different Pods selected by the Service.</p>
<p>So for example if we have three Pods selected by a Service, we can see the following resulting iptables entries with <code>--probability</code> on the underlying Worker Nodes:</p>
<pre><code>-A KUBE-SVC-C5D5TE7O3IX6LYPU -m comment --comment &quot;openshift-logging/fluentd:metrics&quot; -m statistic --mode random --probability 0.20000000019 -j KUBE-SEP-K7BWKR3YFNRALYRO
-A KUBE-SVC-C5D5TE7O3IX6LYPU -m comment --comment &quot;openshift-logging/fluentd:metrics&quot; -m statistic --mode random --probability 0.25000000000 -j KUBE-SEP-SLOSD6E2CHTNQQZ7
-A KUBE-SVC-C5D5TE7O3IX6LYPU -m comment --comment &quot;openshift-logging/fluentd:metrics&quot; -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-I2MJAF47DZ7EPTNC
-A KUBE-SVC-C5D5TE7O3IX6LYPU -m comment --comment &quot;openshift-logging/fluentd:metrics&quot; -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-QCINKYOFNQTK2FRX
-A KUBE-SVC-C5D5TE7O3IX6LYPU -m comment --comment &quot;openshift-logging/fluentd:metrics&quot; -j KUBE-SEP-RWL5ZKQM57XO3TAF
</code></pre>
<p>So the answer to your question is that <strong>traffic distribution via a Service is random</strong>.</p>
<p>On the other hand, an OpenShift Route provides more control over how the traffic is distributed to the Pods. You can choose different load-balancing algorithms. Available options are <code>source</code>, <code>roundrobin</code>, and <code>leastconn</code>.
You can find more options in the <a href="https://docs.openshift.com/container-platform/4.7/networking/routes/route-configuration.html" rel="nofollow noreferrer">documentation about OpenShift Routes</a>.</p>
