<p>I created two replicas of nginx with following yaml:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.20-alpine
          ports:
            - containerPort: 80
</code></pre>
<p>And I created service with:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx-test-service
spec:
  selector:
    app: nginx
  ports:
    - port: 8082
      targetPort: 80
</code></pre>
<p>Everything looks good. But when I do</p>
<pre><code>minikube service nginx-test-service
</code></pre>
<p>I am able to access the nginx. But when I see the two pods logs, the request is always going to single pod. The other pod is not getting any request.</p>
<p>But, kubernetes service should do the load balancing right?</p>
<p>Am I missing anything?</p>

Healthy Bowl
<p>One way to get load balancing on-premise running is with ip virtual services. (ipvs). It;s a service which hands out ip's of the next pod to schedule/call</p>
<p>it's likely installed already.</p>
<pre><code>lsmod | grep ip_vs
ip_vs_sh               16384  0
ip_vs_wrr              16384  0
ip_vs_rr               16384  19
</code></pre>
<p>Have your cni properly setup and run</p>
<pre><code>kubectl edit cm -n kube-system kube-proxy
</code></pre>
<p>edit the ipvs section</p>
<p>set mode to ipvs</p>
<p>mode: &quot;ipvs&quot;</p>
<p>and the ipvs section</p>
<pre><code>ipvs:
      excludeCIDRs: null
      minSyncPeriod: 0s
      scheduler: &quot;rr&quot;
</code></pre>
<p>As always there are lots of variables biting each other with k8s, but it is possible with ipvs.</p>
<p><a href="https://kubernetes.io/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive/" rel="nofollow noreferrer">https://kubernetes.io/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive/</a></p>
