Enable the MetalLB support

Enable the MetalLB support

MetalLB is a Kubernetes add-on that provides a network load balancer for bare metal Kubernetes clusters using standard routing protocols. It provides external IP addresses to the workloads services, for example, NGINX, from the pool of addresses defined in the MetalLB configuration.

To enable MetalLB support on a bare metal Kubernetes cluster:

  1. While generating a deployment metadata model for your new MCP Kubernetes cluster as described in Create a deployment metadata model, select the Kubernetes metallb enabled option in the Infrastructure parameters section of the Model Designer UI.

  2. If you have already generated a deployment metadata model without the MetalLB parameter or to enable this feature on an existing Kubernetes cluster:

    1. Open your Reclass model Git project repository on the cluster level.

    2. In /kubernetes/control.yml, add the MetalLB parameters. For example:

      parameters:
        kubernetes:
          common:
            addons:
              ...
              metallb:
                enabled: true
                  addresses:
                  - 172.16.10.150-172.16.10.180
                  - 172.16.10.192/26
      

      For the addresses parameter, define the required pool of IP addresses.

  3. Select from the following options:

    • If you are performing an initial deployment of your cluster, proceed with further configuration as required. MetalLB will be installed during your Kubernetes cluster deployment.

    • If you are making changes to an existing cluster:

      1. Log in to the Salt Master node.

      2. Refresh your Reclass storage data:

        salt-call state.sls reclass.storage
        
      3. Apply the kube-addons state:

        salt -C 'I@kubernetes:master' state.sls kubernetes.master.kube-addons
        

To verify MetalLB after deployment:

  1. Log in to any Kubernetes Master node.

  2. Verify that the MetalLB pods are created:

    kubectl get pods --namespace metallb-system
    

    Example of system response:

    NAME                          READY     STATUS    RESTARTS   AGE
    controller-79876bc7cc-8z2bh   1/1       Running   0          20h
    speaker-ckn49                 1/1       Running   0          21h
    speaker-dr65f                 1/1       Running   0          21h
    
  3. Create two NGINX pods that listen on port 80:

    kubectl run my-nginx --image=nginx --replicas=2 --port=80
    
  4. Expose the NGINX pods to the Internet:

    kubectl expose deployment my-nginx --port=80 --type=LoadBalancer
    
  5. Verify that NGINX obtained an EXTERNAL-IP address from the pool of addresses defined in the MetalLB configuration.

    kubectl get svc
    

    Example of system response:

    NAME         TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
    kubernetes   ClusterIP      10.254.0.1      <none>        443/TCP        23h
    my-nginx     LoadBalancer   10.254.96.233   172.16.10.150 80:31983/TCP   7m