Skip to content

Commit

Permalink
test integration with CAPI cluster-autoscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrancis committed Jun 22, 2023
1 parent f49938a commit d40b1b2
Show file tree
Hide file tree
Showing 24 changed files with 364 additions and 11 deletions.
3 changes: 3 additions & 0 deletions templates/cluster-template-azure-bastion.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/cluster-template-azure-cni-v1.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/cluster-template-edgezone.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/cluster-template-ephemeral.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/cluster-template-private.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/cluster-template-windows.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ spec:
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
annotations:
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "5"
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "1"
name: ${CLUSTER_NAME}-md-0
namespace: default
spec:
Expand Down
3 changes: 3 additions & 0 deletions templates/flavors/default/machine-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: "${CLUSTER_NAME}-md-0"
annotations:
"cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size": "1"
"cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size": "5"
spec:
clusterName: "${CLUSTER_NAME}"
replicas: ${WORKER_MACHINE_COUNT}
Expand Down
3 changes: 3 additions & 0 deletions templates/test/ci/cluster-template-prow-azure-cni-v1.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/test/ci/cluster-template-prow-ci-version.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/test/ci/cluster-template-prow-custom-vnet.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/test/ci/cluster-template-prow-edgezone.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/test/ci/cluster-template-prow-private.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/test/ci/cluster-template-prow.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions templates/test/dev/cluster-template-custom-builds.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/e2e/azure_csidriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func AzureDiskCSISpec(ctx context.Context, inputGetter func() AzureDiskCSISpecIn

By("creating a deployment that uses pvc")
deploymentName := "stateful" + util.RandomString(6)
statefulDeployment := deploymentBuilder.Create("nginx", deploymentName, corev1.NamespaceDefault).AddPVC(pvcName)
statefulDeployment := deploymentBuilder.Create("nginx", deploymentName, corev1.NamespaceDefault, int32(1)).AddPVC(pvcName)
deployment, err := statefulDeployment.Deploy(ctx, clientset)
Expect(err).NotTo(HaveOccurred())
waitForDeploymentAvailable(ctx, deployment, clientset, specName)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/azure_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func AzureLBSpec(ctx context.Context, inputGetter func() AzureLBSpecInput) {
deploymentName = "web-windows" + util.RandomString(6)
}

webDeployment := deploymentBuilder.Create("httpd", deploymentName, corev1.NamespaceDefault)
webDeployment := deploymentBuilder.Create("httpd", deploymentName, corev1.NamespaceDefault, int32(1))
webDeployment.AddContainerPort("http", "http", 80, corev1.ProtocolTCP)

if input.Windows {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/azure_machinepool_drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func deployHTTPService(ctx context.Context, clientset *kubernetes.Clientset, isW

return "web" + util.RandomString(6)
}()
webDeploymentBuilder = deployments.Create("httpd", deploymentName, corev1.NamespaceDefault)
webDeploymentBuilder = deployments.Create("httpd", deploymentName, corev1.NamespaceDefault, int32(1))
servicesClient = clientset.CoreV1().Services(corev1.NamespaceDefault)
ports = []corev1.ServicePort{
{
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/azure_net_pol.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ func AzureNetPolSpec(ctx context.Context, inputGetter func() AzureNetPolSpecInpu
// Front end Prod
frontendProdDeploymentName := fmt.Sprintf("frontend-prod-%v", randInt)
Log("starting to create frontend-prod deployments")
frontEndProd := deploymentBuilder.Create("library/nginx:1.21.1", frontendProdDeploymentName, namespaceProd.GetName())
frontEndProd := deploymentBuilder.Create("library/nginx:1.21.1", frontendProdDeploymentName, namespaceProd.GetName(), int32(1))
frontEndProd.AddLabels(frontendLabels)
frontendProdDeployment, err := frontEndProd.Deploy(ctx, clientset)
Expect(err).NotTo(HaveOccurred())

// Front end Dev
frontendDevDeploymentName := fmt.Sprintf("frontend-dev-%v", randInt+100000)
Log("starting to create frontend-dev deployments")
frontEndDev := deploymentBuilder.Create("library/nginx:1.21.1", frontendDevDeploymentName, namespaceDev.GetName())
frontEndDev := deploymentBuilder.Create("library/nginx:1.21.1", frontendDevDeploymentName, namespaceDev.GetName(), int32(1))
frontEndDev.AddLabels(frontendLabels)
frontendDevDeployment, err := frontEndDev.Deploy(ctx, clientset)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -113,7 +113,7 @@ func AzureNetPolSpec(ctx context.Context, inputGetter func() AzureNetPolSpecInpu
backendDeploymentName := fmt.Sprintf("backend-%v", randInt+200000)
backendLabels := map[string]string{"app": "webapp", "role": "backend"}
Log("starting to create backend deployments")
backendDev := deploymentBuilder.Create("library/nginx:1.21.1", backendDeploymentName, namespaceDev.GetName())
backendDev := deploymentBuilder.Create("library/nginx:1.21.1", backendDeploymentName, namespaceDev.GetName(), int32(1))
backendDev.AddLabels(backendLabels)
backendDeployment, err := backendDev.Deploy(ctx, clientset)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -122,7 +122,7 @@ func AzureNetPolSpec(ctx context.Context, inputGetter func() AzureNetPolSpecInpu
nwpolicyDeploymentName := fmt.Sprintf("network-policy-%v", randInt+300000)
nwpolicyLabels := map[string]string{"app": "webapp", "role": "any"}
Log("starting to create network-policy deployments")
nwpolicy := deploymentBuilder.Create("library/nginx:1.21.1", nwpolicyDeploymentName, namespaceDev.GetName())
nwpolicy := deploymentBuilder.Create("library/nginx:1.21.1", nwpolicyDeploymentName, namespaceDev.GetName(), int32(1))
nwpolicy.AddLabels(nwpolicyLabels)
nwpolicyDeployment, err := nwpolicy.Deploy(ctx, clientset)
Expect(err).NotTo(HaveOccurred())
Expand Down
82 changes: 81 additions & 1 deletion test/e2e/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

Expand Down Expand Up @@ -232,9 +239,26 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

By("Scaling out via cluster-autoscaler", func() {
AzureAutoscalerSpec(ctx, func() AzureAutoscalerSpecInput {
return AzureAutoscalerSpecInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
})

By("Verifying expected VM extensions are present on the node", func() {
AzureVMExtensionsSpec(ctx, func() AzureVMExtensionsSpecInput {
return AzureVMExtensionsSpecInput{
Expand Down Expand Up @@ -294,7 +318,7 @@ var _ = Describe("Workload cluster creation", func() {
})
})

When("Creating a highly available cluster with Azure CNI v1 [REQUIRED]", Label("Azure CNI v1"), func() {
When("Creating a cluster with Azure CNI v1 [REQUIRED]", Label("Azure CNI v1"), func() {
It("can create 3 control-plane nodes and 2 Linux worker nodes", func() {
clusterName = getClusterName(clusterNamePrefix, "azcni-v1")

Expand Down Expand Up @@ -377,6 +401,13 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

Expand Down Expand Up @@ -415,6 +446,13 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

Expand Down Expand Up @@ -475,6 +513,13 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

Expand Down Expand Up @@ -561,6 +606,13 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

Expand Down Expand Up @@ -669,6 +721,13 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

Expand Down Expand Up @@ -847,6 +906,13 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

Expand Down Expand Up @@ -921,6 +987,13 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

Expand Down Expand Up @@ -965,6 +1038,13 @@ var _ = Describe("Workload cluster creation", func() {
ClusterName: clusterName,
}
})
InstallClusterAutoscaler(ctx, func() ClusterAutoscalerInstallInput {
return ClusterAutoscalerInstallInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

Expand Down
Loading

0 comments on commit d40b1b2

Please sign in to comment.