-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for joining cluster to AKS Fleet
- Loading branch information
1 parent
7996082
commit 0cdf4e1
Showing
18 changed files
with
1,011 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
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 fleetsmember | ||
|
||
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 { | ||
azure.ClusterScoper | ||
aso.Scope | ||
AzureFleetsMemberSpec() azure.ASOResourceSpecGetter[*asocontainerservicev1.FleetsMember] | ||
} | ||
|
||
// Service provides operations on Azure resources. | ||
type Service struct { | ||
Scope FleetsMemberScope | ||
*aso.Service[*asocontainerservicev1.FleetsMember, FleetsMemberScope] | ||
} | ||
|
||
// New creates a new service. | ||
func New(scope FleetsMemberScope) *Service { | ||
svc := aso.NewService[*asocontainerservicev1.FleetsMember, FleetsMemberScope](serviceName, scope) | ||
spec := scope.AzureFleetsMemberSpec() | ||
if spec != nil { | ||
svc.Specs = []azure.ASOResourceSpecGetter[*asocontainerservicev1.FleetsMember]{spec} | ||
} | ||
svc.ConditionType = infrav1.FleetReadyCondition | ||
return &Service{ | ||
Scope: scope, | ||
Service: svc, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
Copyright 2021 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 fleetsmember | ||
|
||
import ( | ||
"context" | ||
|
||
asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20230315preview" | ||
"github.com/Azure/azure-service-operator/v2/pkg/genruntime" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/utils/ptr" | ||
"sigs.k8s.io/cluster-api-provider-azure/azure" | ||
) | ||
|
||
// AzureFleetsMemberSpec defines the specification for azure fleet feature. | ||
type AzureFleetsMemberSpec struct { | ||
Name string | ||
Namespace string | ||
ResourceGroup string | ||
Group string | ||
SubscriptionID string | ||
ManagerName string | ||
ManagerResourceGroup string | ||
} | ||
|
||
// ResourceRef implements azure.ASOResourceSpecGetter. | ||
func (s *AzureFleetsMemberSpec) ResourceRef() *asocontainerservicev1.FleetsMember { | ||
return &asocontainerservicev1.FleetsMember{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: s.Name, | ||
Namespace: s.Namespace, | ||
}, | ||
} | ||
} | ||
|
||
// Parameters implements azure.ASOResourceSpecGetter. | ||
func (s *AzureFleetsMemberSpec) Parameters(ctx context.Context, existingFleetsMember *asocontainerservicev1.FleetsMember) (parameters *asocontainerservicev1.FleetsMember, err error) { | ||
if existingFleetsMember != nil { | ||
return existingFleetsMember, nil | ||
} | ||
|
||
fleetsMember := &asocontainerservicev1.FleetsMember{} | ||
fleetsMember.Spec = asocontainerservicev1.Fleets_Member_Spec{} | ||
fleetsMember.Spec.AzureName = s.ManagerName | ||
fleetsMember.Spec.Owner = &genruntime.KnownResourceReference{ | ||
ARMID: azure.FleetID(s.SubscriptionID, s.ManagerResourceGroup, s.ManagerName), | ||
} | ||
fleetsMember.Spec.Group = ptr.To(s.Group) | ||
fleetsMember.Spec.ClusterResourceReference = &genruntime.ResourceReference{ | ||
ARMID: azure.ManagedClusterID(s.SubscriptionID, s.ResourceGroup, s.Name), | ||
} | ||
|
||
return fleetsMember, nil | ||
} | ||
|
||
// WasManaged implements azure.ASOResourceSpecGetter. | ||
func (s *AzureFleetsMemberSpec) WasManaged(resource *asocontainerservicev1.FleetsMember) bool { | ||
// returns always returns true as CAPZ does not support BYO fleet. | ||
return true | ||
} |
Oops, something went wrong.