MetalLB cannot connect to Kubernetes API

4/23/2019

I installed MetalLB to be able to expose my services via an IP my network. After the installation I tried a simple hello-world according: https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/

I noticed, that the external IP is always in state

In the logs of the controller pod I got following error message:

{"caller":"reflector.go:205","level":"error","msg":"go.universe.tf/metallb/internal/k8s/k8s.go:231: Failed to list *v1.Service: Get https://10.96.0.1:443/api/v1/services?limit=500\u0026resourceVersion=0: dial tcp 10.96.0.1:443: i/o timeout","ts":"2019-04-23T12:16:31.3694Z"}

{"caller":"reflector.go:205","level":"error","msg":"go.universe.tf/metallb/internal/k8s/k8s.go:237: Failed to list *v1.ConfigMap: Get https://10.96.0.1:443/api/v1/namespaces/metallb-system/configmaps?fieldSelector=metadata.name%3Dconfig\u0026limit=500\u0026resourceVersion=0: dial tcp 10.96.0.1:443: i/o timeout","ts":"2019-04-23T12:17:01.779341Z"}

I installed Kubernetes as usual and initialized with the following command: sudo kubeadm init --pod-network-cidr=10.21.8.128/25 --apiserver-advertise-address=10.21.8.1

In the "kube-controller-manager.yaml" I changed the size of the "node-cidr-mask" since the standard value is "/24" and my cluster size is "/25": --node-cidr-mask-size=26

I also installed flannel and Kubernetes Dashboard. Everything works fine!

I installed then MetalLB according: https://metallb.universe.tf/tutorial/layer2/

And configured MetalLB with this config:

*apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: my-ip-space
      protocol: layer2
      addresses:
      - 10.21.8.129-10.21.8.254*

Did I missed something?

-- ABC
bare-metal-server
flannel
internal-load-balancer
kubernetes
load-balancing

2 Answers

3/2/2020

A common mistake with Flannel is to set your own pod-network-cidr with kubadm init and then not put the same CIDR in Flannel's YAML manifest where they hardcoded a default CIDR in the Flannel upstream file that may be different from yours.

Check that first.

-- Tobias
Source: StackOverflow

5/3/2019

can you change the range , first try with limited range may be with single ip also you can try , i mean the addresses just mention - 10.21.8.12

-- Manoj Kasa
Source: StackOverflow