Score:1

K8s - How trigger refresh of LoadBalancer svc IP?

za flag

I'm using metallb to assign IPs to LoadBalancers in a home lab k8s cluster. I've had to shrink the IP pool though as I need to use some of them in another test cluster.

I've done this but the IPs of the existing LB svcs have remained the same afterwards -- I need to give the LB svcs a kick somehow to get them to request new IPs. How can I do this?

Score:1
id flag

It looks like the answer to your question is contained in this github thread.

Everything should come down to recreate your service with the appropriate configmap. Look at this answer:

Before change

[root@m-k8s ~]# kubectl get services
NAME         TYPE           CLUSTER-IP      EXTERNAL-IP    PORT(S)        AGE
cfgmap-svc   LoadBalancer   10.100.199.95   192.168.1.11   80:31463/TCP   2m5s
kubernetes   ClusterIP      10.96.0.1       <none>         443/TCP        4h13m


Change IP address

[root@m-k8s ~]# cat metallb-l2.yaml | grep 192.168
      - 192.168.1.11-192.168.1.13
[root@m-k8s ~]# sed -i 's/11/101/;s/13/103/' metallb-l2.yaml
[root@m-k8s ~]# cat metallb-l2.yaml | grep 192.168
      - 192.168.1.101-192.168.1.103

Just apply
kubectl apply -f metallb-l2.yaml

Delete and revise by kubelet

[root@m-k8s ~]# kubectl delete pods --all -n metallb-system
pod "controller-65895b47d4-l5xnn" deleted
pod "speaker-bk8gr" deleted
pod "speaker-bksns" deleted
pod "speaker-c2z6z" deleted
pod " speaker-chlt5" deleted
pod "speaker-scx6x" deleted


Recreate svc

[root@m-k8s ~]# kubectl delete service cfgmap-svc
service "cfgmap-svc" deleted
[root@m-k8s ~]# kubectl expose deployment cfgmap --type=LoadBalancer --name=cfgmap-svc --port=80
service/cfgmap-svc exposed

Check svc

[root@m-k8s ~]# kubectl get svc
NAME          TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)        AGE
cfgmap-svc3   LoadBalancer   10.104.192.184   192.168.1.101   80:31440/TCP   8s
kubernetes    ClusterIP      10.96.0.1        <none>          443/TCP        4h34m

You can also look at this github issue. Note, it is old thread.

za flag
Thanks this pointed me in the right direction. In fact all I had to do was delete the pods (I'd already updated the configmap). `kubectl -n metallb delete pod --all` The services all obtained new IPs from the new pool once the new metallb pods were running.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.