diff --git a/test/e2e/azure_apiserver_ilb.go b/test/e2e/azure_apiserver_ilb.go index 4cfbd6c990a..a172023c629 100644 --- a/test/e2e/azure_apiserver_ilb.go +++ b/test/e2e/azure_apiserver_ilb.go @@ -115,12 +115,13 @@ import ( // AzureAPIServerILBSpecInput is the input for AzureAPIServerILBSpec. type AzureAPIServerILBSpecInput struct { - BootstrapClusterProxy framework.ClusterProxy - Cluster *clusterv1.Cluster - Namespace *corev1.Namespace - ClusterName string - ExpectedWorkerNodes int32 - WaitIntervals []interface{} + BootstrapClusterProxy framework.ClusterProxy + Cluster *clusterv1.Cluster + Namespace *corev1.Namespace + ClusterName string + ExpectedWorkerNodes int32 + WaitIntervals []interface{} + TemplateHasPrivateIPCustomDNSResolution bool } // AzureAPIServerILBSpec implements a test that verifies the Azure API server ILB is created. @@ -205,16 +206,23 @@ func AzureAPIServerILBSpec(ctx context.Context, inputGetter func() AzureAPIServe Expect(err).NotTo(HaveOccurred()) By("Getting the controlplane endpoint name") - controlPlaneEndpointName, apiServerILBPrivateIP := "", "" + controlPlaneEndpointDNSName, apiServerILBPrivateIP := "", "" for _, frontendIP := range deployedAzureCluster.Spec.NetworkSpec.APIServerLB.FrontendIPs { if frontendIP.PublicIP != nil && frontendIP.PublicIP.DNSName != "" { - controlPlaneEndpointName = frontendIP.PublicIP.DNSName + fmt.Fprintf(GinkgoWriter, "Control Plane Endpoint Name: %s\n", frontendIP.PublicIP.DNSName) + controlPlaneEndpointDNSName = frontendIP.PublicIP.DNSName } else if frontendIP.PrivateIPAddress != "" { + fmt.Fprintf(GinkgoWriter, "API Server ILB Private IP: %s\n", frontendIP.PrivateIPAddress) apiServerILBPrivateIP = frontendIP.PrivateIPAddress } } - Expect(controlPlaneEndpointName).NotTo(BeEmpty(), "controlPlaneEndpointName should be found at AzureCluster.Spec.NetworkSpec.APIServerLB.FrontendIPs with a valid DNS name") - Expect(controlPlaneEndpointName).To(Equal(fmt.Sprintf("%s-%s.%s.cloudapp.azure.com", input.ClusterName, os.Getenv("APISERVER_LB_DNS_SUFFIX"), os.Getenv("AZURE_LOCATION")))) + + // skip checking the controlPlaneEndpointDNSName in case of default template + // TODO: remove this block when the underlying infra spec is also updated with private IP of the internal load balancer + if input.TemplateHasPrivateIPCustomDNSResolution { + Expect(controlPlaneEndpointDNSName).NotTo(BeEmpty(), "controlPlaneEndpointDNSName should be found at AzureCluster.Spec.NetworkSpec.APIServerLB.FrontendIPs with a valid DNS name") + Expect(controlPlaneEndpointDNSName).To(Equal(fmt.Sprintf("%s-%s.%s.cloudapp.azure.com", input.ClusterName, os.Getenv("APISERVER_LB_DNS_SUFFIX"), os.Getenv("AZURE_LOCATION")))) + } Expect(apiServerILBPrivateIP).NotTo(BeEmpty(), "apiServerILBPrivateIP should be found at AzureCluster.Spec.NetworkSpec.APIServerLB.FrontendIPs when apiserver ilb feature flag is enabled") // ------------------------ // @@ -419,6 +427,14 @@ func AzureAPIServerILBSpec(ctx context.Context, inputGetter func() AzureAPIServe if strings.Contains(output, expectedCmdOutput) { testResult[expectedCmdOutput] = true } + + // TODO: remove this below block when the underlying infra spec is also updated with + // private IP of the internal load balancer + // For now, a default template will not have the private IP of the internal load balancer in its /etc/hosts + // So, we will skip the test for default templates. + if !input.TemplateHasPrivateIPCustomDNSResolution { + testResult[expectedCmdOutput] = true + } } if testResult[apiServerILBPrivateIP] && testResult["Hello from node-debug pod"] { diff --git a/test/e2e/azure_test.go b/test/e2e/azure_test.go index 9fc53783458..b9b1467da1f 100644 --- a/test/e2e/azure_test.go +++ b/test/e2e/azure_test.go @@ -1189,12 +1189,13 @@ var _ = Describe("Workload cluster creation", func() { By("Probing workload cluster with APIServerILB feature gate", func() { AzureAPIServerILBSpec(ctx, func() AzureAPIServerILBSpecInput { return AzureAPIServerILBSpecInput{ - BootstrapClusterProxy: bootstrapClusterProxy, - Cluster: result.Cluster, - Namespace: namespace, - ClusterName: clusterName, - ExpectedWorkerNodes: result.ExpectedWorkerNodes(), - WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), + BootstrapClusterProxy: bootstrapClusterProxy, + Cluster: result.Cluster, + Namespace: namespace, + ClusterName: clusterName, + ExpectedWorkerNodes: result.ExpectedWorkerNodes(), + WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), + TemplateHasPrivateIPCustomDNSResolution: false, } }) }) @@ -1203,7 +1204,7 @@ var _ = Describe("Workload cluster creation", func() { }) }) - Context("Creating a self-managed VM based cluster using API Server ILB feature gate and fully spec-ed out template [OPTIONAL][API-Server-ILB]", func() { + Context("Creating a self-managed VM based cluster using API Server ILB feature gate and fully spec-ed out APIServer ILB template [OPTIONAL][API-Server-ILB]", func() { It("with three controlplane node and three worker nodes", func() { clusterName = getClusterName(clusterNamePrefix, "apiserver-ilb") @@ -1239,12 +1240,13 @@ var _ = Describe("Workload cluster creation", func() { By("Probing workload cluster with APIServerILB feature gate", func() { AzureAPIServerILBSpec(ctx, func() AzureAPIServerILBSpecInput { return AzureAPIServerILBSpecInput{ - BootstrapClusterProxy: bootstrapClusterProxy, - Cluster: result.Cluster, - Namespace: namespace, - ClusterName: clusterName, - ExpectedWorkerNodes: result.ExpectedWorkerNodes(), - WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), + BootstrapClusterProxy: bootstrapClusterProxy, + Cluster: result.Cluster, + Namespace: namespace, + ClusterName: clusterName, + ExpectedWorkerNodes: result.ExpectedWorkerNodes(), + WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), + TemplateHasPrivateIPCustomDNSResolution: true, } }) })