Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EKS: disable bastion sg when bastion is disabled #3028

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const (

var (
eksSecurityGroupRoles = []infrav1.SecurityGroupRole{
infrav1.SecurityGroupBastion,
infrav1.SecurityGroupEKSNodeAdditional,
}
)
Expand Down Expand Up @@ -203,6 +202,10 @@ func (r *AWSManagedControlPlaneReconciler) reconcileNormal(ctx context.Context,
return ctrl.Result{}, err
}

if awsManagedControlPlane.Spec.Bastion.Enabled {
eksSecurityGroupRoles = append(eksSecurityGroupRoles, infrav1.SecurityGroupBastion)
}

ec2Service := ec2.NewService(managedScope)
networkSvc := network.NewService(managedScope)
ekssvc := eks.NewService(managedScope)
Expand Down
17 changes: 12 additions & 5 deletions pkg/cloud/services/securitygroup/securitygroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ func (s *Service) getSecurityGroupIngressRules(role infrav1.SecurityGroupRole) (
}, nil
case infrav1.SecurityGroupControlPlane:
rules := infrav1.IngressRules{
s.defaultSSHIngressRule(s.scope.SecurityGroups()[infrav1.SecurityGroupBastion].ID),
{
Description: "Kubernetes API",
Protocol: infrav1.SecurityGroupProtocolTCP,
Expand All @@ -510,11 +509,13 @@ func (s *Service) getSecurityGroupIngressRules(role infrav1.SecurityGroupRole) (
SourceSecurityGroupIDs: []string{s.scope.SecurityGroups()[infrav1.SecurityGroupControlPlane].ID},
},
}
if s.scope.Bastion().Enabled {
rules = append(rules, s.defaultSSHIngressRule(s.scope.SecurityGroups()[infrav1.SecurityGroupBastion].ID))
}
return append(cniRules, rules...), nil

case infrav1.SecurityGroupNode:
rules := infrav1.IngressRules{
s.defaultSSHIngressRule(s.scope.SecurityGroups()[infrav1.SecurityGroupBastion].ID),
{
Description: "Node Port Services",
Protocol: infrav1.SecurityGroupProtocolTCP,
Expand All @@ -534,11 +535,17 @@ func (s *Service) getSecurityGroupIngressRules(role infrav1.SecurityGroupRole) (
},
},
}
if s.scope.Bastion().Enabled {
rules = append(rules, s.defaultSSHIngressRule(s.scope.SecurityGroups()[infrav1.SecurityGroupBastion].ID))
}
return append(cniRules, rules...), nil
case infrav1.SecurityGroupEKSNodeAdditional:
return infrav1.IngressRules{
s.defaultSSHIngressRule(s.scope.SecurityGroups()[infrav1.SecurityGroupBastion].ID),
}, nil
if s.scope.Bastion().Enabled {
return infrav1.IngressRules{
s.defaultSSHIngressRule(s.scope.SecurityGroups()[infrav1.SecurityGroupBastion].ID),
}, nil
}
return infrav1.IngressRules{}, nil
case infrav1.SecurityGroupAPIServerLB:
return infrav1.IngressRules{
{
Expand Down