Jump to: navigation, search

StarlingX/Containers/Applications/app-metallb

StarlingX MetalLB App installation guide

app-metallb is a StarlingX containerized application that deploys MetalLB to provide Kubernetes LoadBalancer services for clusters running on bare metal or non-cloud environments.

MetalLB integrates with the StarlingX networking model to advertise service IP addresses using either BGP or Layer 2 (ARP/NDP) mechanisms, enabling external connectivity to Kubernetes services without relying on a cloud provider load balancer.


Source


Tarball Package

  • Get the .tgz file located at
   /usr/local/share/applications/helm/
  • Or build it yourself using the Debian Build environment
   build-pkgs -c -p metallb-helm,python3-k8sapp-metallb,stx-metallb-helm


Deployment Architecture

MetalLB is deployed into the metallb-system namespace and consists of:

  • metallb-controller Deployment
  • metallb-speaker DaemonSet
  • Optional FRR containers when BGP mode is enabled


In BGP mode, the speaker establishes BGP sessions with configured peers and advertises service IPs as host routes.

Usage

  • Apply the app
   [root@controller-0 sysadmin(keystone_admin)]# system application-apply metallb
  • Verify MetalLB controller and speaker pods are running
   [root@controller-0 sysadmin(keystone_admin)]# kubectl get pods -n metallb-system
   NAME                                 READY   STATUS    RESTARTS   AGE
   metallb-controller-bbfd4845b-gknmx   1/1     Running   0          75s
   metallb-speaker-tfwmz                1/1     Running   0          75s

Simple L2 mode example

  • Apply the configuration for the IPAddressPool and "L2Advertisement".
   [root@controller-0 sysadmin(keystone_admin)]# cat metallb-l2.yaml
   apiVersion: metallb.io/v1beta1
   kind: IPAddressPool
   metadata:
     name: l2-pool
     namespace: metallb-system
   spec:
     addresses: ["192.168.206.200-192.168.206.210"]
     avoidBuggyIPs: true
   ---
   apiVersion: metallb.io/v1beta1
   kind: L2Advertisement
   metadata:
     name: metallb-adv
     namespace: metallb-system
   spec:
     ipAddressPools:
       - l2-pool
  • Apply a simple nginx service that a host outside the cluster can access
   [root@controller-0 sysadmin(keystone_admin)]# cat nginx.yaml
   apiVersion: apps/v1
   kind: Deployment
   metadata:
     name: nginx-test
   spec:
     replicas: 1
     selector:
       matchLabels:
         app: nginx-test
     template:
       metadata:
         labels:
           app: nginx-test
       spec:
         containers:
         - name: nginx
           image: nginx:latest
           ports:
           - containerPort: 80
   ---
   apiVersion: v1
   kind: Service
   metadata:
     name: nginx-service
   spec:
     type: LoadBalancer
     selector:
       app: nginx-test
     ports:
     - port: 80
       targetPort: 80
  • Notice that the MetalLB controller assigns the nginx service an external IP while the speaker is announcing that IP.
   [root@controller-0 sysadmin(keystone_admin)]# kubectl get svc nginx-service
   NAME            TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)        AGE
   nginx-service   LoadBalancer   10.111.148.132   192.168.206.200   80:30966/TCP   6s
   [root@controller-0 sysadmin(keystone_admin)]# kubectl describe svc nginx-service
   ...
   Events:
     Type    Reason        Age   From                Message
     ----    ------        ----  ----                -------
     Normal  IPAllocated   23s   metallb-controller  Assigned IP ["192.168.206.200"]
     Normal  nodeAssigned  12s   metallb-speaker     announcing from node "controller-0" with protocol "layer2"