- Running on MacOS
- Install Docker Desktop
- Install Kind
- Install Docker Mac Net Connect
- Create a cluster:
kind create cluster --config kind-cluster.yaml
- Instal Ingress NGINX Controller:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
- Install 2 pods, their corresponding services and an Ingress:
kubectl apply -f ingress-service.yaml
- Test:
curl localhost/foo/hostname
returns 'foo-app'
curl localhost/bar/hostname
returns 'bar-app' - Install MetalLB:
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml
- Find out CIDR used by the Docker network used by the kind cluster:
docker network inspect -f '{{.IPAM.Config}}' kind
- Verify that 'spec.addresses' in 'metallb-config.yaml' are comprised in the kind network CIDR. Modify the file if required.
- Configure MetalIB:
kubectl apply -f metallb-config.yaml
- Create a Service of type LoadBalancer that load balances across the previously created pods:
kubectl apply -f lb-service.yaml
- Test the load balanced service through the Ingress:
curl localhost/foo-bar/hostname
return 'foo-app' or 'bar-app' approximately evenly distributed - Test the load balancer directly:
LB_IP=`kubectl get svc foo-bar-service -o json | jq ".status.loadBalancer.ingress.[].ip" | tr -d '"'`
curl $LB_IP/hostname
return 'foo-app' or 'bar-app' approximately evenly distributed