-
Notifications
You must be signed in to change notification settings - Fork 581
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
Add externally managed predicate #2383
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ import ( | |
"sigs.k8s.io/cluster-api/controllers/noderefutil" | ||
capierrors "sigs.k8s.io/cluster-api/errors" | ||
"sigs.k8s.io/cluster-api/util" | ||
"sigs.k8s.io/cluster-api/util/annotations" | ||
"sigs.k8s.io/cluster-api/util/conditions" | ||
"sigs.k8s.io/cluster-api/util/patch" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
@@ -343,6 +344,10 @@ func (m *MachineScope) IsEKSManaged() bool { | |
return m.InfraCluster.InfraCluster().GetObjectKind().GroupVersionKind().Kind == "AWSManagedControlPlane" | ||
} | ||
|
||
func (m *MachineScope) IsExternallyManaged() bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return annotations.IsExternallyManaged(m.InfraCluster.InfraCluster()) | ||
} | ||
|
||
// SetInterruptible sets the AWSMachine status Interruptible | ||
func (m *MachineScope) SetInterruptible() { | ||
if m.AWSMachine.Spec.SpotMarketOptions != nil { | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -173,7 +173,7 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte) (*i | |||
} | ||||
input.SubnetID = subnetID | ||||
|
||||
if !scope.IsEKSManaged() && s.scope.Network().APIServerELB.DNSName == "" { | ||||
if !scope.IsExternallyManaged() && !scope.IsEKSManaged() && s.scope.Network().APIServerELB.DNSName == "" { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was under the impression that it being externally managed means there should be no reconciliation at all? So do we not need something like
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is related to instance creation, we are skipping logic that is relying on infrastructure created by the managed cluster. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that if we are using external but still provide the APIServer DNSName then we still work as expected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this logic is only used to check that a load balancer was created. |
||||
record.Eventf(s.scope.InfraCluster(), "FailedCreateInstance", "Failed to run controlplane, APIServer ELB not available") | ||||
|
||||
return nil, awserrors.NewFailedDependency("failed to run controlplane, APIServer ELB not available") | ||||
|
@@ -210,7 +210,9 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte) (*i | |||
// fallback to AWSCluster.Spec.SSHKeyName if it is defined | ||||
prioritizedSSHKeyName = *scope.InfraCluster.SSHKeyName() | ||||
default: | ||||
prioritizedSSHKeyName = defaultSSHKeyName | ||||
if !scope.IsExternallyManaged() { | ||||
prioritizedSSHKeyName = defaultSSHKeyName | ||||
} | ||||
} | ||||
|
||||
// Only set input.SSHKeyName if the user did not explicitly request no ssh key be set (explicitly setting "" on either the Machine or related Cluster) | ||||
|
@@ -291,7 +293,9 @@ func (s *Service) findSubnet(scope *scope.MachineScope) (string, error) { | |||
case scope.AWSMachine.Spec.Subnet != nil && scope.AWSMachine.Spec.Subnet.Filters != nil: | ||||
criteria := []*ec2.Filter{ | ||||
filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), | ||||
filter.EC2.VPC(s.scope.VPC().ID), | ||||
} | ||||
if !scope.IsExternallyManaged() { | ||||
criteria = append(criteria, filter.EC2.VPC(s.scope.VPC().ID)) | ||||
} | ||||
if failureDomain != nil { | ||||
criteria = append(criteria, filter.EC2.AvailabilityZone(*failureDomain)) | ||||
|
@@ -355,6 +359,10 @@ func (s *Service) getFilteredSubnets(criteria ...*ec2.Filter) ([]*ec2.Subnet, er | |||
// GetCoreSecurityGroups looks up the security group IDs managed by this actuator | ||||
// They are considered "core" to its proper functioning | ||||
func (s *Service) GetCoreSecurityGroups(scope *scope.MachineScope) ([]string, error) { | ||||
if scope.IsExternallyManaged() { | ||||
return nil, nil | ||||
} | ||||
Comment on lines
+362
to
+364
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to have the same effect as the changes on lines 191 right? Also, do we not still need security groups? Or are they just fetched explicitly from the AWSCluster in this case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think this is called in more places, so we possibly want to drop the other one and keep this logic here within the func.
I expect machines with externallyManaged infra to set their desired security groups explicitly through the API contract /~https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/main/api/v1alpha4/awsmachine_types.go#L100
|
||||
|
||||
// These are common across both controlplane and node machines | ||||
sgRoles := []infrav1.SecurityGroupRole{ | ||||
infrav1.SecurityGroupNode, | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to check the other way around as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that the user can add this annotation and disable infrastructure management, am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going from managed to externally managed should be allowed. The other way around is not allowed.