@@ -30,6 +30,28 @@ var _ ctrlconversion.Convertible = &OpenStackCluster{}
30
30
31
31
const trueString = "true"
32
32
33
+ // legacyCalicoSecurityGroupRules are the legacy security group rules for calico
34
+ // that need to be applied to the control plane and worker security groups when
35
+ // managed security groups are enabled and upgrading from v1alpha7 to v1alpha8.
36
+ var legacyCalicoSecurityGroupRules = []infrav1.SecurityGroupRuleSpec {
37
+ {
38
+ Description : "BGP (calico)" ,
39
+ Direction : "ingress" ,
40
+ EtherType : "IPv4" ,
41
+ PortRangeMin : 179 ,
42
+ PortRangeMax : 179 ,
43
+ Protocol : "tcp" ,
44
+ RemoteManagedGroups : []infrav1.ManagedSecurityGroupName {"controlplane" , "worker" },
45
+ },
46
+ {
47
+ Description : "IP-in-IP (calico)" ,
48
+ Direction : "ingress" ,
49
+ EtherType : "IPv4" ,
50
+ Protocol : "4" ,
51
+ RemoteManagedGroups : []infrav1.ManagedSecurityGroupName {"controlplane" , "worker" },
52
+ },
53
+ }
54
+
33
55
func (r * OpenStackCluster ) ConvertTo (dstRaw ctrlconversion.Hub ) error {
34
56
dst := dstRaw .(* infrav1.OpenStackCluster )
35
57
@@ -196,6 +218,10 @@ func Convert_v1alpha8_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(in *
196
218
out .ExternalNetworkID = in .ExternalNetwork .ID
197
219
}
198
220
221
+ if in .ManagedSecurityGroups .Enabled {
222
+ out .ManagedSecurityGroups = true
223
+ }
224
+
199
225
return nil
200
226
}
201
227
@@ -211,6 +237,13 @@ func Convert_v1alpha5_OpenStackClusterSpec_To_v1alpha8_OpenStackClusterSpec(in *
211
237
}
212
238
}
213
239
240
+ if in .ManagedSecurityGroups {
241
+ out .ManagedSecurityGroups = infrav1.SecurityGroupsSpec {
242
+ Enabled : true ,
243
+ AllNodesSecurityGroupRules : legacyCalicoSecurityGroupRules ,
244
+ }
245
+ }
246
+
214
247
return nil
215
248
}
216
249
@@ -523,6 +556,43 @@ func Convert_v1alpha5_Bastion_To_v1alpha8_Bastion(in *Bastion, out *infrav1.Bast
523
556
return nil
524
557
}
525
558
526
- func Convert_v1alpha8_SecurityGroupRule_To_v1alpha5_SecurityGroupRule (in * infrav1.SecurityGroupRule , out * SecurityGroupRule , s conversion.Scope ) error {
527
- return autoConvert_v1alpha8_SecurityGroupRule_To_v1alpha5_SecurityGroupRule (in , out , s )
559
+ func Convert_v1alpha8_SecurityGroupStatus_To_v1alpha5_SecurityGroup (in * infrav1.SecurityGroupStatus , out * SecurityGroup , s conversion.Scope ) error { //nolint:revive
560
+ out .ID = in .ID
561
+ out .Name = in .Name
562
+ out .Rules = make ([]SecurityGroupRule , len (in .Rules ))
563
+ for i , rule := range in .Rules {
564
+ out .Rules [i ] = SecurityGroupRule {
565
+ ID : rule .ID ,
566
+ Description : rule .Description ,
567
+ Direction : rule .Direction ,
568
+ EtherType : rule .EtherType ,
569
+ PortRangeMin : rule .PortRangeMin ,
570
+ PortRangeMax : rule .PortRangeMax ,
571
+ Protocol : rule .Protocol ,
572
+ RemoteGroupID : rule .RemoteGroupID ,
573
+ RemoteIPPrefix : rule .RemoteIPPrefix ,
574
+ }
575
+ }
576
+ return nil
577
+ }
578
+
579
+ func Convert_v1alpha5_SecurityGroup_To_v1alpha8_SecurityGroupStatus (in * SecurityGroup , out * infrav1.SecurityGroupStatus , s conversion.Scope ) error { //nolint:revive
580
+ out .ID = in .ID
581
+ out .Name = in .Name
582
+ out .Rules = make ([]infrav1.SecurityGroupRuleStatus , len (in .Rules ))
583
+ for i , rule := range in .Rules {
584
+ out .Rules [i ] = infrav1.SecurityGroupRuleStatus {
585
+ ID : rule .ID ,
586
+ Description : rule .Description ,
587
+ Direction : rule .Direction ,
588
+ EtherType : rule .EtherType ,
589
+ PortRangeMin : rule .PortRangeMin ,
590
+ PortRangeMax : rule .PortRangeMax ,
591
+ Protocol : rule .Protocol ,
592
+ RemoteGroupID : rule .RemoteGroupID ,
593
+ RemoteIPPrefix : rule .RemoteIPPrefix ,
594
+ }
595
+ }
596
+
597
+ return nil
528
598
}
0 commit comments