Skip to content

Commit 9c70865

Browse files
Merge pull request openshift#8786 from jhixson74/capz_managed_identity
OCPBUGS-36361: Azure: If credentialsMode is manual, pass the identity through
2 parents 8453641 + 51c9897 commit 9c70865

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/asset/manifests/azure/cluster.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/openshift/installer/pkg/asset"
1414
"github.com/openshift/installer/pkg/asset/installconfig"
15+
azic "github.com/openshift/installer/pkg/asset/installconfig/azure"
1516
"github.com/openshift/installer/pkg/asset/manifests/capiutils"
1617
"github.com/openshift/installer/pkg/asset/manifests/capiutils/cidr"
1718
"github.com/openshift/installer/pkg/types"
@@ -200,6 +201,10 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
200201
TenantID: session.Credentials.TenantID,
201202
},
202203
}
204+
if session.AuthType == azic.ManagedIdentityAuth {
205+
id.Spec.Type = capz.UserAssignedMSI
206+
id.Spec.ClientSecret = corev1.SecretReference{}
207+
}
203208
id.SetGroupVersionKind(capz.GroupVersion.WithKind("AzureClusterIdentity"))
204209
manifests = append(manifests, &asset.RuntimeFile{
205210
Object: id,

pkg/infrastructure/azure/dns.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
88
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
9-
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
109
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns"
1110
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns"
1211
"k8s.io/utils/ptr"
@@ -89,11 +88,7 @@ func createDNSEntries(ctx context.Context, in clusterapi.InfraReadyInput, extLBF
8988
subscriptionID := session.Credentials.SubscriptionID
9089
cloudConfiguration := session.CloudConfig
9190

92-
tokenCreds, err := azidentity.NewClientSecretCredential(session.Credentials.TenantID, session.Credentials.ClientID, session.Credentials.ClientSecret, nil)
93-
if err != nil {
94-
return fmt.Errorf("failed to create identity: %w", err)
95-
}
96-
recordSetClient, err := armdns.NewRecordSetsClient(subscriptionID, tokenCreds,
91+
recordSetClient, err := armdns.NewRecordSetsClient(subscriptionID, session.TokenCreds,
9792
&arm.ClientOptions{
9893
ClientOptions: policy.ClientOptions{
9994
Cloud: cloudConfiguration,
@@ -103,7 +98,7 @@ func createDNSEntries(ctx context.Context, in clusterapi.InfraReadyInput, extLBF
10398
if err != nil {
10499
return fmt.Errorf("failed to create public record client: %w", err)
105100
}
106-
privateRecordSetClient, err := armprivatedns.NewRecordSetsClient(subscriptionID, tokenCreds,
101+
privateRecordSetClient, err := armprivatedns.NewRecordSetsClient(subscriptionID, session.TokenCreds,
107102
&arm.ClientOptions{
108103
ClientOptions: policy.ClientOptions{
109104
Cloud: cloudConfiguration,

0 commit comments

Comments
 (0)