Skip to content

Commit

Permalink
add l2advertisement
Browse files Browse the repository at this point in the history
  • Loading branch information
defo89 committed Sep 26, 2024
1 parent c43195e commit 5c748f7
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- if .Values.l2Advertisement.enabled }}
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: default
namespace: {{ .Release.Namespace }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
images:
metallb-speaker: image-repository:image-tag
metallb-controller: image-repository:image-tag

speaker:
enabled: false

ipAddressPool: []

l2Advertisement:
enabled: false
12 changes: 12 additions & 0 deletions hack/api-reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,18 @@ bool
<p>EnableSpeaker enables the metallb speaker.</p>
</td>
</tr>
<tr>
<td>
<code>enableL2Advertisement</code></br>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>EnableL2Advertisement enables L2 advertisement.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="metal.provider.extensions.gardener.cloud/v1alpha1.RegionConfig">RegionConfig
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/metal/types_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ type MetallbConfig struct {

// EnableSpeaker enables the metallb speaker.
EnableSpeaker bool

// EnableL2Advertisement enables L2 advertisement.
EnableL2Advertisement bool
}
5 changes: 5 additions & 0 deletions pkg/apis/metal/v1alpha1/types_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ type MetallbConfig struct {
// IPAddressPool contains IP address pools for metallb.
// +optional
IPAddressPool []string `json:"ipAddressPool,omitempty"`

// EnableSpeaker enables the metallb speaker.
// +optional
EnableSpeaker bool `json:"enableSpeaker,omitempty"`

// EnableL2Advertisement enables L2 advertisement.
// +optional
EnableL2Advertisement bool `json:"enableL2Advertisement,omitempty"`
}
2 changes: 2 additions & 0 deletions pkg/apis/metal/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions pkg/controller/controlplane/valuesprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ var (
Name: "shoot-system-components",
EmbeddedFS: charts.InternalChart,
Path: filepath.Join(charts.InternalChartsPath, "shoot-system-components"),
Images: []string{metal.MetallbControllerImageName, metal.MetallbSpeakerImageName},
SubCharts: []*chart.Chart{
{
Name: "cloud-controller-manager",
Expand All @@ -117,10 +116,10 @@ var (
},
},
{
Name: "metallb",
Path: filepath.Join(charts.InternalChartsPath, "metallb"),
Name: "metallb",
Path: filepath.Join(charts.InternalChartsPath, "metallb"),
Images: []string{metal.MetallbControllerImageName, metal.MetallbSpeakerImageName},
Objects: []*chart.Object{
{Type: &corev1.Namespace{}, Name: "metallb-system"},
{Type: &rbacv1.ClusterRole{}, Name: "metallb:controller"},
{Type: &rbacv1.ClusterRole{}, Name: "metallb:speaker"},
{Type: &rbacv1.ClusterRoleBinding{}, Name: "metallb:controller"},
Expand All @@ -136,7 +135,6 @@ var (
{Type: &corev1.Service{}, Name: "metallb-webhook-service"},
{Type: &corev1.ServiceAccount{}, Name: "metallb-controller"},
{Type: &corev1.ServiceAccount{}, Name: "metallb-speaker"},
//{Type: &metallbv1beta1.IPAddressPool{}, Name: "default"},
},
},
},
Expand Down Expand Up @@ -370,11 +368,18 @@ func getMetallbChartValues(
if cpConfig.LoadBalancerConfig.MetallbConfig.EnableSpeaker {
enableSpeaker = true
}
enableL2 := false
if cpConfig.LoadBalancerConfig.MetallbConfig.EnableL2Advertisement {
enableL2 = true
}
return map[string]interface{}{
"enabled": true,
"speaker": map[string]interface{}{
"enabled": enableSpeaker,
},
"l2Advertisement": map[string]interface{}{
"enabled": enableL2,
},
"ipAddressPool": cpConfig.LoadBalancerConfig.MetallbConfig.IPAddressPool,
}, nil
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/controlplane/valuesprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ var _ = Describe("Valueprovider Reconcile", func() {
"speaker": map[string]interface{}{
"enabled": false,
},
"l2Advertisement": map[string]interface{}{
"enabled": false,
},
"ipAddressPool": []string{"10.10.10.0/24", "10.20.20.10-10.20.20.30"},
},
}))
Expand Down

0 comments on commit 5c748f7

Please sign in to comment.