Skip to content

Commit 662cf0a

Browse files
authored
Merge pull request #1878 from k8s-infra-cherrypick-robot/cherry-pick-1810-to-release-1.0
[release-1.0] v1alpha4 -> v1beta1 clusterctl upgrade test
2 parents 148a8fa + 1c0dcc8 commit 662cf0a

File tree

8 files changed

+2862
-35
lines changed

8 files changed

+2862
-35
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test/e2e/logs/*
6464
_artifacts
6565

6666
# E2E test templates
67-
test/e2e/data/infrastructure-azure/v1alpha4/cluster-template*.yaml
67+
test/e2e/data/infrastructure-azure/v1beta1/cluster-template*.yaml
6868

6969
# boilerplate_test output
7070
hack/boilerplate/__pycache__

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ require (
4343
k8s.io/klog/v2 v2.9.0
4444
k8s.io/kubectl v0.22.2
4545
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b
46-
sigs.k8s.io/cluster-api v1.0.0
47-
sigs.k8s.io/cluster-api/test v1.0.0
48-
sigs.k8s.io/controller-runtime v0.10.2
46+
sigs.k8s.io/cluster-api v1.0.1
47+
sigs.k8s.io/cluster-api/test v1.0.1
48+
sigs.k8s.io/controller-runtime v0.10.3
4949
sigs.k8s.io/kind v0.11.1
5050
sigs.k8s.io/yaml v1.3.0
5151
)
5252

53-
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.0.0
53+
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.0.1

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,12 +1617,12 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
16171617
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
16181618
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
16191619
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
1620-
sigs.k8s.io/cluster-api v1.0.0 h1:GcVA2ObQTXo/+jzSLWPy4Bd3NeiwJyAB8n19kyJIotA=
1621-
sigs.k8s.io/cluster-api v1.0.0/go.mod h1:V230kMSaYENTUcx1QRkoRCklb3vfphQGV3/z4ODNGWo=
1622-
sigs.k8s.io/cluster-api/test v1.0.0 h1:PeWOLXtDGYMmzXwGX+NtH7Xxx6BtS83DT7vKzITY5X0=
1623-
sigs.k8s.io/cluster-api/test v1.0.0/go.mod h1:8WQozDv62x2qHkCB1wTUeFjuwawuHKUTh8IMH5hePQs=
1624-
sigs.k8s.io/controller-runtime v0.10.2 h1:jW8qiY+yMnnPx6O9hu63tgcwaKzd1yLYui+mpvClOOc=
1625-
sigs.k8s.io/controller-runtime v0.10.2/go.mod h1:CQp8eyUQZ/Q7PJvnIrB6/hgfTC1kBkGylwsLgOQi1WY=
1620+
sigs.k8s.io/cluster-api v1.0.1 h1:0YXQoemI4WnZF8RzT9T2vCtnXAi22rD4Fx1Tj2hhCEM=
1621+
sigs.k8s.io/cluster-api v1.0.1/go.mod h1:/LkJXtsvhxTV4U0z1Y2Y1Gr2xebJ0/ce09Ab2M0XU/U=
1622+
sigs.k8s.io/cluster-api/test v1.0.1 h1:bqyRhJ/Nc2Go+A7tl15QkCfNVyNOEPsTgJgZOiUwoJs=
1623+
sigs.k8s.io/cluster-api/test v1.0.1/go.mod h1:D8eLfLrzKcPbm/TzYexoRJISaDleOGSpBrBvH0yVEuA=
1624+
sigs.k8s.io/controller-runtime v0.10.3 h1:s5Ttmw/B4AuIbwrXD3sfBkXwnPMMWrqpVj4WRt1dano=
1625+
sigs.k8s.io/controller-runtime v0.10.3/go.mod h1:CQp8eyUQZ/Q7PJvnIrB6/hgfTC1kBkGylwsLgOQi1WY=
16261626
sigs.k8s.io/kind v0.11.1 h1:pVzOkhUwMBrCB0Q/WllQDO3v14Y+o2V0tFgjTqIUjwA=
16271627
sigs.k8s.io/kind v0.11.1/go.mod h1:fRpgVhtqAWrtLB9ED7zQahUimpUXuG/iHT88xYqEGIA=
16281628
sigs.k8s.io/kustomize/api v0.8.11/go.mod h1:a77Ls36JdfCWojpUqR6m60pdGY1AYFix4AH83nJtY1g=

test/e2e/capi_test.go

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
e2e_namespace "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/namespace"
3131
clusterctl "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
3232
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
33+
"sigs.k8s.io/cluster-api/test/framework"
3334
"sigs.k8s.io/cluster-api/util"
3435
)
3536

@@ -230,32 +231,83 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
230231
})
231232

232233
if os.Getenv("LOCAL_ONLY") != "true" {
233-
Context("upgrade from v1alpha3 to v1beta1, and scale workload clusters created in v1alpha3", func() {
234-
BeforeEach(func() {
235-
// Unset resource group and vnet env variables, since we capi test creates 2 clusters,
236-
// and will result in both the clusters using the same vnet and resource group.
237-
Expect(os.Unsetenv(AzureResourceGroup)).To(Succeed())
238-
Expect(os.Unsetenv(AzureVNetName)).To(Succeed())
239-
240-
// Set base64 encoded values for v1alpha3 cluster.
241-
Expect(os.Setenv("AZURE_CLIENT_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv(AzureClientId))))).To(Succeed())
242-
Expect(os.Setenv("AZURE_CLIENT_SECRET_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv(AzureClientSecret))))).To(Succeed())
243-
Expect(os.Setenv("AZURE_SUBSCRIPTION_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv("AZURE_SUBSCRIPTION_ID"))))).To(Succeed())
244-
Expect(os.Setenv("AZURE_TENANT_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv("AZURE_TENANT_ID"))))).To(Succeed())
245-
246-
// Unset windows specific variables
247-
Expect(os.Unsetenv("WINDOWS_WORKER_MACHINE_COUNT")).To(Succeed())
248-
Expect(os.Unsetenv("K8S_FEATURE_GATES")).To(Succeed())
234+
Context("API Version Upgrade", func() {
235+
Context("upgrade from v1alpha3 to v1beta1, and scale workload clusters created in v1alpha3 ", func() {
236+
BeforeEach(func() {
237+
// Unset resource group and vnet env variables, since we capi test creates 2 clusters,
238+
// and will result in both the clusters using the same vnet and resource group.
239+
Expect(os.Unsetenv(AzureResourceGroup)).To(Succeed())
240+
Expect(os.Unsetenv(AzureVNetName)).To(Succeed())
241+
242+
// Set base64 encoded values for v1alpha3 cluster.
243+
Expect(os.Setenv("AZURE_CLIENT_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv(AzureClientId))))).To(Succeed())
244+
Expect(os.Setenv("AZURE_CLIENT_SECRET_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv(AzureClientSecret))))).To(Succeed())
245+
Expect(os.Setenv("AZURE_SUBSCRIPTION_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv("AZURE_SUBSCRIPTION_ID"))))).To(Succeed())
246+
Expect(os.Setenv("AZURE_TENANT_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv("AZURE_TENANT_ID"))))).To(Succeed())
247+
248+
// Unset windows specific variables
249+
Expect(os.Unsetenv("WINDOWS_WORKER_MACHINE_COUNT")).To(Succeed())
250+
Expect(os.Unsetenv("K8S_FEATURE_GATES")).To(Succeed())
251+
})
252+
capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
253+
return capi_e2e.ClusterctlUpgradeSpecInput{
254+
E2EConfig: e2eConfig,
255+
ClusterctlConfigPath: clusterctlConfigPath,
256+
BootstrapClusterProxy: bootstrapClusterProxy,
257+
ArtifactFolder: artifactFolder,
258+
SkipCleanup: skipCleanup,
259+
}
260+
})
249261
})
250-
capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
251-
return capi_e2e.ClusterctlUpgradeSpecInput{
252-
E2EConfig: e2eConfig,
253-
ClusterctlConfigPath: clusterctlConfigPath,
254-
BootstrapClusterProxy: bootstrapClusterProxy,
255-
ArtifactFolder: artifactFolder,
256-
SkipCleanup: skipCleanup,
257-
}
262+
263+
Context("upgrade from v1alpha4 to v1beta1, and scale workload clusters created in v1alpha4", func() {
264+
BeforeEach(func() {
265+
// Unset resource group and vnet env variables, since we capi test creates 2 clusters,
266+
// and will result in both the clusters using the same vnet and resource group.
267+
Expect(os.Unsetenv(AzureResourceGroup)).To(Succeed())
268+
Expect(os.Unsetenv(AzureVNetName)).To(Succeed())
269+
270+
// Unset windows specific variables
271+
Expect(os.Unsetenv("WINDOWS_WORKER_MACHINE_COUNT")).To(Succeed())
272+
Expect(os.Unsetenv("K8S_FEATURE_GATES")).To(Succeed())
273+
})
274+
capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
275+
return capi_e2e.ClusterctlUpgradeSpecInput{
276+
E2EConfig: e2eConfig,
277+
ClusterctlConfigPath: clusterctlConfigPath,
278+
BootstrapClusterProxy: bootstrapClusterProxy,
279+
ArtifactFolder: artifactFolder,
280+
SkipCleanup: skipCleanup,
281+
InitWithProvidersContract: "v1alpha4",
282+
InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/clusterctl-{OS}-{ARCH}",
283+
PreInit: getPreInitFunc(ctx),
284+
}
285+
})
258286
})
259287
})
260288
}
261289
})
290+
291+
func getPreInitFunc(ctx context.Context) func(proxy framework.ClusterProxy) {
292+
return func(clusterProxy framework.ClusterProxy) {
293+
spClientSecret := os.Getenv(AzureClientSecret)
294+
secret := &corev1.Secret{
295+
ObjectMeta: metav1.ObjectMeta{
296+
Name: IdentitySecretName,
297+
Namespace: "default",
298+
Labels: map[string]string{
299+
clusterctl.ClusterctlMoveHierarchyLabelName: "true",
300+
},
301+
},
302+
Type: corev1.SecretTypeOpaque,
303+
Data: map[string][]byte{"clientSecret": []byte(spClientSecret)},
304+
}
305+
err := clusterProxy.GetClient().Create(ctx, secret)
306+
Expect(err).ToNot(HaveOccurred())
307+
308+
identityName := e2eConfig.GetVariable(ClusterIdentityName)
309+
Expect(os.Setenv(ClusterIdentityName, identityName)).NotTo(HaveOccurred())
310+
Expect(os.Setenv(ClusterIdentitySecretName, IdentitySecretName)).NotTo(HaveOccurred())
311+
Expect(os.Setenv(ClusterIdentitySecretNamespace, "default")).NotTo(HaveOccurred())
312+
}
313+
}

test/e2e/config/azure-dev.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ providers:
1717
replacements:
1818
- old: "imagePullPolicy: Always"
1919
new: "imagePullPolicy: IfNotPresent"
20+
- name: v0.4.4 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
21+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/core-components.yaml"
22+
type: "url"
23+
contract: v1alpha4
24+
replacements:
25+
- old: --metrics-addr=127.0.0.1:8080
26+
new: --metrics-addr=:8080
27+
files:
28+
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
2029
- name: v1.0.0
2130
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/core-components.yaml
2231
type: url
@@ -39,6 +48,15 @@ providers:
3948
replacements:
4049
- old: "imagePullPolicy: Always"
4150
new: "imagePullPolicy: IfNotPresent"
51+
- name: v0.4.4 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
52+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/bootstrap-components.yaml"
53+
type: "url"
54+
contract: v1alpha4
55+
replacements:
56+
- old: --metrics-addr=127.0.0.1:8080
57+
new: --metrics-addr=:8080
58+
files:
59+
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
4260
- name: v1.0.0
4361
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/bootstrap-components.yaml
4462
type: url
@@ -60,6 +78,15 @@ providers:
6078
replacements:
6179
- old: "imagePullPolicy: Always"
6280
new: "imagePullPolicy: IfNotPresent"
81+
- name: v0.4.4 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
82+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/control-plane-components.yaml"
83+
type: "url"
84+
contract: v1alpha4
85+
replacements:
86+
- old: --metrics-addr=127.0.0.1:8080
87+
new: --metrics-addr=:8080
88+
files:
89+
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
6390
- name: v1.0.0
6491
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/control-plane-components.yaml
6592
type: url
@@ -83,6 +110,17 @@ providers:
83110
replacements:
84111
- old: "imagePullPolicy: Always"
85112
new: "imagePullPolicy: IfNotPresent"
113+
- name: v0.5.3 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
114+
value: https://github.com/kubernetes-sigs/cluster-api-provider-azure/releases/download/v0.5.3/infrastructure-components.yaml
115+
type: url
116+
contract: v1alpha4
117+
files:
118+
- sourcePath: "../data/shared/v1alpha4_provider/metadata.yaml"
119+
- sourcePath: "../data/infrastructure-azure/v1alpha4/cluster-template-prow.yaml"
120+
targetName: "cluster-template.yaml"
121+
replacements:
122+
- old: "imagePullPolicy: Always"
123+
new: "imagePullPolicy: IfNotPresent"
86124
- name: v1.0.99 # next; use manifest from source files
87125
value: "${PWD}/config/default"
88126
files:

0 commit comments

Comments
 (0)