EN

MULTICLUSTER WITH LINKERD – PART 2

Configure MetalLB in your Kubernetes clusters for LoadBalancers. Check the assigned IPs and test connectivity. Avoid IP conflicts.

SRE/Kubernetes Admin

Adonai Costa

Part 1

Install metallb to get LoadBalancers on your clusters

helm repo add metallb https://metallb.github.io/metallbhelm repo updatefor ctx in kind-demo kind-demo3; do helm install metallb -n metallb --create-namespace metallb/metallb --kube-context=${ctx}done

Create an `ipaddresspool` for each cluster based on its kind docker network, but remember, for each cluster, a different `ipaddresspool` to avoid conflict.

To do this, first discover the IP range of your kind network

docker network inspect kind -f '{{.IPAM.Config}}'{172.17.0.0/16  172.17.0.1 map[]} {fc00:f853:ccd:e793::/64  fc00:f853:ccd:e793::1 map[]}]

Mine is `172.17.0.16`, so I will use it in the IP configuration for my `LoadBalancer` type services.

kubectl --context=kind-demo apply -f - <<EOFapiVersion: metallb.io/v1beta1kind: IPAddressPoolmetadata:  name: first-pool  namespace: metallb-systemspec:  addresses:  - 172.17.0.61-172.17.0.70---apiVersion: metallb.io/v1beta1kind: L2Advertisementmetadata:  labels:    todos: verdade  name: example  namespace: metallb-systemEOF

AND AFTER....

kubectl --context=kind-demo3 apply -f - <<EOFapiVersion: metallb.io/v1beta1kind: IPAddressPoolmetadata:  name: first-pool  namespace: metallb-systemspec:  addresses:  - 172.17.0.71-172.17.0.80---apiVersion: metallb.io/v1beta1kind: L2Advertisementmetadata:  labels:    todos: verdade  name: example  namespace: metallb-systemEOF

This is the time for you to validate if your machine can connect to a service in the clusters, of type `LoadBalancer`.

# create a simple deploy:

kubectl create deploy web --image nginx --context=kind-demo

# expose the deploy as a LoadBalancer

kubectl expose deploy web --port 80 --target-port 80 --type LoadBalancer --context=kind-demo

# verify the IP assigned to your service

kubectl get service web --context=kind-demoNAMESPACE   NAME       TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGEdefault     web        LoadBalancer   10.101.106.156   172.17.0.61   80:31507/TCP      20s

# run a test to see if it is online

curl 172.17.0.61<!DOCTYPE html><html><head><title>Welcome to nginx!</title><style>html { color-scheme: light dark; } .... bla bla bla bla```

# did it work? You can delete it

kubectl delete deploy,svc web --context=kind-demo

Do the same on the other cluster changing the `--context=kind-demo3`

In case of problems, check:

  • firewall on your machine

  • correct network of the docker network kind

  • if you have properly distributed the `ipaddresspool` in the metallbs, without repeating them in the clusters, the idea is each with its own pool of IPs for LoadBalancers, got it.


We will publish part 3 soon! Stay tuned.

Newsletter Getup.

Atualizações sobre Kubernetes e Software Supply Chain Security todos os meses.

Operating Kubernetes in production for more than 13 years. With Quor, this experience extends to software supply chain security as well.