Skip to content

Commit

Permalink
Merge branch 'main' into clusterclass-aks-final
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Nov 6, 2023
2 parents 6d06ee6 + fc7bb60 commit 15c4dbc
Show file tree
Hide file tree
Showing 63 changed files with 1,787 additions and 262 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: 'Checkout Repository'
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: 'Dependency Review'
uses: actions/dependency-review-action@6c5ccdad469c9f8a2996bfecaec55a631a347034 # v3.1.0
uses: actions/dependency-review-action@9f45b2463b475767b61721ccfef113fef513e6aa # v3.1.1
12 changes: 12 additions & 0 deletions api/v1beta1/azuremanagedcontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ type AzureManagedControlPlaneSpec struct {
// +optional
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint,omitempty"`

// AdditionalTags is an optional set of tags to add to Azure resources managed by the Azure provider, in addition to the
// ones added by default.
// +optional
AdditionalTags Tags `json:"additionalTags,omitempty"`

// NetworkPlugin used for building Kubernetes network.
// Allowed values are "azure", "kubenet".
// Immutable.
// +kubebuilder:validation:Enum=azure;kubenet;none
// +optional
NetworkPlugin *string `json:"networkPlugin,omitempty"`

// NetworkPluginMode is the mode the network plugin should use.
// Allowed value is "overlay".
// +kubebuilder:validation:Enum=overlay
Expand Down
6 changes: 6 additions & 0 deletions azure/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import (

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// Reconciler is a generic interface for a controller reconciler which has Reconcile and Delete methods.
Expand Down Expand Up @@ -79,6 +81,7 @@ type NetworkDescriber interface {
type ClusterDescriber interface {
Authorizer
ResourceGroup() string
NodeResourceGroup() string
ClusterName() string
Location() string
ExtendedLocation() *infrav1.ExtendedLocationSpec
Expand All @@ -104,6 +107,9 @@ type AsyncStatusUpdater interface {
type ClusterScoper interface {
ClusterDescriber
NetworkDescriber
AsyncStatusUpdater
GetClient() client.Client
GetDeletionTimestamp() *metav1.Time
}

// ManagedClusterScoper defines the interface for ManagedClusterScope.
Expand Down
132 changes: 132 additions & 0 deletions azure/mock_azure/azure_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions azure/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ func (s *ClusterScope) GetClient() client.Client {
return s.Client
}

// GetDeletionTimestamp returns the deletion timestamp of the Cluster.
func (s *ClusterScope) GetDeletionTimestamp() *metav1.Time {
return s.Cluster.DeletionTimestamp
}

// PublicIPSpecs returns the public IP specs.
func (s *ClusterScope) PublicIPSpecs() []azure.ResourceSpecGetter {
var publicIPSpecs []azure.ResourceSpecGetter
Expand Down Expand Up @@ -740,6 +745,12 @@ func (s *ClusterScope) ResourceGroup() string {
return s.AzureCluster.Spec.ResourceGroup
}

// NodeResourceGroup returns the resource group where nodes live.
// For AzureClusters this is the same as the cluster RG.
func (s *ClusterScope) NodeResourceGroup() string {
return s.ResourceGroup()
}

// ClusterName returns the cluster name.
func (s *ClusterScope) ClusterName() string {
return s.Cluster.Name
Expand Down
26 changes: 13 additions & 13 deletions azure/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (m *MachineScope) VMSpec() azure.ResourceSpecGetter {
Name: m.Name(),
Location: m.Location(),
ExtendedLocation: m.ExtendedLocation(),
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
ClusterName: m.ClusterName(),
Role: m.Role(),
NICIDs: m.NICIDs(),
Expand Down Expand Up @@ -193,7 +193,7 @@ func (m *MachineScope) VMSpec() azure.ResourceSpecGetter {
func (m *MachineScope) TagsSpecs() []azure.TagsSpec {
return []azure.TagsSpec{
{
Scope: azure.VMID(m.SubscriptionID(), m.ResourceGroup(), m.Name()),
Scope: azure.VMID(m.SubscriptionID(), m.NodeResourceGroup(), m.Name()),
Tags: m.AdditionalTags(),
Annotation: azure.VMTagsLastAppliedAnnotation,
},
Expand All @@ -206,7 +206,7 @@ func (m *MachineScope) PublicIPSpecs() []azure.ResourceSpecGetter {
if m.AzureMachine.Spec.AllocatePublicIP {
specs = append(specs, &publicips.PublicIPSpec{
Name: azure.GenerateNodePublicIPName(m.Name()),
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
ClusterName: m.ClusterName(),
DNSName: "", // Set to default value
IsIPv6: false, // Set to default value
Expand All @@ -225,13 +225,13 @@ func (m *MachineScope) InboundNatSpecs() []azure.ResourceSpecGetter {
if m.Role() == infrav1.ControlPlane {
spec := &inboundnatrules.InboundNatSpec{
Name: m.Name(),
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
LoadBalancerName: m.APIServerLBName(),
FrontendIPConfigurationID: nil,
}
if frontEndIPs := m.APIServerLB().FrontendIPs; len(frontEndIPs) > 0 {
ipConfig := frontEndIPs[0].Name
id := azure.FrontendIPConfigID(m.SubscriptionID(), m.ResourceGroup(), m.APIServerLBName(), ipConfig)
id := azure.FrontendIPConfigID(m.SubscriptionID(), m.NodeResourceGroup(), m.APIServerLBName(), ipConfig)
spec.FrontendIPConfigurationID = ptr.To(id)
}

Expand Down Expand Up @@ -260,7 +260,7 @@ func (m *MachineScope) NICSpecs() []azure.ResourceSpecGetter {
func (m *MachineScope) BuildNICSpec(nicName string, infrav1NetworkInterface infrav1.NetworkInterface, primaryNetworkInterface bool) *networkinterfaces.NICSpec {
spec := &networkinterfaces.NICSpec{
Name: nicName,
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
Location: m.Location(),
ExtendedLocation: m.ExtendedLocation(),
SubscriptionID: m.SubscriptionID(),
Expand Down Expand Up @@ -328,13 +328,13 @@ func (m *MachineScope) DiskSpecs() []azure.ResourceSpecGetter {
diskSpecs := make([]azure.ResourceSpecGetter, 1+len(m.AzureMachine.Spec.DataDisks))
diskSpecs[0] = &disks.DiskSpec{
Name: azure.GenerateOSDiskName(m.Name()),
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
}

for i, dd := range m.AzureMachine.Spec.DataDisks {
diskSpecs[i+1] = &disks.DiskSpec{
Name: azure.GenerateDataDiskName(m.Name(), dd.NameSuffix),
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
}
}
return diskSpecs
Expand All @@ -348,7 +348,7 @@ func (m *MachineScope) RoleAssignmentSpecs(principalID *string) []azure.Resource
Name: m.SystemAssignedIdentityName(),
MachineName: m.Name(),
ResourceType: azure.VirtualMachine,
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
Scope: m.SystemAssignedIdentityScope(),
RoleDefinitionID: m.SystemAssignedIdentityDefinitionID(),
PrincipalID: principalID,
Expand Down Expand Up @@ -382,7 +382,7 @@ func (m *MachineScope) VMExtensionSpecs() []azure.ResourceSpecGetter {
Settings: extension.Settings,
ProtectedSettings: extension.ProtectedSettings,
},
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
Location: m.Location(),
})
}
Expand All @@ -393,7 +393,7 @@ func (m *MachineScope) VMExtensionSpecs() []azure.ResourceSpecGetter {
if bootstrapExtensionSpec != nil {
extensionSpecs = append(extensionSpecs, &vmextensions.VMExtensionSpec{
ExtensionSpec: *bootstrapExtensionSpec,
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
Location: m.Location(),
})
}
Expand Down Expand Up @@ -482,7 +482,7 @@ func (m *MachineScope) AvailabilitySetSpec() azure.ResourceSpecGetter {

spec := &availabilitysets.AvailabilitySetSpec{
Name: availabilitySetName,
ResourceGroup: m.ResourceGroup(),
ResourceGroup: m.NodeResourceGroup(),
ClusterName: m.ClusterName(),
Location: m.Location(),
SKU: nil,
Expand Down Expand Up @@ -524,7 +524,7 @@ func (m *MachineScope) AvailabilitySet() (string, bool) {
func (m *MachineScope) AvailabilitySetID() string {
var asID string
if asName, ok := m.AvailabilitySet(); ok {
asID = azure.AvailabilitySetID(m.SubscriptionID(), m.ResourceGroup(), asName)
asID = azure.AvailabilitySetID(m.SubscriptionID(), m.NodeResourceGroup(), asName)
}
return asID
}
Expand Down
Loading

0 comments on commit 15c4dbc

Please sign in to comment.