Skip to content
This repository was archived by the owner on Mar 27, 2026. It is now read-only.

Commit 344e307

Browse files
author
Wolfgang Nagele
authored
Add config option for MTU setting (#20)
1 parent 0853b18 commit 344e307

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

cmd/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func main() {
6868
var probeAddr string
6969
var secureMetrics bool
7070
var enableHTTP2 bool
71+
var mtu int
7172
var tlsOpts []func(*tls.Config)
7273
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
7374
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
@@ -86,6 +87,8 @@ func main() {
8687
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
8788
flag.BoolVar(&enableHTTP2, "enable-http2", false,
8889
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
90+
flag.IntVar(&mtu, "mtu", 1372,
91+
"The MTU to configure for CNI network interfaces.")
8992
opts := zap.Options{
9093
Development: true,
9194
}
@@ -219,6 +222,7 @@ func main() {
219222
Client: mgr.GetClient(),
220223
Scheme: mgr.GetScheme(),
221224
Identifier: identifier.New(),
225+
MTU: mtu,
222226
}).SetupWithManager(mgr); err != nil {
223227
setupLog.Error(err, "unable to create controller", "controller", "VPCAttachment")
224228
os.Exit(1)

internal/cniconfig/cniconfig.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type PluginConfGalactic struct {
2525
IPAM cni.IPAM `json:"ipam,omitempty"`
2626
}
2727

28-
func CNIConfigForVPCAttachment(vpc galacticv1alpha.VPC, vpcAttachment galacticv1alpha.VPCAttachment) (NetConfList, error) {
28+
func CNIConfigForVPCAttachment(vpc galacticv1alpha.VPC, vpcAttachment galacticv1alpha.VPCAttachment, mtu int) (NetConfList, error) {
2929
terminations := make([]cni.Termination, 0, 10)
3030
addresses := make([]cni.Address, 0, 10)
3131
routes := make([]cni.Route, 0, 10)
@@ -85,7 +85,7 @@ func CNIConfigForVPCAttachment(vpc galacticv1alpha.VPC, vpcAttachment galacticv1
8585
Type: "galactic",
8686
VPC: vpcIdentifierBase62,
8787
VPCAttachment: vpcAttachmentIdentifierBase62,
88-
MTU: 1300,
88+
MTU: mtu,
8989
Terminations: terminations,
9090
IPAM: cni.IPAM{
9191
Type: "static",

internal/cniconfig/cniconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestCNIConfigForVPCAttachment(t *testing.T) {
2121
Type: "galactic",
2222
VPC: "1hVwxnaA7",
2323
VPCAttachment: "h31",
24-
MTU: 1300,
24+
MTU: 1372,
2525
Terminations: []cni.Termination{
2626
{Network: "10.1.1.0/24"},
2727
{Network: "2001:10:1:1::/64"},
@@ -90,7 +90,7 @@ func TestCNIConfigForVPCAttachment(t *testing.T) {
9090
Identifier: "ffff",
9191
},
9292
}
93-
actual, err := cniconfig.CNIConfigForVPCAttachment(vpc, vpcAttachment)
93+
actual, err := cniconfig.CNIConfigForVPCAttachment(vpc, vpcAttachment, 1372)
9494
if err != nil {
9595
t.Errorf("CNIConfigForVPCAttachment error: %+v", err)
9696
}

internal/controller/vpcattachment_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type VPCAttachmentReconciler struct {
2828
client.Client
2929
Scheme *runtime.Scheme
3030
Identifier *identifier.Identifier
31+
MTU int
3132
}
3233

3334
// +kubebuilder:rbac:groups=galactic.datumapis.com,resources=vpcattachments,verbs=get;list;watch;create;update;patch;delete
@@ -82,7 +83,7 @@ func (r *VPCAttachmentReconciler) Reconcile(ctx context.Context, req ctrl.Reques
8283
},
8384
}
8485
_, err := controllerutil.CreateOrUpdate(ctx, r.Client, nad, func() error {
85-
cniPluginConfig, err := cniconfig.CNIConfigForVPCAttachment(vpc, vpcAttachment)
86+
cniPluginConfig, err := cniconfig.CNIConfigForVPCAttachment(vpc, vpcAttachment, r.MTU)
8687
if err != nil {
8788
return err
8889
}

test/e2e/e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ var _ = Describe("Manager", Ordered, func() {
429429
"CNI config should have cniVersion 0.4.0")
430430
g.Expect(output).To(ContainSubstring(`"type":"galactic"`),
431431
"CNI config should use the galactic plugin")
432-
g.Expect(output).To(ContainSubstring(`"mtu":1300`),
433-
"CNI config should set MTU to 1300")
432+
g.Expect(output).To(ContainSubstring(`"mtu":1372`),
433+
"CNI config should set MTU to 1372")
434434
g.Expect(output).To(ContainSubstring(`"type":"static"`),
435435
"CNI config IPAM should be static")
436436

0 commit comments

Comments
 (0)