Skip to content

Commit

Permalink
Fix azure.json generation: include node-subnet data
Browse files Browse the repository at this point in the history
  • Loading branch information
a13x5 authored and eromanova committed Dec 23, 2024
1 parent a198bc7 commit 8a8e363
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions internal/credspropagation/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,22 @@ func PropagateAzureSecrets(ctx context.Context, cfg *PropagationCfg) error {
}

func generateAzureCCMSecret(azureCluster *capz.AzureCluster, azureClIdty *capz.AzureClusterIdentity, azureSecret *corev1.Secret) (*corev1.Secret, error) {
subnetName, secGroup, routeTable := getAzureSubnetData(azureCluster)
azureJSONMap := map[string]any{
"cloud": azureCluster.Spec.AzureEnvironment,
"tenantId": azureClIdty.Spec.TenantID,
"subscriptionId": azureCluster.Spec.SubscriptionID,
"aadClientId": azureClIdty.Spec.ClientID,
"aadClientSecret": string(azureSecret.Data["clientSecret"]),
"resourceGroup": azureCluster.Spec.ResourceGroup,
"securityGroupName": azureCluster.Spec.NetworkSpec.Subnets[0].SecurityGroup.Name,
"securityGroupName": secGroup,
"securityGroupResourceGroup": azureCluster.Spec.NetworkSpec.Vnet.ResourceGroup,
"location": azureCluster.Spec.Location,
"vmType": "vmss",
"vnetName": azureCluster.Spec.NetworkSpec.Vnet.Name,
"vnetResourceGroup": azureCluster.Spec.NetworkSpec.Vnet.ResourceGroup,
"subnetName": azureCluster.Spec.NetworkSpec.Subnets[0].Name,
"subnetName": subnetName,
"routeTableName": routeTable,
"loadBalancerSku": "Standard",
"loadBalancerName": "",
"maximumLoadBalancerRuleCount": 250,
Expand All @@ -94,3 +96,15 @@ func generateAzureCCMSecret(azureCluster *capz.AzureCluster, azureClIdty *capz.A

return makeSecret("azure-cloud-provider", metav1.NamespaceSystem, secretData), nil
}

func getAzureSubnetData(azureCluster *capz.AzureCluster) (subnetName, secGroup, routeTable string) {
for _, sn := range azureCluster.Spec.NetworkSpec.Subnets {
if sn.Role == "node" {
subnetName = sn.Name
secGroup = sn.SecurityGroup.Name
routeTable = sn.RouteTable.Name
break
}
}
return subnetName, secGroup, routeTable
}

0 comments on commit 8a8e363

Please sign in to comment.