Skip to content

Commit

Permalink
Merge pull request #4815 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…4725-to-release-1.14

[release-1.14] Allow upper-case resource names
  • Loading branch information
k8s-ci-robot authored May 7, 2024
2 parents cfe0748 + 9b95377 commit 03ea504
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 20 deletions.
4 changes: 2 additions & 2 deletions azure/services/agentpools/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ func (s *AgentPoolSpec) ResourceRef() genruntime.MetaObject {
if s.Preview {
return &asocontainerservicev1preview.ManagedClustersAgentPool{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
},
}
}
return &asocontainerservicev1.ManagedClustersAgentPool{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
},
}
}
Expand Down
3 changes: 2 additions & 1 deletion azure/services/aksextensions/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure"
)

// AKSExtensionSpec defines the specification for an AKS Extension.
Expand All @@ -47,7 +48,7 @@ type AKSExtensionSpec struct {
func (s *AKSExtensionSpec) ResourceRef() *asokubernetesconfigurationv1.Extension {
return &asokubernetesconfigurationv1.Extension{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
Namespace: s.Namespace,
},
}
Expand Down
5 changes: 3 additions & 2 deletions azure/services/bastionhosts/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure"
)

// AzureBastionSpec defines the specification for azure bastion feature.
Expand All @@ -44,7 +45,7 @@ type AzureBastionSpec struct {
func (s *AzureBastionSpec) ResourceRef() *asonetworkv1.BastionHost {
return &asonetworkv1.BastionHost{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
},
}
}
Expand All @@ -60,7 +61,7 @@ func (s *AzureBastionSpec) Parameters(ctx context.Context, existingBastionHost *
bastionHost.Spec.AzureName = s.Name
bastionHost.Spec.Location = ptr.To(s.Location)
bastionHost.Spec.Owner = &genruntime.KnownResourceReference{
Name: s.ResourceGroup,
Name: azure.GetNormalizedKubernetesName(s.ResourceGroup),
}
bastionHost.Spec.Tags = infrav1.Build(infrav1.BuildParams{
ClusterName: s.ClusterName,
Expand Down
2 changes: 1 addition & 1 deletion azure/services/groups/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *Service) IsManaged(ctx context.Context) (bool, error) {
// resource. We also need to check that deleting the ASO resource will really
// delete the underlying resource group by checking the ASO reconcile-policy.
group := spec.ResourceRef()
groupName := group.Name
groupName := azure.GetNormalizedKubernetesName(group.Name)
groupNamespace := s.Scope.ASOOwner().GetNamespace()
err = s.Scope.GetClient().Get(ctx, client.ObjectKey{Namespace: groupNamespace, Name: groupName}, group)
if err != nil || group.GetAnnotations()[asoannotations.ReconcilePolicy] != string(asoannotations.ReconcilePolicyManage) {
Expand Down
3 changes: 2 additions & 1 deletion azure/services/groups/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
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"
)

Expand All @@ -39,7 +40,7 @@ type GroupSpec struct {
func (s *GroupSpec) ResourceRef() *asoresourcesv1.ResourceGroup {
return &asoresourcesv1.ResourceGroup{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions azure/services/managedclusters/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,13 @@ func (s *ManagedClusterSpec) ResourceRef() genruntime.MetaObject {
if s.Preview {
return &asocontainerservicev1preview.ManagedCluster{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
},
}
}
return &asocontainerservicev1.ManagedCluster{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
},
}
}
Expand Down Expand Up @@ -441,7 +441,7 @@ func (s *ManagedClusterSpec) Parameters(ctx context.Context, existingObj genrunt

managedCluster.Spec.AzureName = s.Name
managedCluster.Spec.Owner = &genruntime.KnownResourceReference{
Name: s.ResourceGroup,
Name: azure.GetNormalizedKubernetesName(s.ResourceGroup),
}
managedCluster.Spec.Identity = &asocontainerservicev1.ManagedClusterIdentity{
Type: ptr.To(asocontainerservicev1.ManagedClusterIdentity_Type_SystemAssigned),
Expand Down
4 changes: 2 additions & 2 deletions azure/services/natgateways/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type NatGatewaySpec struct {
func (s *NatGatewaySpec) ResourceRef() *asonetworkv1.NatGateway {
return &asonetworkv1.NatGateway{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
},
}
}
Expand All @@ -59,7 +59,7 @@ func (s *NatGatewaySpec) Parameters(ctx context.Context, existingNatGateway *aso

natGateway.Spec.AzureName = s.Name
natGateway.Spec.Owner = &genruntime.KnownResourceReference{
Name: s.ResourceGroup,
Name: azure.GetNormalizedKubernetesName(s.ResourceGroup),
}
natGateway.Spec.Location = ptr.To(s.Location)
natGateway.Spec.Sku = &asonetworkv1.NatGatewaySku{
Expand Down
5 changes: 3 additions & 2 deletions azure/services/privateendpoints/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure"
)

// PrivateLinkServiceConnection defines the specification for a private link service connection associated with a private endpoint.
Expand Down Expand Up @@ -54,7 +55,7 @@ type PrivateEndpointSpec struct {
func (s *PrivateEndpointSpec) ResourceRef() *asonetworkv1.PrivateEndpoint {
return &asonetworkv1.PrivateEndpoint{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
},
}
}
Expand Down Expand Up @@ -129,7 +130,7 @@ func (s *PrivateEndpointSpec) Parameters(ctx context.Context, existingPrivateEnd
}

privateEndpoint.Spec.Owner = &genruntime.KnownResourceReference{
Name: s.ResourceGroup,
Name: azure.GetNormalizedKubernetesName(s.ResourceGroup),
}

privateEndpoint.Spec.Subnet = &asonetworkv1.Subnet_PrivateEndpoint_SubResourceEmbedded{
Expand Down
2 changes: 1 addition & 1 deletion azure/services/privateendpoints/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
var (
fakePrivateEndpoint = PrivateEndpointSpec{
Name: "test_private_endpoint_1",
ResourceGroup: "test_rg",
ResourceGroup: "test-rg",
Location: "test_location",
CustomNetworkInterfaceName: "test_if_name",
PrivateIPAddresses: []string{"1.2.3.4", "5.6.7.8"},
Expand Down
4 changes: 2 additions & 2 deletions azure/services/subnets/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (s *SubnetSpec) ResourceRef() *asonetworkv1.VirtualNetworksSubnet {
ObjectMeta: metav1.ObjectMeta{
// s.Name isn't unique per-cluster, so combine with vnet name to avoid collisions.
// ToLower makes the name compatible with standard Kubernetes name requirements.
Name: s.VNetName + "-" + strings.ToLower(s.Name),
Name: azure.GetNormalizedKubernetesName(s.VNetName + "-" + strings.ToLower(s.Name)),
},
}
}
Expand All @@ -64,7 +64,7 @@ func (s *SubnetSpec) Parameters(ctx context.Context, existing *asonetworkv1.Virt
subnet.Spec = asonetworkv1.VirtualNetworks_Subnet_Spec{
AzureName: s.Name,
Owner: &genruntime.KnownResourceReference{
Name: s.VNetName,
Name: azure.GetNormalizedKubernetesName(s.VNetName),
},
AddressPrefixes: s.CIDRs,
}
Expand Down
5 changes: 3 additions & 2 deletions azure/services/virtualnetworks/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
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/converters"
)

Expand All @@ -42,7 +43,7 @@ type VNetSpec struct {
func (s *VNetSpec) ResourceRef() *asonetworkv1.VirtualNetwork {
return &asonetworkv1.VirtualNetwork{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: azure.GetNormalizedKubernetesName(s.Name),
},
}
}
Expand All @@ -66,7 +67,7 @@ func (s *VNetSpec) Parameters(ctx context.Context, existing *asonetworkv1.Virtua

vnet.Spec.AzureName = s.Name
vnet.Spec.Owner = &genruntime.KnownResourceReference{
Name: s.ResourceGroup,
Name: azure.GetNormalizedKubernetesName(s.ResourceGroup),
}
vnet.Spec.Location = ptr.To(s.Location)
vnet.Spec.ExtendedLocation = converters.ExtendedLocationToNetworkASO(s.ExtendedLocation)
Expand Down
2 changes: 2 additions & 0 deletions docs/book/src/topics/managedcluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export AZURE_LOCATION="southcentralus"
export AZURE_RESOURCE_GROUP="${CLUSTER_NAME}"
```

***NOTE***: `${CLUSTER_NAME}` should adhere to the RFC 1123 standard. This means that it must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.

Create a new service principal and save to a local file:

```bash
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/aks_marketplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type AKSMarketplaceExtensionSpecInput struct {
}

const (
extensionName = "aks-marketplace-extension"
extensionName = "AKS-marketplace-extension" // Test that upper case name is allowed
officialExtensionName = "official-aks-extension"
)

Expand Down

0 comments on commit 03ea504

Please sign in to comment.