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.

pf9-addon-operator Image
Copy

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 API: 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.
GET API
Copy

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

  • MetalLB ClusterAddon object here with single address pool range.
Example GET API
Copy
  • Related Existing ConfigMap.
Example of Existing ConfigMap
Copy
  1. Create a new JSON spec for MetalLB.

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.

Spec Example
Copy
Example Encoded string value for parameter base64EncMetallbConfig
Copy

translates to

Example Decoded string value for base64EncMetallbConfig
Copy

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.
PATCH API
Copy
Example Patch API
Copy
  • Updated MetalLB ClusterAddon object
Example GET API Post Update
Copy
  • ConfigMap Updated After the PATCH Request.
Example of Updated ConfigMap
Copy

Additional Information

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard