Search code examples
minikubemetallb

minikube metallb external-ip vs minikube ip


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


Solution

  • 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.