How To Add/Modify Existing MetalLB Configuration via API

Problem

How To Add/Modify Existing MetalLB Configuration via API on a PMK cluster?

Environment

  • Platform9 Managed Kubernetes

  • AddOn Operator v4.0.0 & MetalLB v0.9.7 and Above

Procedure

Verify the pf9-addon-operator version on the cluster.

# kubectl describe deployment pf9-addon-operator -n pf9-addons | grep -i image
    Image:      platform9/pf9-addon-operator:5.0.0
circle-info

Info

One can add/modify the set/existing MetalLB configuration as desired by following the steps below.

Note: For Cluster running pf9-addon-operator version below 4.0.0, set the watch attribute in the MetalLB ClusterAddOn object to false and then make changes to the MetalLB configmap directly so that the AddOn operator will not revert the changes made to the configmap. Note that the same will be overwritten post cluster upgrade.

  1. Fetch the authentication TOKEN. Keystone Identity APIarrow-up-right: This link describes the process for getting a Keystone authentication token in order to access the PMK REST API.

  2. API to retrieve currently set MetalLB ClusterAddon object details.

curl -X GET -H "X-Auth-Token: $TOKEN" https://<DU_FQDN>/qbert/v4/<PROJECT_ID>/sunpike/apis/sunpike.platform9.com/v1alpha2/namespaces/default/clusteraddons/<CLUSTER_UUID>-metallb
circle-info

Info

Replace the placeholders <DU_FQDN>, <PROJECT_ID> and the <CLUSTER_UUID> with their appropriate values.

  • MetalLB ClusterAddon object here with single address pool range.

  • Related Existing ConfigMap.

  1. Create a new JSON spec for MetalLB.

circle-info

Info

Replace the values for clusterID & sunpike.pf9.io/cluster with required CLUSTER_UUID.

The name attribute in the spec must be in the format CLUSTER_UUID-metallb.

translates to

circle-info

Note

In the above example, we are passing base64EncMetallbConfig string which includes Multiple Named Address Pools which have different IP allocations than the original MetallbIpRange.

  1. Patching the existing MetalLB ClusterAddon object with the above-mentioned new JSON spec metallbaddon.json.

  • Updated MetalLB ClusterAddon object

  • ConfigMap Updated After the PATCH Request.

Additional Information

Last updated