Cannot access load balancer external ip address assigned by metallb installed on kind cluster using docker desktop on mac m1 from browser

843 views Asked by At

I have MAC M1 running Docker Desktop (v20.10.17). Kubernetes is NOT enabled, just the docker engine is running.

I installed Kind Cluster:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
# Can add additional control planes
#- role: control-plane
#- role: control-plane
- role: control-plane
- role: worker
- role: worker
- role: worker

I then installed Metalllb using steps from https://kind.sigs.k8s.io/docs/user/loadbalancer/

I then deployed nginx: kubectl create deploy nginx --image nginx

If I port forward, I can reach nginx from the browser.

I then exposed my deployment as a Service of type LoadBalancer: kubectl expose deploy nginx --port 8080 --type LoadBalancer

Unfortunately if I try to access the Service via the External IP Address shown, I am not able to access nginx.

Please Advise.

2

There are 2 answers

0
JPSur On

LoadBalancers work by utilizing load balancers on cloud providers like GCP or AWS so a locally running Kind cluster would probably use a NodePort service instead of Loadbalancer in your deployment/StatefulSet to expose nginx but double check the options.

Currently working on a Kind deployment for Postgres and when I ran into similar issues with connectivity and port fowarding, the solution was to add a listen address to the Kind config file - in both cases the issue being to make service accessible outside of the cluster. I believe you can also expose an externalIP like below but test it out.

kind-config.yaml (some values from Postgres)

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  # port forward 5432 on the host to 5432 on this node
  extraPortMappings:
  - containerPort: 5432
    hostPort: 5432
    # optional: set the bind address on the host
    # 0.0.0.0 is the current default
    listenAddress: "127.0.0.1"
    # optional: set the protocol to one of TCP, UDP, SCTP.
    # TCP is the default
    protocol: TCP
networking:
  ipFamily: ipv4
  apiServerAddress: 192.168.1.175
  apiServerPort: 10000

4
Mauricio Caro On

The issue, as stated in Kind - Load Balancer is that: "With Docker on Linux, you can send traffic directly to the loadbalancer’s external IP if the IP space is within the docker IP space.

On macOS and Windows, docker does not expose the docker network to the host."

The workaround I found is to use Docker Mac Net Connect.

I also have a Mac M1 and I am running Docker Desktop 4.25.2 (129061).