Skip to content

Commit 78a8390

Browse files
feat: Allow Setting the desired GCPCluster.Spec.Network.Mtu passed when created a network
1 parent 857b045 commit 78a8390

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cloud/scope/cluster.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ func (s *ClusterScope) NetworkName() string {
131131
return ptr.Deref(s.GCPCluster.Spec.Network.Name, "default")
132132
}
133133

134+
// NetworkMtu returns the Network MTU of 1440 which is the default, otherwise returns back what is being set.
135+
// https://cloud.google.com/vpc/docs/mtu
136+
func (s *ClusterScope) NetworkMtu() int64 {
137+
if s.GCPCluster.Spec.Network.Mtu == 0 {
138+
return int64(1440)
139+
}
140+
return s.GCPCluster.Spec.Network.Mtu
141+
}
142+
134143
// NetworkLink returns the partial URL for the network.
135144
func (s *ClusterScope) NetworkLink() string {
136145
return fmt.Sprintf("projects/%s/global/networks/%s", s.NetworkProject(), s.NetworkName())
@@ -206,6 +215,7 @@ func (s *ClusterScope) NetworkSpec() *compute.Network {
206215
Description: infrav1.ClusterTagKey(s.Name()),
207216
AutoCreateSubnetworks: createSubnet,
208217
ForceSendFields: []string{"AutoCreateSubnetworks"},
218+
Mtu: s.NetworkMtu(),
209219
}
210220

211221
return network

0 commit comments

Comments
 (0)