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 committed Dec 18, 2024
1 parent 7c83fbc commit d11b853
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 string, secGroup string, routeTable string) {
subnetName = fmt.Sprintf("%s-node-subnet", azureCluster.Name)
for _, sn := range azureCluster.Spec.NetworkSpec.Subnets {
if sn.Name == subnetName {
secGroup = sn.SecurityGroup.Name
routeTable = sn.RouteTable.Name
break
}
}
return
}

0 comments on commit d11b853

Please sign in to comment.