<p>I have a simple microservice setup running in a minikube cluster. It is inspired by <a href="https://github.com/GoogleCloudPlatform/microservices-demo" rel="nofollow noreferrer">this example.</a>
My setup includes a simple <code>router</code> microservice that contains a golang webserver. What I want to test now is the loadbalancing when there is more then one pod. But there seems to be no load-balancing whatsoever.</p>

<p>The kubernetes file for the microservices looks like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: router
  labels:
    app: router
    tier: router
spec:
  replicas: 2
  strategy: {}
  template:
    metadata:
      labels:
        app: router
        tier: router
    spec:
      containers:
      - image: {myregistry}/router
        name: router
        resources: {}
        ports:
          - name: target-port
            containerPort: 8082
        env:
          - name: PORT
            value: "8082"
status: {}
---
apiVersion: v1
kind: Service
metadata:
  name: router
  labels:
    app: router
    tier: router
spec:
  type: LoadBalancer
  selector:
    app: router
    tier: router
  ports:
  - port: 8082
    name: http
    targetPort: target-port
</code></pre>

<p>The skaffold config looks like this:</p>

<pre><code>apiVersion: skaffold/v1beta2
kind: Config
build:
  artifacts:
  - image: {myregistry}/router
    context: src/router/bin
  tagPolicy:
    gitCommit: {}
  local:
    push: false
deploy:
  kubectl:
    manifests:
    - ./kubernetes/**.yaml
</code></pre>

<p>Kubernetes correctly deploys two pods. The output of <code>kubectl get pods</code> looks like this:</p>

<pre><code>NAME                           READY   STATUS    RESTARTS   AGE
router-7f75f6f9df-c8mgp        1/1     Running   0          14m
router-7f75f6f9df-k248m        1/1     Running   0          14m
</code></pre>

<p>From the <code>skaffold dev</code> log output I can see that every request is routed to the <code>router-7f75f6f9df-c8mgp</code> pod. Even with different browsers all requests end up at the exact same pod. </p>

<p>When I delete this pod there is even a slight downtime of the router microservice even though there is another pod running.</p>

<p>What could be the problem of this behavior?</p>

jrenk
<p>minikube doesn't 'properly' support the LoadBalancer service type. It used to be commonplace to just use the NodePort or externalIP service type instead, however the official <a href="https://kubernetes.io/docs/tutorials/hello-minikube/" rel="nofollow noreferrer">hello-minikube</a> sample now states:</p>

<blockquote>
  <p>On cloud providers that support load balancers, an external IP address
  would be provisioned to access the Service. On Minikube, the
  LoadBalancer type makes the Service accessible through the minikube
  service command</p>
</blockquote>

<p>So effectively you should be able to use your minikube LoadBalancer service with: <code>minikube service router</code></p>

<p>However there is a neat solution that was developed for bare-metal kubernetes clusters called <strong>metallb</strong> that may be able to help you test this in a better way on minikube.</p>

<p>You can install and configure it on minikube. E.g.</p>

<p><code>kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.1/manifests/metallb.yaml</code></p>

<p>Here are some blog posts where others have explained the setup and use of metallb with minikube for LoadBalancer support:</p>

<p><a href="https://medium.com/@emirmujic/istio-and-metallb-on-minikube-242281b1134b" rel="nofollow noreferrer">Blog Post 1</a>
<a href="https://ervikrant06.github.io/kubernetes/metallb-LB-on-minikube/" rel="nofollow noreferrer">Blog Post 2</a></p>

<p>Here are the <a href="https://metallb.universe.tf/" rel="nofollow noreferrer">official docs</a>.</p>

<p>Hope that helps!</p>
