<p>I've recently started working with Kubernetes clusters. The flow of network calls for a given Kubernetes service in our cluster is something like the following:</p>

<p>External Non-K8S Load Balancer -> Ingress Controller -> Ingress Resource -> Service -> Pod</p>

<p>For a given service, there are two replicas. By looking at the logs of the containers in the replicas, I can see that calls are being routed to different pods. As far as I can see, we haven't explicitly set up any load-balancing policies anywhere for our services in Kubernetes.</p>

<p>I've got a few questions:</p>

<p>1) Is there a default load-balancing policy for K8S? I've read about kube-proxy and random routing. It definitely doesn't appear to be round-robin.
2) Is there an obvious way to specify load balancing rules in the Ingress resources themselves? On a per-service basis?</p>

<p>Looking at one of our Ingress resources, I can see that the 'loadBalancer' property is empty:</p>

<pre><code>---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
ingress.kubernetes.io/rewrite-target: /
kubectl.kubernetes.io/last-applied-configuration: |
  {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"ingress.kubernetes.io/rewrite-target":"/","nginx.ingress.kubernetes.io/rewrite-target":"/"},"name":"example-service-ingress","namespace":"member"},"spec":{"rules":[{"host":"example-service.x.x.x.example.com","http":{"paths":[{"backend":{"serviceName":"example-service-service","servicePort":8080},"path":""}]}}]}}
nginx.ingress.kubernetes.io/rewrite-target: /
  creationTimestamp: "2019-02-13T17:49:29Z"
  generation: 1
  name: example-service-ingress
  namespace: x
  resourceVersion: "59178"
  selfLink: /apis/extensions/v1beta1/namespaces/x/ingresses/example-service-ingress
  uid: b61decda-2fb7-11e9-935b-02e6ca1a54ae
spec:
  rules:
  - host: example-service.x.x.x.example.com
    http:
      paths:
      - backend:
          serviceName: example-service-service
          servicePort: 8080
status:
  loadBalancer:
    ingress:
    - {}
</code></pre>

<p>I should specify - we're using an on-prem Kubernetes cluster, rather than on the cloud.</p>

<p>Cheers!</p>

<p>The "internal load balancing" between Pods of a Service has already been covered in <a href="https://stackoverflow.com/questions/48789227/does-clusterip-service-distributes-requests-between-replica-pods">this question from a few days ago</a>.</p>

<p>Ingress isn't really doing anything special (unless you've been hacking in the NGINX config it uses) - it will use the same Service rules as in the linked question.</p>

<p>If you want or need fine-grained control of how pods are routed to within a service, it is possible to extend Kubernetes' features - I recommend you look into the traffic management features of <a href="https://istio.io" rel="nofollow noreferrer">Istio</a>, as one of its features is to be able to dynamically control how much traffic different pods in a service receive.</p>
