@@ -25,17 +25,13 @@ import (
25
25
"sigs.k8s.io/cluster-api-provider-openstack/pkg/record"
26
26
)
27
27
28
- // export constants for use in loadbalancer-package
29
- const (
30
- SecGroupPrefix string = "k8s"
31
- NeutronLbaasSuffix string = "lbaas"
32
- )
33
-
34
28
const (
29
+ secGroupPrefix string = "k8s"
35
30
controlPlaneSuffix string = "controlplane"
36
31
workerSuffix string = "worker"
37
32
bastionSuffix string = "bastion"
38
33
remoteGroupIDSelf string = "self"
34
+ neutronLbaasSuffix string = "lbaas"
39
35
)
40
36
41
37
var defaultRules = []infrav1.SecurityGroupRule {
@@ -67,21 +63,21 @@ func (s *Service) ReconcileSecurityGroups(clusterName string, openStackCluster *
67
63
return nil
68
64
}
69
65
70
- secControlPlaneGroupName := fmt .Sprintf ("%s-cluster-%s-secgroup-%s" , SecGroupPrefix , clusterName , controlPlaneSuffix )
71
- secWorkerGroupName := fmt .Sprintf ("%s-cluster-%s-secgroup-%s" , SecGroupPrefix , clusterName , workerSuffix )
66
+ secControlPlaneGroupName := fmt .Sprintf ("%s-cluster-%s-secgroup-%s" , secGroupPrefix , clusterName , controlPlaneSuffix )
67
+ secWorkerGroupName := fmt .Sprintf ("%s-cluster-%s-secgroup-%s" , secGroupPrefix , clusterName , workerSuffix )
72
68
secGroupNames := map [string ]string {
73
69
controlPlaneSuffix : secControlPlaneGroupName ,
74
70
workerSuffix : secWorkerGroupName ,
75
71
}
76
72
77
73
if openStackCluster .Spec .Bastion != nil && openStackCluster .Spec .Bastion .Enabled {
78
- secBastionGroupName := fmt .Sprintf ("%s-cluster-%s-secgroup-%s" , SecGroupPrefix , clusterName , bastionSuffix )
74
+ secBastionGroupName := fmt .Sprintf ("%s-cluster-%s-secgroup-%s" , secGroupPrefix , clusterName , bastionSuffix )
79
75
secGroupNames [bastionSuffix ] = secBastionGroupName
80
76
}
81
77
82
78
if openStackCluster .Spec .ManagedAPIServerLoadBalancer && ! openStackCluster .Spec .UseOctavia {
83
- secLbaasGroupName := fmt .Sprintf ("%s-cluster-%s-secgroup-%s" , SecGroupPrefix , clusterName , NeutronLbaasSuffix )
84
- secGroupNames [NeutronLbaasSuffix ] = secLbaasGroupName
79
+ secLbaasGroupName := fmt .Sprintf ("%s-cluster-%s-secgroup-%s" , secGroupPrefix , clusterName , neutronLbaasSuffix )
80
+ secGroupNames [neutronLbaasSuffix ] = secLbaasGroupName
85
81
}
86
82
87
83
//create security groups first, because desired rules use group ids.
@@ -370,8 +366,8 @@ func (s *Service) generateDesiredSecGroups(secGroupNames map[string]string, open
370
366
)
371
367
}
372
368
}
373
- desiredSecGroups [NeutronLbaasSuffix ] = infrav1.SecurityGroup {
374
- Name : secGroupNames [NeutronLbaasSuffix ],
369
+ desiredSecGroups [neutronLbaasSuffix ] = infrav1.SecurityGroup {
370
+ Name : secGroupNames [neutronLbaasSuffix ],
375
371
Rules : neutronLbaasRules ,
376
372
}
377
373
}
@@ -579,3 +575,8 @@ func convertOSSecGroupRuleToConfigSecGroupRule(osSecGroupRule rules.SecGroupRule
579
575
RemoteIPPrefix : osSecGroupRule .RemoteIPPrefix ,
580
576
}
581
577
}
578
+
579
+ // GetNeutronLBaasSecGroupName export NeutronLBaasSecGroupName
580
+ func GetNeutronLBaasSecGroupName (clusterName string ) string {
581
+ return fmt .Sprintf ("%s-cluster-%s-secgroup-%s" , secGroupPrefix , clusterName , neutronLbaasSuffix )
582
+ }
0 commit comments