{{- if .Values.metallb.enabled }}
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: l2advertisement1
  namespace: kube-system
spec:
  ipAddressPools:
    {{- range $key, $val := .Values.metallb.ipAddressPools }}
    {{- if eq $val.protocol "layer2" }}
    - {{ $val.name }}
    {{- end }}
    {{- end }}
---

{{- range $key, $val := .Values.metallb.ipAddressPools }}
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: {{ $val.name }}
  namespace: kube-system
spec:
  addresses:
  {{- $val.addresses | toYaml | nindent 4 }}
{{- end }}
---
{{- end }}