Convert Metallb configInline to CRs for Layer 2 Protocol

I need to create k8s cluster very often in my daily job. One reason I switched from Mac to Linux was to get REAL ip address from metallb. I have everything in scripts for creating a kind cluster, installing metallb loadbalancer and ingress controller.

So when I was trying to start a new cluster like I always do today and got below error, it was quite a shock. I need to find a way to fix this quickly. 🌋

1
Error: execution error at (metallb/templates/deprecated_configInline.yaml:2:4): Starting from v0.13.0 configInline is no longer supported. Please see https://metallb.universe.tf/#backward-compatibility

I went to their website first. The Backward Compatibility section mentioned they develped a conversion tool to use. It should be quite straight forward, right? 🤗

1
2
3
4
5
6
7
8
9
10
docker run -v $(pwd):/var/input quay.io/metallb/configmaptocrs -source values.yaml
2022/07/14 01:17:41 MetalLB generator starting. commit: dev branch: dev goversion: gc / go1.18.3 / amd64
2022/07/14 01:17:41 Reading configmap
2022/07/14 01:17:41 Decoding configmap
2022/07/14 01:17:41 failed to generate resources: Object 'Kind' is missing in 'configInline:
address-pools:
- name: default
protocol: layer2
addresses:
- 172.18.18.150-172.18.18.200'

😮‍💨 Apparently the conversion tool does not work for configInline, and here is a discussion of the exact issue on their Github repo.

All I need is to pass an address pool in layer2 mode. I found the solution not on the L2 configuration page but on the Full example page.

Here is the CR equivelent to my configInline above.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: l2-ip
namespace: metallb
spec:
ipAddressPools:
- default-pool
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: default-pool
namespace: metallb
spec:
addresses:
- 172.18.18.150-172.18.18.200

I update my script and pin the chart verion to 0.13.3. I hope I will never have such surprise… 🤞