diff --git a/k8s/manifests/charts/ck-loadbalancer/templates/metallb/bgp-policy.yaml b/k8s/manifests/charts/ck-loadbalancer/templates/metallb/bgp-policy.yaml index 1e52bcf769..bc66583e37 100644 --- a/k8s/manifests/charts/ck-loadbalancer/templates/metallb/bgp-policy.yaml +++ b/k8s/manifests/charts/ck-loadbalancer/templates/metallb/bgp-policy.yaml @@ -15,5 +15,17 @@ spec: peerPort: {{ .peerPort }} {{- end }} +--- + +apiVersion: "metallb.io/v1beta1" +kind: BGPAdvertisement +metadata: + name: {{ include "ck-loadbalancer.fullname" $ }} + labels: + {{- include "ck-loadbalancer.labels" $ | nindent 4 }} +spec: + ipAddressPools: + - {{ include "ck-loadbalancer.fullname" . }} + {{- end }} {{- end}} diff --git a/k8s/manifests/charts/ck-loadbalancer/templates/metallb/lb-ip-pool.yaml b/k8s/manifests/charts/ck-loadbalancer/templates/metallb/lb-ip-pool.yaml index a17b13203f..30acb82b9b 100644 --- a/k8s/manifests/charts/ck-loadbalancer/templates/metallb/lb-ip-pool.yaml +++ b/k8s/manifests/charts/ck-loadbalancer/templates/metallb/lb-ip-pool.yaml @@ -1,4 +1,4 @@ -{{- if .Values.l2.enabled }} +{{- if (gt (len .Values.ipPool.cidrs) 0) }} {{- if (eq .Values.driver "metallb") }} apiVersion: "metallb.io/v1beta1" diff --git a/src/k8s/pkg/k8sd/features/metallb/loadbalancer.go b/src/k8s/pkg/k8sd/features/metallb/loadbalancer.go index 376ebcb44e..2e3977890d 100644 --- a/src/k8s/pkg/k8sd/features/metallb/loadbalancer.go +++ b/src/k8s/pkg/k8sd/features/metallb/loadbalancer.go @@ -45,7 +45,7 @@ func enableLoadBalancer(ctx context.Context, snap snap.Snap, loadbalancer types. } if err := waitForRequiredLoadBalancerCRDs(ctx, snap, loadbalancer.GetBGPMode()); err != nil { - return fmt.Errorf("failed to wait for required LoadBalancer CRDs: %w", err) + return fmt.Errorf("failed to wait for required MetalLB CRDs: %w", err) } cidrs := []string{} @@ -101,10 +101,11 @@ func waitForRequiredLoadBalancerCRDs(ctx context.Context, snap snap.Snap, bgpMod "ipaddresspools": {}, "l2advertisements": {}, } - // TODO - // if bgpMode { - // requiredCRDs["ciliumbgppeeringpolicies"] = struct{}{} - // } + if bgpMode { + requiredCRDs["bgppeers"] = struct{}{} + requiredCRDs["bgpadvertisements"] = struct{}{} + } + requiredCount := len(requiredCRDs) for _, resource := range resources.APIResources { if _, ok := requiredCRDs[resource.Name]; ok {