Skip to content

Commit 1a71dd9

Browse files
authored
Merge pull request #4242 from mihaiandreiratoiu/cp/pdns-1.11
[release-1.11] Set correct fqdn on private cluster
2 parents 2cc50db + de721bb commit 1a71dd9

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

azure/services/managedclusters/managedclusters.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ func (s *Service) Reconcile(ctx context.Context) error {
9898
Host: ptr.Deref(managedCluster.Properties.Fqdn, ""),
9999
Port: 443,
100100
}
101+
if managedCluster.Properties.APIServerAccessProfile != nil &&
102+
ptr.Deref(managedCluster.Properties.APIServerAccessProfile.EnablePrivateCluster, false) &&
103+
!ptr.Deref(managedCluster.Properties.APIServerAccessProfile.EnablePrivateClusterPublicFQDN, false) {
104+
endpoint = clusterv1.APIEndpoint{
105+
Host: ptr.Deref(managedCluster.Properties.PrivateFQDN, ""),
106+
Port: 443,
107+
}
108+
}
101109
s.Scope.SetControlPlaneEndpoint(endpoint)
102110

103111
// Update kubeconfig data

azure/services/managedclusters/managedclusters_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,44 @@ func TestReconcile(t *testing.T) {
9090
s.UpdatePutStatus(infrav1.ManagedClusterRunningCondition, serviceName, nil)
9191
},
9292
},
93+
{
94+
name: "create private managed cluster succeeds",
95+
expectedError: "",
96+
expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) {
97+
s.ManagedClusterSpec().Return(fakeManagedClusterSpec)
98+
r.CreateOrUpdateResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(armcontainerservice.ManagedCluster{
99+
Properties: &armcontainerservice.ManagedClusterProperties{
100+
APIServerAccessProfile: &armcontainerservice.ManagedClusterAPIServerAccessProfile{
101+
EnablePrivateCluster: ptr.To(true),
102+
EnablePrivateClusterPublicFQDN: ptr.To(false),
103+
},
104+
PrivateFQDN: ptr.To("my-managedcluster-fqdn.private"),
105+
ProvisioningState: ptr.To("Succeeded"),
106+
IdentityProfile: map[string]*armcontainerservice.UserAssignedIdentity{
107+
kubeletIdentityKey: {
108+
ResourceID: ptr.To("kubelet-id"),
109+
},
110+
},
111+
OidcIssuerProfile: &armcontainerservice.ManagedClusterOIDCIssuerProfile{
112+
Enabled: ptr.To(true),
113+
IssuerURL: ptr.To("oidc issuer url"),
114+
},
115+
},
116+
}, nil)
117+
s.SetControlPlaneEndpoint(clusterv1.APIEndpoint{
118+
Host: "my-managedcluster-fqdn.private",
119+
Port: 443,
120+
})
121+
m.GetCredentials(gomockinternal.AContext(), "my-rg", "my-managedcluster").Return([]byte("credentials"), nil)
122+
s.SetKubeConfigData([]byte("credentials"))
123+
s.SetKubeletIdentity("kubelet-id")
124+
s.SetOIDCIssuerProfileStatus(nil)
125+
s.SetOIDCIssuerProfileStatus(&infrav1.OIDCIssuerProfileStatus{
126+
IssuerURL: ptr.To("oidc issuer url"),
127+
})
128+
s.UpdatePutStatus(infrav1.ManagedClusterRunningCondition, serviceName, nil)
129+
},
130+
},
93131
{
94132
name: "fail to get managed cluster credentials",
95133
expectedError: "failed to get credentials for managed cluster: internal server error",

0 commit comments

Comments
 (0)