2

enter image description here

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
  labels:
    app: metallb

data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.99.100-192.168.99.250

Hello, I am using metallb in minikube (virtualbox). When configuring metallb's external-ip, you must set it according to the minikube ip range. But why does it work well even out of range?

enter image description here

hochan
  • 220
  • 3
  • 10

1 Answers1

2

This behavior is working as expected due to your Layer 2 configuration of your MetalLB:

Layer 2 mode is the simplest to configure: in many cases, you don’t need any protocol-specific configuration, only IP addresses.

Layer 2 mode does not require the IPs to be bound to the network interfaces of your worker nodes. It works by responding to ARP requests on your local network directly, to give the machine’s MAC address to clients.

In your ConfigMap we see:

data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.99.100-192.168.99.250

It gives MetalLB control over IPs from 192.168.99.100 to 192.168.99.250 and configures the Layer 2 mode. Notice that your minikube IP which is 192.168.99.102 is in the range defined above and thus you can access it via your browser.

This mechanic is well explained in the MetalLB Layer 2 Configuration section of this guide:

MetalLB contains two pieces of information, a protocol and range of IP addresses. In this configuration MetalLB is instructed to handout addresses from the 192.168.99.95/105, its our predefined range with respect to node IP. In our case to get IP of our minikube we use minikube ip command and set range accordingly in config file.

I recommend going through the whole guide to get a better understanding of the whole minikube + MetalLB concept.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
  • 1
    @hochan Is my answer useful for you? – Wytrzymały Wiktor Nov 05 '20 at 10:58
  • 1
    Thank you for answering first. It was very useful. However, the reason that the answer check was delayed is because I wanted to accumulate more knowledge and thank you with a quality answer. Actually, during the port connection process, a little problem occurred in the pv setting, so I could not experiment with the real environment. – hochan Nov 10 '20 at 13:45
  • In fact, I don't understand because I think the address part described in the matallb configmap should belong to the minikube ip, but the configuration I made is because the minikube ip belongs to the address part of the matallb configmap. After a little understanding, I would like to express my gratitude. – hochan Nov 10 '20 at 13:48