-
Notifications
You must be signed in to change notification settings - Fork 472
Add support for joining clusters to AKS Fleet #4316
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
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 |
|---|---|---|
|
|
@@ -83,6 +83,7 @@ func (mw *azureManagedControlPlaneWebhook) Default(ctx context.Context, obj runt | |
| m.Spec.Version = setDefaultVersion(m.Spec.Version) | ||
| m.Spec.SKU = setDefaultSku(m.Spec.SKU) | ||
| m.Spec.AutoScalerProfile = setDefaultAutoScalerProfile(m.Spec.AutoScalerProfile) | ||
| m.Spec.FleetsMember = setDefaultFleetsMember(m.Spec.FleetsMember, m.Labels) | ||
|
|
||
| if err := m.setDefaultSSHPublicKey(); err != nil { | ||
| ctrl.Log.WithName("AzureManagedControlPlaneWebHookLogger").Error(err, "setDefaultSSHPublicKey failed") | ||
|
|
@@ -260,6 +261,10 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o | |
| allErrs = append(allErrs, errs...) | ||
| } | ||
|
|
||
| if errs := m.validateFleetsMember(old); len(errs) > 0 { | ||
|
Contributor
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. Do we need to do any validation for AzureManagedControlPlaneTemplate?
Contributor
Author
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. 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. |
||
| allErrs = append(allErrs, errs...) | ||
| } | ||
|
|
||
| if len(allErrs) == 0 { | ||
| return nil, m.Validate(mw.Client) | ||
| } | ||
|
|
@@ -687,6 +692,25 @@ func (m *AzureManagedControlPlane) validateOIDCIssuerProfileUpdate(old *AzureMan | |
| return allErrs | ||
| } | ||
|
|
||
| // validateFleetsMember validates a FleetsMember. | ||
| func (m *AzureManagedControlPlane) validateFleetsMember(old *AzureManagedControlPlane) field.ErrorList { | ||
| var allErrs field.ErrorList | ||
|
|
||
| if old.Spec.FleetsMember == nil || m.Spec.FleetsMember == nil { | ||
| return allErrs | ||
| } | ||
|
Comment on lines
+699
to
+701
Member
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 statement seems to allow addition of FleetMember to the spec or deletion of FleetMember from the spec since
Contributor
Author
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. Yes we're allowed to join an existing cluster to a Fleet, or detach it from the Fleet by removing the FleetsMember spec. |
||
| if old.Spec.FleetsMember.Name != "" && old.Spec.FleetsMember.Name != m.Spec.FleetsMember.Name { | ||
| allErrs = append(allErrs, | ||
| field.Forbidden( | ||
| field.NewPath("Spec", "FleetsMember", "Name"), | ||
| "Name is immutable", | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| return allErrs | ||
| } | ||
|
|
||
| func validateName(name string, fldPath *field.Path) field.ErrorList { | ||
| var allErrs field.ErrorList | ||
| if lName := strings.ToLower(name); strings.Contains(lName, "microsoft") || | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1000,6 +1000,18 @@ type AzureBastion struct { | |||||||||
| EnableTunneling bool `json:"enableTunneling,omitempty"` | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // FleetsMember defines the fleets member configuration. | ||||||||||
| // See also [AKS doc]. | ||||||||||
| // | ||||||||||
| // [AKS doc]: https://learn.microsoft.com/en-us/azure/templates/microsoft.containerservice/2023-03-15-preview/fleets/members | ||||||||||
|
Contributor
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
Suggested change
|
||||||||||
| type FleetsMember struct { | ||||||||||
| // Name is the name of the member. | ||||||||||
| // +optional | ||||||||||
| Name string `json:"name,omitempty"` | ||||||||||
|
|
||||||||||
| FleetsMemberClassSpec `json:",inline"` | ||||||||||
|
Contributor
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. Q: is this a shared spec for cluster class?
Contributor
Author
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. Yes the only field that isn't shared is the name of the fleets member. |
||||||||||
| } | ||||||||||
|
|
||||||||||
| // BackendPool describes the backend pool of the load balancer. | ||||||||||
| type BackendPool struct { | ||||||||||
| // Name specifies the name of backend pool for the load balancer. If not specified, the default name will | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -211,6 +211,13 @@ 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. | ||
|
Contributor
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. Same here re: AKS doc link |
||
| // See also [AKS doc]. | ||
| // | ||
| // [AKS doc]: https://learn.microsoft.com/en-us/azure/templates/microsoft.containerservice/2023-03-15-preview/fleets/members | ||
| // +optional | ||
| FleetsMember *FleetsMemberClassSpec `json:"fleetsMember,omitempty"` | ||
| } | ||
|
|
||
| // AzureManagedMachinePoolClassSpec defines the AzureManagedMachinePool properties that may be shared across several Azure managed machinepools. | ||
|
|
@@ -448,6 +455,19 @@ type LoadBalancerClassSpec struct { | |
| IdleTimeoutInMinutes *int32 `json:"idleTimeoutInMinutes,omitempty"` | ||
| } | ||
|
|
||
| // FleetsMemberClassSpec defines the FleetsMemberSpec properties that may be shared across several Azure clusters. | ||
| type FleetsMemberClassSpec struct { | ||
| // Group is the group this member belongs to for multi-cluster update management. | ||
| // +optional | ||
| Group string `json:"group,omitempty"` | ||
|
|
||
| // ManagerName is the name of the fleet manager. | ||
| ManagerName string `json:"managerName"` | ||
|
|
||
| // ManagerResourceGroup is the resource group of the fleet manager. | ||
| ManagerResourceGroup string `json:"managerResourceGroup"` | ||
| } | ||
|
|
||
| // SecurityGroupClass defines the SecurityGroup properties that may be shared across several Azure clusters. | ||
| type SecurityGroupClass struct { | ||
| // +optional | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| Copyright 2023 The Kubernetes Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package fleetsmembers | ||
|
|
||
| import ( | ||
| asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20230315preview" | ||
| infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" | ||
| "sigs.k8s.io/cluster-api-provider-azure/azure" | ||
| "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" | ||
| ) | ||
|
|
||
| const serviceName = "fleetsmember" | ||
|
|
||
| // FleetsMemberScope defines the scope interface for a Fleet host service. | ||
| type FleetsMemberScope interface { | ||
| aso.Scope | ||
| AzureFleetsMemberSpec() []azure.ASOResourceSpecGetter[*asocontainerservicev1.FleetsMember] | ||
| } | ||
|
|
||
| // New creates a new service. | ||
| func New(scope FleetsMemberScope) *aso.Service[*asocontainerservicev1.FleetsMember, FleetsMemberScope] { | ||
| svc := aso.NewService[*asocontainerservicev1.FleetsMember, FleetsMemberScope](serviceName, scope) | ||
| svc.Specs = scope.AzureFleetsMemberSpec() | ||
| svc.ConditionType = infrav1.FleetReadyCondition | ||
| return svc | ||
| } |
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?