Skip to content

Commit

Permalink
Merge pull request #4241 from mihaiandreiratoiu/fix/private-dns
Browse files Browse the repository at this point in the history
[release-1.10] Set correct fqdn on private cluster
  • Loading branch information
k8s-ci-robot authored Nov 7, 2023
2 parents ebec548 + b18aaf7 commit 0740df0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
8 changes: 8 additions & 0 deletions azure/services/managedclusters/managedclusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ func (s *Service) Reconcile(ctx context.Context) error {
Host: pointer.StringDeref(managedCluster.ManagedClusterProperties.Fqdn, ""),
Port: 443,
}
if managedCluster.ManagedClusterProperties.APIServerAccessProfile != nil &&
pointer.BoolDeref(managedCluster.ManagedClusterProperties.APIServerAccessProfile.EnablePrivateCluster, false) &&
!pointer.BoolDeref(managedCluster.ManagedClusterProperties.APIServerAccessProfile.EnablePrivateClusterPublicFQDN, false) {
endpoint = clusterv1.APIEndpoint{
Host: pointer.StringDeref(managedCluster.ManagedClusterProperties.PrivateFQDN, ""),
Port: 443,
}
}
s.Scope.SetControlPlaneEndpoint(endpoint)

// Update kubeconfig data
Expand Down
30 changes: 30 additions & 0 deletions azure/services/managedclusters/managedclusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,36 @@ func TestReconcile(t *testing.T) {
s.UpdatePutStatus(infrav1.ManagedClusterRunningCondition, serviceName, nil)
},
},
{
name: "create managed private cluster succeeds",
expectedError: "",
expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) {
s.ManagedClusterSpec().Return(fakeManagedClusterSpec)
r.CreateOrUpdateResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(containerservice.ManagedCluster{
ManagedClusterProperties: &containerservice.ManagedClusterProperties{
APIServerAccessProfile: &containerservice.ManagedClusterAPIServerAccessProfile{
EnablePrivateCluster: pointer.Bool(true),
EnablePrivateClusterPublicFQDN: pointer.Bool(false),
},
PrivateFQDN: pointer.String("my-managedcluster-fqdn.private"),
ProvisioningState: pointer.String("Succeeded"),
IdentityProfile: map[string]*containerservice.UserAssignedIdentity{
kubeletIdentityKey: {
ResourceID: pointer.String("kubelet-id"),
},
},
},
}, nil)
s.SetControlPlaneEndpoint(clusterv1.APIEndpoint{
Host: "my-managedcluster-fqdn.private",
Port: 443,
})
m.GetCredentials(gomockinternal.AContext(), "my-rg", "my-managedcluster").Return([]byte("credentials"), nil)
s.SetKubeConfigData([]byte("credentials"))
s.SetKubeletIdentity("kubelet-id")
s.UpdatePutStatus(infrav1.ManagedClusterRunningCondition, serviceName, nil)
},
},
{
name: "fail to get managed cluster credentials",
expectedError: "failed to get credentials for managed cluster: internal server error",
Expand Down

0 comments on commit 0740df0

Please sign in to comment.