Skip to content

Commit

Permalink
Rollback custom resource group
Browse files Browse the repository at this point in the history
  • Loading branch information
kahun committed Jun 23, 2023
1 parent c260c2f commit b73a03e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
18 changes: 5 additions & 13 deletions pkg/cluster/internal/create/actions/createworker/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ func installCloudProvider(n nodes.Node, descriptorFile commons.DescriptorFile, k
return nil
}

func assignUserIdentity(d commons.DescriptorFile, s map[string]string) error {
var cluster string

func assignUserIdentity(i string, c string, r string, s map[string]string) error {
creds, err := azidentity.NewClientSecretCredential(s["TenantID"], s["ClientID"], s["ClientSecret"], nil)
if err != nil {
return err
Expand All @@ -153,26 +151,20 @@ func assignUserIdentity(d commons.DescriptorFile, s map[string]string) error {
}
managedClustersClient := containerserviceClientFactory.NewManagedClustersClient()

if d.ControlPlane.Azure.ResourceGroup != "" {
cluster = d.ControlPlane.Azure.ResourceGroup
} else {
cluster = d.ClusterID
}

pollerResp, err := managedClustersClient.BeginCreateOrUpdate(
ctx, cluster, cluster,
ctx, c, c,
armcontainerservice.ManagedCluster{
Location: to.Ptr(d.Region),
Location: to.Ptr(r),
Identity: &armcontainerservice.ManagedClusterIdentity{
Type: to.Ptr(armcontainerservice.ResourceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armcontainerservice.ManagedServiceIdentityUserAssignedIdentitiesValue{
d.Security.NodesIdentity: {},
i: {},
},
},
Properties: &armcontainerservice.ManagedClusterProperties{
IdentityProfile: map[string]*armcontainerservice.UserAssignedIdentity{
"kubeletidentity": {
ResourceID: to.Ptr(d.Security.NodesIdentity),
ResourceID: to.Ptr(i),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (a *action) Execute(ctx *actions.ActionContext) error {

if provider.capxProvider == "azure" && descriptorFile.ControlPlane.Managed && descriptorFile.Security.NodesIdentity != "" {
// Update AKS cluster with the user kubelet identity until the provider supports it
err := assignUserIdentity(*descriptorFile, credentialsMap)
err := assignUserIdentity(descriptorFile.Security.NodesIdentity, descriptorFile.ClusterID, descriptorFile.Region, credentialsMap)
if err != nil {
return errors.Wrap(err, "failed to assign user identity to the workload Cluster")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ spec:
location: "{{ .Descriptor.Region }}"
sku:
tier: "{{ .Descriptor.ControlPlane.Azure.Tier }}"
resourceGroupName: {{ if ne .Descriptor.ControlPlane.Azure.ResourceGroup "" }}{{ .Descriptor.ControlPlane.Azure.ResourceGroup }}{{ else }}{{ .Descriptor.ClusterID }}{{- end }}
nodeResourceGroupName: {{ if ne .Descriptor.ControlPlane.Azure.ResourceGroup "" }}{{ .Descriptor.ControlPlane.Azure.ResourceGroup }}{{ else }}{{ .Descriptor.ClusterID }}{{- end }}-nodes
resourceGroupName: {{ .Descriptor.ClusterID }}
nodeResourceGroupName: {{ .Descriptor.ClusterID }}-nodes
networkPolicy: calico
sshPublicKey: \"\"
subscriptionID: "{{ .Credentials.SubscriptionID }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
- name: node-subnet
role: node
{{- end }}
resourceGroup: {{ if ne .Descriptor.ControlPlane.Azure.ResourceGroup "" }}{{ .Descriptor.ControlPlane.Azure.ResourceGroup }}{{ else }}{{ .Descriptor.ClusterID }}{{- end }}
resourceGroup: {{ .Descriptor.ClusterID }}
subscriptionID: {{ .Credentials.SubscriptionID }}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
Expand Down
3 changes: 1 addition & 2 deletions pkg/commons/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ type AWSCP struct {
}

type AzureCP struct {
ResourceGroup string `yaml:"resource_group"`
Tier string `yaml:"tier" validate:"oneof='Free' 'Paid'"`
Tier string `yaml:"tier" validate:"oneof='Free' 'Paid'"`
}

type WorkerNodes []struct {
Expand Down

0 comments on commit b73a03e

Please sign in to comment.