Metallb Failed to allocate IP

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version:
Cloud being used: onpremise
Installation method: kubespray
Host OS: Debian GNU/Linux 11 (bullseye)
CNI and version: v1.25.0
CRI and version: v1.25.0

root@master20-2 /home/server/kube/metallb # kubectl get nodes -o wide
NAME         STATUS   ROLES           AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE
             KERNEL-VERSION    CONTAINER-RUNTIME
master20-2   Ready    control-plane   2d    v1.25.5   10.20.1.2     <none>        Debian GNU/Linux 11 (bullseye)   5.10.0-20-amd64   containerd://1.6.15
node10-2     Ready    <none>          2d    v1.25.5   10.10.1.2     <none>        Debian GNU/Linux 11 (bullseye)   5.10.0-19-amd64   containerd://1.6.15
node10-3     Ready    <none>          2d    v1.25.5   10.10.1.3     <none>        Debian GNU/Linux 11 (bullseye)   5.10.0-22-amd64   containerd://1.6.15
node40-2     Ready    <none>          2d    v1.25.5   10.40.1.2     <none>        Debian GNU/Linux 11 (bullseye)   5.10.0-19-amd64   containerd://1.6.15
root@master20-2 /home/server/kube/metallb # ls
metallb_config.yml  my_svc.yml
root@master20-2 /home/server/kube/metallb # cat *
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: my-ip
      protocol: layer2
      addresses:
      - 10.10.1.10-10.10.1.255
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: my-app
  ports:
  - name: http
    port: 80
    targetPort: 80
  type: LoadBalancer
root@master20-2 /home/server/kube/metallb # kubectl get svc
NAME         TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP      10.233.0.1     <none>        443/TCP        2d
my-service   LoadBalancer   10.233.3.145   <pending>     80:30598/TCP   6m9s
root@master20-2 /home/server/kube/metallb # kubectl describe svc my-service
Name:                     my-service
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=my-app
Type:                     LoadBalancer
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.233.3.145
IPs:                      10.233.3.145
Port:                     http  80/TCP
TargetPort:               80/TCP
NodePort:                 http  30598/TCP
Endpoints:                <none>
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type     Reason            Age    From                Message
  ----     ------            ----   ----                -------
  Warning  AllocationFailed  6m19s  metallb-controller  Failed to allocate IP for "default/my-service": no available IPs
root@master20-2 /home/server/kube/metallb # kubectl -n metallb-system get all
NAME                              READY   STATUS    RESTARTS   AGE
pod/controller-844979dcdc-ptd7k   1/1     Running   0          76m
pod/speaker-fz489                 1/1     Running   0          76m
pod/speaker-jm7f8                 1/1     Running   0          76m
pod/speaker-ssvn6                 1/1     Running   0          76m
pod/speaker-vld5k                 1/1     Running   0          76m
pod/speaker-xph9p                 1/1     Running   0          76m

NAME                      TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE
service/webhook-service   ClusterIP   10.233.3.18   <none>        443/TCP   77m

NAME                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR
 AGE
daemonset.apps/speaker   5         5         5       5            5           kubernetes.io/os=linux   77m

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/controller   1/1     1            1           77m

NAME                                    DESIRED   CURRENT   READY   AGE
replicaset.apps/controller-844979dcdc   1         1         1       76m

In an infrastructure with the following structure, there are nodes in VLAN10, VLAN20, and VLAN40. However, even after configuring it as shown above, the load balancer external IP doesn’t work. I configured the DHCP range as 10.10.1.0/24, with a scope from 10.10.1.2 to 10.10.1.255. I also configured other LAN IPs, for example, 192.168.2.10 to 192.168.2.255, but it still doesn’t work. The WAN IP is 192.168.35.168, and the WAN subnet is also 192.168.35.0/24. I can’t figure out why the IP is not being applied to the load balancer service. Is there any possible solution?