From 0a31b1193612fc9f974051068f747f5b8903ca95 Mon Sep 17 00:00:00 2001 From: ahreehong <46465244+ahreehong@users.noreply.github.com> Date: Fri, 29 Mar 2024 11:41:44 -0700 Subject: [PATCH] Fix proxy configuration for airgapped environments (#7913) --- pkg/helm/factory.go | 3 ++- test/e2e/airgap.go | 19 ++++++++++++++++++- test/e2e/cloudstack_test.go | 22 ++++++++++++++++++++++ test/e2e/vsphere_test.go | 15 +++++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/pkg/helm/factory.go b/pkg/helm/factory.go index 0f56fe0a269b..802fa9b2ffcb 100644 --- a/pkg/helm/factory.go +++ b/pkg/helm/factory.go @@ -52,7 +52,8 @@ func (f *ClientFactory) Get(ctx context.Context, clus *anywherev1.Cluster) (Clie } r := registrymirror.FromCluster(managmentCluster) - helmClient := f.builder.BuildHelm(WithRegistryMirror(r), WithInsecure()) + p := managmentCluster.ProxyConfiguration() + helmClient := f.builder.BuildHelm(WithRegistryMirror(r), WithInsecure(), WithProxyConfig(p)) if r != nil && managmentCluster.RegistryAuth() { if err := helmClient.RegistryLogin(ctx, r.BaseRegistry, rUsername, rPassword); err != nil { diff --git a/test/e2e/airgap.go b/test/e2e/airgap.go index 470653ded6fd..f0ee7d286849 100644 --- a/test/e2e/airgap.go +++ b/test/e2e/airgap.go @@ -22,7 +22,8 @@ const ( bundleReleasePathFromArtifacts = "./eks-anywhere-downloads/bundle-release.yaml" ) -// runAirgapConfigFlow run airgap deployment but allow bootstrap cluster to access local peers. +// runAirgapConfigFlow runs an airgap deployment workflow with a registry mirror configuration, +// and allows bootstrap cluster to access local peers func runAirgapConfigFlow(test *framework.ClusterE2ETest, localCIDRs string) { test.GenerateClusterConfig() test.DownloadArtifacts() @@ -39,6 +40,22 @@ func runAirgapConfigFlow(test *framework.ClusterE2ETest, localCIDRs string) { test.DeleteCluster() } +// runAirgapConfigProxyFlow runs an airgapped deployment workflow with a proxy configuration, +// and allows bootstrap cluster to access local peers. +func runAirgapConfigProxyFlow(test *framework.ClusterE2ETest, localCIDRs string) { + test.GenerateClusterConfig() + test.DownloadArtifacts() + test.ExtractDownloadedArtifacts() + test.AirgapDockerContainers(localCIDRs) + test.CreateAirgappedUser(localCIDRs) + test.AssertAirgappedNetwork() + test.CreateCluster( + framework.WithSudo(airgapUsername), + framework.WithBundlesOverride(bundleReleasePathFromArtifacts), // generated by ExtractDownloadArtifacts + ) + test.DeleteCluster() +} + func runTinkerbellAirgapConfigFlow(test *framework.ClusterE2ETest, localCIDRs, kubeVersion string) { test.DownloadArtifacts() test.ExtractDownloadedArtifacts() diff --git a/test/e2e/cloudstack_test.go b/test/e2e/cloudstack_test.go index 560a4f96b3b6..90c52949b04f 100644 --- a/test/e2e/cloudstack_test.go +++ b/test/e2e/cloudstack_test.go @@ -3609,6 +3609,28 @@ func TestCloudStackKubernetes126RedhatAirgappedRegistryMirror(t *testing.T) { runAirgapConfigFlow(test, "10.0.0.1/8") } +func TestCloudStackKubernetes128RedhatAirgappedProxy(t *testing.T) { + test := framework.NewClusterE2ETest( + t, + framework.NewCloudStack(t, + framework.WithCloudStackRedhat9Kubernetes128(), + framework.WithCloudStackFillers( + framework.RemoveAllCloudStackAzs(), + framework.UpdateAddCloudStackAz3(), + ), + ), + framework.WithClusterFiller( + api.WithStackedEtcdTopology(), + api.WithControlPlaneCount(1), + api.WithWorkerNodeCount(1), + ), + framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube128)), + framework.WithProxy(framework.CloudstackProxyRequiredEnvVars), + ) + + runAirgapConfigProxyFlow(test, "10.0.0.1/8") +} + // Workload API func TestCloudStackMulticlusterWorkloadClusterAPI(t *testing.T) { cloudstack := framework.NewCloudStack(t) diff --git a/test/e2e/vsphere_test.go b/test/e2e/vsphere_test.go index 5d18e5cef6ef..d18f65ac3492 100644 --- a/test/e2e/vsphere_test.go +++ b/test/e2e/vsphere_test.go @@ -4474,6 +4474,7 @@ func TestVSphereUpgradeKubernetesCiliumUbuntuGitHubFluxAPI(t *testing.T) { test.DeleteManagementCluster() } +// Airgapped tests func TestVSphereKubernetes128UbuntuAirgappedRegistryMirror(t *testing.T) { test := framework.NewClusterE2ETest( t, @@ -4502,6 +4503,20 @@ func TestVSphereKubernetes129UbuntuAirgappedRegistryMirror(t *testing.T) { runAirgapConfigFlow(test, "195.18.0.1/16,196.18.0.1/16") } +func TestVSphereKubernetes129UbuntuAirgappedProxy(t *testing.T) { + test := framework.NewClusterE2ETest( + t, + framework.NewVSphere(t, framework.WithUbuntu129(), framework.WithPrivateNetwork()), + framework.WithClusterFiller(api.WithControlPlaneCount(1)), + framework.WithClusterFiller(api.WithWorkerNodeCount(1)), + framework.WithClusterFiller(api.WithExternalEtcdTopology(1)), + framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube129)), + framework.WithProxy(framework.VsphereProxyRequiredEnvVars), + ) + + runAirgapConfigProxyFlow(test, "195.18.0.1/16,196.18.0.1/16") +} + func TestVSphereKubernetesUbuntu128EtcdEncryption(t *testing.T) { test := framework.NewClusterE2ETest( t,