-
Notifications
You must be signed in to change notification settings - Fork 431
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 support for joining clusters to AKS Fleet #4316
Add support for joining clusters to AKS Fleet #4316
Conversation
0cdf4e1
to
5d61e6f
Compare
azure/services/fleetsmember/spec.go
Outdated
import ( | ||
"context" | ||
|
||
asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20230315preview" |
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.
Why is fleetmember in the same namespace as AKS in ASO? that seems wrong? We release with a different SDK, different API version, etc...
our latest API version is 0815preview.
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.
Hmm I'm not sure. ASO includes both under asocontainerservicev1 here: https://azure.github.io/azure-service-operator/reference/containerservice/
azure/services/fleetsmember/spec.go
Outdated
|
||
fleetsMember := &asocontainerservicev1.FleetsMember{} | ||
fleetsMember.Spec = asocontainerservicev1.Fleets_Member_Spec{} | ||
fleetsMember.Spec.AzureName = s.ManagerName |
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.
why AzureName = ManagerName?
member.Name is the name of the member.
it shouldn't be the same as the fleet.
and same comment as further up on naming consistency. is the Azure prefix needed?
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.
The AzureName
is defined as a part of an ASO spec type, so I can't change that
azure/services/fleetsmember/spec.go
Outdated
} | ||
fleetsMember.Spec.Group = ptr.To(s.Group) | ||
fleetsMember.Spec.ClusterResourceReference = &genruntime.ResourceReference{ | ||
ARMID: azure.ManagedClusterID(s.SubscriptionID, s.ResourceGroup, s.Name), |
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.
is s.ResourceGroup the resourceGroup of the target AKS cluster? or the resource group of the member resource?
I assume that memberSpec.ResourceGroup is the RG of the member?
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.
It is the resource group of both the target AKS cluster and the member resource. The member resource is then attached the owning fleet manager. I may be misunderstanding how member resources work though. Are they supposed to be in a different resource group?
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.
the member resource is a child resource of the fleet manager, just like an agentpool is a child resource of an aks cluster.
the member cannot be in a different RG than the fleet manager.
the aks cluster that the member resource targets, can be anywhere.
it is the resource group of both the target AKS cluster and the member resource.
This would imply that all AKS clusters that join a fleet must be in the same resource group as the fleet manager, which means they would all have to be in the same subscription as well.
-
subscription-1
- MyFleet-RG
- Fleet
- Member A -> aks-a cluster (located anywhere)
- Member B -> aks-b cluster (located anywhere)
- Fleet
- MyFleet-RG
-
subscription-2
- Cluster-A-RG
- aks-a cluster
- Cluster-A-RG
-
subscription-3
- Cluster-B-RG
- aks-b cluster
- Cluster-B-RG
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.
the member cannot be in a different RG than the fleet manager.
Is the spec.Group
field the resource group of the fleet member then? I don't see any other place where I specified the resource group for the member. If so, I can set Group to s.ManagerResourceGroup
. For the ClusterResourceReference
, I think the current logic makes sense as the cluster resource group is separate from the manager/member resource group.
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.
member.Group
is an "UpdateGroup" that the user can provide to group members within a fleet.
"test", "staging", "prod-early", "prod" for example.
like a static annotation on the member if you will. not a resourcegroup.
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.
a member of. | ||
properties: | ||
group: | ||
description: Group is the group this member belongs to for multi-cluster |
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.
is that correct? why is the group under the fleetsManager?
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.
This is defined in ASO's fleetsManager spec, so I'm not entirely sure: https://azure.github.io/azure-service-operator/reference/containerservice/v1api20230315preview/#containerservice.azure.com/v1api20230315preview.Fleets_Member_Spec
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #4316 +/- ##
==========================================
- Coverage 62.20% 62.11% -0.10%
==========================================
Files 187 189 +2
Lines 18568 18642 +74
==========================================
+ Hits 11551 11580 +29
- Misses 6381 6425 +44
- Partials 636 637 +1 ☔ View full report in Codecov by Sentry. |
5283947
to
96fe895
Compare
/retest |
@serbrech I have addressed all comments and also made a few improvements to the implementation. Let me know what you think! |
4e81e22
to
d688d75
Compare
888e648
to
3736469
Compare
/retest |
4d887bb
to
e1fab08
Compare
2382d4a
to
f34f81c
Compare
93b25d0
to
434d82b
Compare
/lgtm |
LGTM label has been added. Git tree hash: 6ba3ca6e1cc7a596ccd48ae841e90d759a860158
|
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jackfrancis The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold I have some comments queued up |
@@ -260,6 +261,10 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o | |||
allErrs = append(allErrs, errs...) | |||
} | |||
|
|||
if errs := m.validateFleetsMember(old); len(errs) > 0 { |
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 need to do any validation for AzureManagedControlPlaneTemplate?
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.
We don't need validation for the template since the name is the only thing we need to validate, and we don't specify the name in the template.
@@ -110,6 +110,10 @@ type AzureManagedControlPlaneSpec struct { | |||
// Immutable. | |||
// +optional | |||
DNSPrefix *string `json:"dnsPrefix,omitempty"` | |||
|
|||
// FleetsMember is the spec for the fleet this cluster is a member of. |
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.
Is there a link to AKS docs we could include here?
@@ -211,6 +211,10 @@ type AzureManagedControlPlaneClassSpec struct { | |||
// DisableLocalAccounts disables getting static credentials for this cluster when set. Expected to only be used for AAD clusters. | |||
// +optional | |||
DisableLocalAccounts *bool `json:"disableLocalAccounts,omitempty"` | |||
|
|||
// FleetsMember is the spec for the fleet this cluster is a member of. |
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.
Same here re: AKS doc link
spec := scope.AzureFleetsMemberSpec() | ||
if spec != nil { | ||
svc.Specs = []azure.ASOResourceSpecGetter[*asocontainerservicev1.FleetsMember]{spec} | ||
} |
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.
One way I can think of to get rid of this little dance is for AzureFleetsMemberSpec
to return a slice of 0 or 1 elements instead of a possibly-nil pointer to one. Then this could just be:
spec := scope.AzureFleetsMemberSpec() | |
if spec != nil { | |
svc.Specs = []azure.ASOResourceSpecGetter[*asocontainerservicev1.FleetsMember]{spec} | |
} | |
svc.Specs = scope.AzureFleetsMemberSpecs() |
} | ||
|
||
// Service provides operations on Azure resources. | ||
type Service struct { |
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 need this struct definition or can we refactor this like #4224?
g.Expect(mgmtClient.Update(ctx, infraControlPlane)).To(Succeed()) | ||
}, input.WaitIntervals...).Should(Succeed()) | ||
|
||
By("Waiting for the managed cluster to finish updating") |
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.
Not blocking this PR, but I'm still curious as to exactly what's being updated here if removing the fleets member field doesn't actually delete the ASO resource.
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.
I think that there was an issue with the controller trying to reconcile the fleets member as we're trying to delete it, and it may have been causing some problems. I'll try testing it again without this step and maybe those problems were due to a different issue.
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.
Found the error. It happens when I try to delete the fleets member:
this operation depends on is not in an expected state. Expected: ProvisioningState in (Succeeded, Canceled, Failed, Deleting, Upgrading). Actual: ProvisioningState is Updating. Change the resource to expected state and try again.
434d82b
to
3f7ad96
Compare
@@ -1000,6 +1000,16 @@ type AzureBastion struct { | |||
EnableTunneling bool `json:"enableTunneling,omitempty"` | |||
} | |||
|
|||
// FleetsMember defines the fleets member configuration. | |||
// [AKS doc]: https://learn.microsoft.com/en-us/azure/templates/microsoft.containerservice/2023-03-15-preview/fleets/members |
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.
This [AKS doc]: ...
syntax basically only defines a variable that you need to reference for it to actually render in the generated docs:
// [AKS doc]: https://learn.microsoft.com/en-us/azure/templates/microsoft.containerservice/2023-03-15-preview/fleets/members | |
// See also [AKS doc]. | |
// | |
// [AKS doc]: https://learn.microsoft.com/en-us/azure/templates/microsoft.containerservice/2023-03-15-preview/fleets/members |
3f7ad96
to
ad60a09
Compare
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.
/lgtm
/hold cancel
LGTM label has been added. Git tree hash: 1bf6b4cf8533455daae165b411807cbe6661db79
|
@willie-yao: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/retest |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR adds support for joining managed clusters to AKS Fleet via the field
fleetManager
in theAzureManagedControlPlane
.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Steps to test:
AzureManagedControlPlane
specTODOs:
Release note: