Minikube: LoadBalancer support

Created on 22 Jul 2016  Â·  16Comments  Â·  Source: kubernetes/minikube

Trying to understand where this is on the roadmap. I understand it's currently not supported but is there opposition to adding it?

Currently a lot of Kubernetes examples uses LoadBalancer. Sure, easy to replace with NodePort, but it would be ideal if we could run those with no modifications on minikube.

Since LoadBalancer is already "cloud dependent", Minikube could likewise just make its own decision, which could be something simple (nginx, mapping to nodeport somehow, etc). Of course it will evolve over time, add Ingress support etc but this is the one feature that would enable a lot of the getting started examples to work:

Getting started examples that use LoadBalancer and not much else:

https://github.com/kubernetes/kubernetes/blob/master/examples/guestbook/frontend-service.yaml

https://github.com/GoogleCloudPlatform/getting-started-python/blob/master/optional-container-engine/bookshelf-service.yaml

http://www.thagomizer.com/blog/2015/07/01/kubernetes-and-deploying-to-google-container-engine.html

Most helpful comment

LoadBalancer services run fine on minikube, just with no real external load balancer created. LoadBalancer services get a node port assigned too so you can access services via minikube service <name> to open browser or add --url flag to output service URL to terminal.

Would that cover what you need or is there something more that you'd like to see?

All 16 comments

LoadBalancer services run fine on minikube, just with no real external load balancer created. LoadBalancer services get a node port assigned too so you can access services via minikube service <name> to open browser or add --url flag to output service URL to terminal.

Would that cover what you need or is there something more that you'd like to see?

Ah I didn't know about that feature, cool thanks.

Why not support that minikube could give some address form internal pool that could be accessible from dev machine?

Just to avoid port mapping, and this could make access to services much easier.

Could the getting started examples be updated to include @jimmidyson 's comment? It would be tremendously helpful if this information were easier to find.

@bryanerayner PRs are always welcome

i'm running something like:

apiVersion: v1
kind: Service
metadata:
  name: my-ftp
spec:
  ports:
  - port: 22
  selector:
    app: my-ftp
  type: LoadBalancer

but minikube seems to be having an issue exposing the service:

⋊> kubectl get svc my-ftp                                                      
NAME      CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
my-ftp   10.0.0.47    <pending>     22:31253/TCP   5m

i can access the service via the internal port 31253, but not the exposed 22...?
is this just the expected behavior with LoadBalancer...?

i'm running mk v0.18.0/osx/virtualbox

@tony-kerz , it looks like the expected behavior to me... Your pods are available on port 22 inside the cluster and are exposed to the host by the load balancer on a random port (31253 in your example). https://github.com/kubernetes/minikube/issues/38 aims to improve this behavior.

FYI, I finally have a doc on implementing this here: https://github.com/kubernetes/minikube/pull/2413

@gkubisa I'm having situation similar to @tony-kerz, the EXTERNAL-IP is always pending and minikube service spring-boot-publisher --url does not work (Waiting, endpoint for service is not ready yet...)

EDIT: I resolved the problem, minikube shows the URL and the address works. However, I'd want the URL to use the port number I defined for the load balancer, not a random port.

@asfernandes

EDIT: I resolved the problem, minikube shows the URL and the address works. However, I'd want the URL to use the port number I defined for the load balancer, not a random port.

Great to hear the pending external IP issue can be resolved! Would you mind to share how you did it?

@steveeJ ..

Run the following commands to get the external IP:

  1. kubectl get services --namespace= ( will give three pods, including loadbalancer)
  2. minikube service --namespace=

A temporary workaround https://github.com/knative/serving/blob/master/docs/creating-a-kubernetes-cluster.md#loadbalancer-support-in-minikube.

Any official solution here?

The documentation above is not available.

It's now April 2019 and I am still having this issue of the service being pending. Should I open a new issue?

It is still available at:

https://github.com/knative/serving/blob/b31d96e03bfa1752031d0bc4ae2a3a00744d6cd5/docs/creating-a-kubernetes-cluster.md#loadbalancer-support-in-minikube

The key commands are

sudo ip route add $(cat ~/.minikube/profiles/minikube/config.json | jq -r ".KubernetesConfig.ServiceCIDR") via $(minikube ip)
kubectl run minikube-lb-patch --replicas=1 --image=elsonrodriguez/minikube-lb-patch:0.1 --namespace=kube-system

When creating a LoadBalancer services, why doesn't Minikube just assign a new IP address within the loopback range 127.0.0.0/8?

Minikube is mostly for development, so having a loopback address would be sufficient. I vote for 127.42.0.* to keep it outside the normal range of 127.0.0.* and just to reference The Hitchhikers Guide to the Galaxy.

When using the docker-desktop context provided (k8s v1.16.5 macOS v10.15.4) the EXTERNAL-IP is assigned and I am able to connect from local machine via "http://127.0.0.1:3000":

apiVersion: v1
kind: Service
metadata:
  labels:
    app: mgmt-ui
  name: mgmt-ui
  namespace: default
spec:
  ports:
  - name: 3000-3000
    port: 3000
    protocol: TCP
    targetPort: 3000
  selector:
    app: mgmt-ui
  type: LoadBalancer

That does not work when using a context that I create via minikube start --profile mgmt-cluster. Sadly, I have to either hit it via the minikube IP or minikube tunnel. I will start digging to see what docker-deskop does under the hood. I would prefer to be able to spin up my own clusters and not rely on the docker-desktop one.

Was this page helpful?
0 / 5 - 0 ratings