From 4750e82d25e00a7452aa163351cae406bfcc0bed Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Thu, 22 Aug 2024 09:54:28 +0200 Subject: [PATCH] add template for autoscaler --- Makefile | 1 + test/e2e/autoscaler_test.go | 26 ++++++++++--------- test/e2e/config/vsphere.yaml | 1 + .../cluster-autoscaler.yaml | 6 +++++ .../topology-autoscaler/kustomization.yaml | 8 ++++++ 5 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 test/e2e/data/infrastructure-vsphere-supervisor/main/topology-autoscaler/cluster-autoscaler.yaml create mode 100644 test/e2e/data/infrastructure-vsphere-supervisor/main/topology-autoscaler/kustomization.yaml diff --git a/Makefile b/Makefile index 749b3f2524..10836ae3bc 100644 --- a/Makefile +++ b/Makefile @@ -408,6 +408,7 @@ generate-e2e-templates-main: $(KUSTOMIZE) ## Generate test templates for the mai "$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/clusterclass-runtimesdk" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/clusterclass-quick-start-supervisor-runtimesdk.yaml" cp "$(RELEASE_DIR)/main/cluster-template-topology-supervisor.yaml" "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/topology/cluster-template-topology-supervisor.yaml" "$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/topology" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-topology-supervisor.yaml" + "$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/topology-autoscaler" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-topology-autoscaler-supervisor.yaml" "$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/topology-runtimesdk" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-topology-runtimesdk-supervisor.yaml" "$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/conformance" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-conformance-supervisor.yaml" "$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/fast-rollout" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-fast-rollout-supervisor.yaml" diff --git a/test/e2e/autoscaler_test.go b/test/e2e/autoscaler_test.go index 172d85e5fb..192549bd76 100644 --- a/test/e2e/autoscaler_test.go +++ b/test/e2e/autoscaler_test.go @@ -32,20 +32,22 @@ var _ = Describe("When using the autoscaler with Cluster API using ClusterClass // KUBERNETES_VERSION_UPGRADE_TO. const specName = "k8s-upgrade" // aligned to CAPI Setup(specName, func(testSpecificSettingsGetter func() testSettings) { - if testMode == GovmomiTestMode { - // This test is only implemented for supervisor - Skip("This test is only implemented for supervisor") - } - capi_e2e.AutoscalerSpec(ctx, func() capi_e2e.AutoscalerSpecInput { return capi_e2e.AutoscalerSpecInput{ - E2EConfig: e2eConfig, - ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath, - BootstrapClusterProxy: bootstrapClusterProxy, - ArtifactFolder: artifactFolder, - SkipCleanup: skipCleanup, - Flavor: ptr.To(testSpecificSettingsGetter().FlavorForMode("topology")), - PostNamespaceCreated: testSpecificSettingsGetter().PostNamespaceCreatedFunc, + E2EConfig: e2eConfig, + ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath, + BootstrapClusterProxy: bootstrapClusterProxy, + ArtifactFolder: artifactFolder, + SkipCleanup: skipCleanup, + Flavor: ptr.To(testSpecificSettingsGetter().FlavorForMode("topology-autoscaler")), + PostNamespaceCreated: func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string) { + if testMode == GovmomiTestMode { + // This test is only implemented for supervisor + Skip("This test is only implemented for supervisor") + } + + testSpecificSettingsGetter().PostNamespaceCreatedFunc(managementClusterProxy, workloadClusterNamespace) + }, InfrastructureMachineTemplateKind: "vspheremachinetemplates", AutoscalerVersion: "v1.30.0", InstallOnManagementCluster: true, diff --git a/test/e2e/config/vsphere.yaml b/test/e2e/config/vsphere.yaml index 2966c40e24..65d9a64983 100644 --- a/test/e2e/config/vsphere.yaml +++ b/test/e2e/config/vsphere.yaml @@ -156,6 +156,7 @@ providers: - sourcePath: "../../../test/e2e/data/infrastructure-vsphere-govmomi/main/clusterclass-quick-start.yaml" - sourcePath: "../../../test/e2e/data/infrastructure-vsphere-govmomi/main/clusterclass-quick-start-runtimesdk.yaml" - sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/cluster-template-topology-supervisor.yaml" + - sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/cluster-template-topology-autoscaler-supervisor.yaml" - sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/cluster-template-topology-runtimesdk-supervisor.yaml" - sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/cluster-template-supervisor.yaml" - sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/clusterclass-quick-start-supervisor.yaml" diff --git a/test/e2e/data/infrastructure-vsphere-supervisor/main/topology-autoscaler/cluster-autoscaler.yaml b/test/e2e/data/infrastructure-vsphere-supervisor/main/topology-autoscaler/cluster-autoscaler.yaml new file mode 100644 index 0000000000..26d009dde5 --- /dev/null +++ b/test/e2e/data/infrastructure-vsphere-supervisor/main/topology-autoscaler/cluster-autoscaler.yaml @@ -0,0 +1,6 @@ +- op: replace + path: /spec/topology/workers/machineDeployments/0/metadata + value: + annotations: + cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "5" + cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "2" diff --git a/test/e2e/data/infrastructure-vsphere-supervisor/main/topology-autoscaler/kustomization.yaml b/test/e2e/data/infrastructure-vsphere-supervisor/main/topology-autoscaler/kustomization.yaml new file mode 100644 index 0000000000..8efca71355 --- /dev/null +++ b/test/e2e/data/infrastructure-vsphere-supervisor/main/topology-autoscaler/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../topology +patches: + - target: + kind: Cluster + path: ./cluster-autoscaler.yaml