@@ -229,9 +229,21 @@ func (s *Service) generateDesiredSecGroups(openStackCluster *infrav1.OpenStackCl
229
229
workerRules = append (workerRules , getSGWorkerGeneral (remoteGroupIDSelf , secControlPlaneGroupID )... )
230
230
}
231
231
232
+ // Append any additional rules for control plane and worker nodes
233
+ controlPlaneExtraRules , err := getRulesFromSpecs (remoteManagedGroups , openStackCluster .Spec .ManagedSecurityGroups .ControlPlaneNodesSecurityGroupRules )
234
+ if err != nil {
235
+ return nil , err
236
+ }
237
+ controlPlaneRules = append (controlPlaneRules , controlPlaneExtraRules ... )
238
+ workersExtraRules , err := getRulesFromSpecs (remoteManagedGroups , openStackCluster .Spec .ManagedSecurityGroups .WorkerNodesSecurityGroupRules )
239
+ if err != nil {
240
+ return nil , err
241
+ }
242
+ workerRules = append (workerRules , workersExtraRules ... )
243
+
232
244
// For now, we do not create a separate security group for allNodes.
233
245
// Instead, we append the rules for allNodes to the control plane and worker security groups.
234
- allNodesRules , err := getAllNodesRules (remoteManagedGroups , openStackCluster .Spec .ManagedSecurityGroups .AllNodesSecurityGroupRules )
246
+ allNodesRules , err := getRulesFromSpecs (remoteManagedGroups , openStackCluster .Spec .ManagedSecurityGroups .AllNodesSecurityGroupRules )
235
247
if err != nil {
236
248
return nil , err
237
249
}
@@ -275,9 +287,9 @@ func (s *Service) generateDesiredSecGroups(openStackCluster *infrav1.OpenStackCl
275
287
}
276
288
277
289
// getAllNodesRules returns the rules for the allNodes security group that should be created.
278
- func getAllNodesRules (remoteManagedGroups map [string ]string , allNodesSecurityGroupRules []infrav1.SecurityGroupRuleSpec ) ([]resolvedSecurityGroupRuleSpec , error ) {
279
- rules := make ([]resolvedSecurityGroupRuleSpec , 0 , len (allNodesSecurityGroupRules ))
280
- for _ , rule := range allNodesSecurityGroupRules {
290
+ func getRulesFromSpecs (remoteManagedGroups map [string ]string , securityGroupRules []infrav1.SecurityGroupRuleSpec ) ([]resolvedSecurityGroupRuleSpec , error ) {
291
+ rules := make ([]resolvedSecurityGroupRuleSpec , 0 , len (securityGroupRules ))
292
+ for _ , rule := range securityGroupRules {
281
293
if err := validateRemoteManagedGroups (remoteManagedGroups , rule .RemoteManagedGroups ); err != nil {
282
294
return nil , err
283
295
}
0 commit comments