Skip to content

Commit

Permalink
Fix create cluster template
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Sep 27, 2023
1 parent 13c3201 commit aeae5ec
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 99 deletions.
4 changes: 2 additions & 2 deletions api/v1beta1/azuremanagedcontrolplane_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ func TestAzureManagedControlPlane_ValidateCreate(t *testing.T) {
name: "invalid DNSServiceIP",
amcp: createAzureManagedControlPlane("192.168.0.10.3", "v1.18.0", generateSSHPublicKey(true)),
wantErr: true,
errorLen: 1,
errorLen: 2,
},
{
name: "invalid DNSServiceIP",
Expand All @@ -1091,7 +1091,7 @@ func TestAzureManagedControlPlane_ValidateCreate(t *testing.T) {
name: "invalid sshKey with a simple text and invalid DNSServiceIP",
amcp: createAzureManagedControlPlane("192.168.0.10.3", "v1.18.0", "invalid_sshkey_honk"),
wantErr: true,
errorLen: 2,
errorLen: 3,
},
{
name: "invalid version",
Expand Down
203 changes: 106 additions & 97 deletions test/e2e/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,121 +846,130 @@ var _ = Describe("Workload cluster creation", func() {
// use ci-default as the clusterclass name so test infra can find the clusterclass template
os.Setenv("CLUSTER_CLASS_NAME", "ci-default")

It("with a single control plane node and 1 node", func() {
clusterName = getClusterName(clusterNamePrefix, aksClusterNameSuffix)
kubernetesVersionUpgradeFrom, err := GetAKSKubernetesVersion(ctx, e2eConfig, AKSKubernetesVersionUpgradeFrom)
Expect(err).To(BeNil())
kubernetesVersion, err := GetAKSKubernetesVersion(ctx, e2eConfig, AKSKubernetesVersion)
Expect(err).To(BeNil())

clusterctl.ApplyClusterTemplateAndWait(ctx, createApplyClusterTemplateInput(
specName,
withFlavor("aks-clusterclass"),
withNamespace(namespace.Name),
withClusterName(clusterName),
withKubernetesVersion(kubernetesVersionUpgradeFrom),
withControlPlaneMachineCount(1),
withWorkerMachineCount(1),
withMachineDeploymentInterval(specName, ""),
withMachinePoolInterval(specName, "wait-worker-nodes"),
withControlPlaneWaiters(clusterctl.ControlPlaneWaiters{
WaitForControlPlaneInitialized: WaitForAKSControlPlaneInitialized,
WaitForControlPlaneMachinesReady: WaitForAKSControlPlaneReady,
}),
), result)

By("Upgrading the Kubernetes version of the cluster", func() {
AKSUpgradeSpec(ctx, func() AKSUpgradeSpecInput {
return AKSUpgradeSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
KubernetesVersionUpgradeTo: kubernetesVersion,
WaitForControlPlane: e2eConfig.GetIntervals(specName, "wait-machine-upgrade"),
WaitForMachinePools: e2eConfig.GetIntervals(specName, "wait-machine-pool-upgrade"),
// use "cc" as spec name because natgw pip name exceeds limit.
clusterName = getClusterName(clusterNamePrefix, "cc")
kubernetesVersionUpgradeFrom, err := GetAKSKubernetesVersion(ctx, e2eConfig, AKSKubernetesVersionUpgradeFrom)
Expect(err).To(BeNil())
kubernetesVersion, err := GetAKSKubernetesVersion(ctx, e2eConfig, AKSKubernetesVersion)
Expect(err).To(BeNil())

// Opt into using windows with prow template
Expect(os.Setenv("WINDOWS_WORKER_MACHINE_COUNT", "1")).To(Succeed())

// Create a cluster using the cluster class created above
clusterctl.ApplyClusterTemplateAndWait(ctx, createApplyClusterTemplateInput(
specName,
withFlavor("aks-clusterclass"),
withNamespace(namespace.Name),
withClusterName(clusterName),
withKubernetesVersion(kubernetesVersionUpgradeFrom),
withControlPlaneMachineCount(1),
withWorkerMachineCount(1),
withControlPlaneWaiters(clusterctl.ControlPlaneWaiters{
WaitForControlPlaneInitialized: EnsureControlPlaneInitialized,
}),
withPostMachinesProvisioned(func() {
EnsureDaemonsets(ctx, func() DaemonsetsSpecInput {
return DaemonsetsSpecInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
}
})
}),
), result)

By("Upgrading the Kubernetes version of the cluster", func() {
AKSUpgradeSpec(ctx, func() AKSUpgradeSpecInput {
return AKSUpgradeSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
KubernetesVersionUpgradeTo: kubernetesVersion,
WaitForControlPlane: e2eConfig.GetIntervals(specName, "wait-machine-upgrade"),
WaitForMachinePools: e2eConfig.GetIntervals(specName, "wait-machine-pool-upgrade"),
}
})
})

By("Exercising machine pools", func() {
AKSMachinePoolSpec(ctx, func() AKSMachinePoolSpecInput {
return AKSMachinePoolSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
By("Exercising machine pools", func() {
AKSMachinePoolSpec(ctx, func() AKSMachinePoolSpecInput {
return AKSMachinePoolSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
})

By("creating a machine pool with public IP addresses from a prefix", func() {
// This test is also currently serving as the canonical
// "create/delete node pool" test. Eventually, that should be
// made more distinct from this public IP prefix test.
AKSPublicIPPrefixSpec(ctx, func() AKSPublicIPPrefixSpecInput {
return AKSPublicIPPrefixSpecInput{
Cluster: result.Cluster,
KubernetesVersion: kubernetesVersion,
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
}
})
By("creating a machine pool with public IP addresses from a prefix", func() {
// This test is also currently serving as the canonical
// "create/delete node pool" test. Eventually, that should be
// made more distinct from this public IP prefix test.
AKSPublicIPPrefixSpec(ctx, func() AKSPublicIPPrefixSpecInput {
return AKSPublicIPPrefixSpecInput{
Cluster: result.Cluster,
KubernetesVersion: kubernetesVersion,
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
}
})
})

By("creating a machine pool with spot max price and scale down mode", func() {
AKSSpotSpec(ctx, func() AKSSpotSpecInput {
return AKSSpotSpecInput{
Cluster: result.Cluster,
KubernetesVersion: kubernetesVersion,
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
}
})
By("creating a machine pool with spot max price and scale down mode", func() {
AKSSpotSpec(ctx, func() AKSSpotSpecInput {
return AKSSpotSpecInput{
Cluster: result.Cluster,
KubernetesVersion: kubernetesVersion,
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
}
})
})

By("modifying nodepool autoscaling configuration", func() {
AKSAutoscaleSpec(ctx, func() AKSAutoscaleSpecInput {
return AKSAutoscaleSpecInput{
Cluster: result.Cluster,
MachinePool: result.MachinePools[0],
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
By("modifying nodepool autoscaling configuration", func() {
AKSAutoscaleSpec(ctx, func() AKSAutoscaleSpecInput {
return AKSAutoscaleSpecInput{
Cluster: result.Cluster,
MachinePool: result.MachinePools[0],
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
})

By("modifying additionalTags configuration", func() {
AKSAdditionalTagsSpec(ctx, func() AKSAdditionalTagsSpecInput {
return AKSAdditionalTagsSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
WaitForUpdate: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
By("modifying additionalTags configuration", func() {
AKSAdditionalTagsSpec(ctx, func() AKSAdditionalTagsSpecInput {
return AKSAdditionalTagsSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
WaitForUpdate: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
})

By("modifying the azure cluster-autoscaler settings", func() {
AKSAzureClusterAutoscalerSettingsSpec(ctx, func() AKSAzureClusterAutoscalerSettingsSpecInput {
return AKSAzureClusterAutoscalerSettingsSpecInput{
Cluster: result.Cluster,
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
}
})
By("modifying the azure cluster-autoscaler settings", func() {
AKSAzureClusterAutoscalerSettingsSpec(ctx, func() AKSAzureClusterAutoscalerSettingsSpecInput {
return AKSAzureClusterAutoscalerSettingsSpecInput{
Cluster: result.Cluster,
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
}
})
})

By("modifying node labels configuration", func() {
AKSNodeLabelsSpec(ctx, func() AKSNodeLabelsSpecInput {
return AKSNodeLabelsSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
WaitForUpdate: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
By("modifying node labels configuration", func() {
AKSNodeLabelsSpec(ctx, func() AKSNodeLabelsSpecInput {
return AKSNodeLabelsSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
WaitForUpdate: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
})

By("modifying taints configuration", func() {
AKSNodeTaintsSpec(ctx, func() AKSNodeTaintsSpecInput {
return AKSNodeTaintsSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
WaitForUpdate: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
By("modifying taints configuration", func() {
AKSNodeTaintsSpec(ctx, func() AKSNodeTaintsSpecInput {
return AKSNodeTaintsSpecInput{
Cluster: result.Cluster,
MachinePools: result.MachinePools,
WaitForUpdate: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
}
})
})
})
Expand Down

0 comments on commit aeae5ec

Please sign in to comment.