Skip to content

Commit 7809bc5

Browse files
committed
azure: Add e2e testing
1 parent 6ac7fcc commit 7809bc5

File tree

8 files changed

+60
-3
lines changed

8 files changed

+60
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ UPLOAD_CMD=$(KOPS_ROOT)/hack/upload ${UPLOAD_ARGS}
5050
unexport AWS_ACCESS_KEY_ID AWS_REGION AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN CNI_VERSION_URL DNS_IGNORE_NS_CHECK DNSCONTROLLER_IMAGE DO_ACCESS_TOKEN GOOGLE_APPLICATION_CREDENTIALS
5151
unexport KOPS_BASE_URL KOPS_CLUSTER_NAME KOPS_RUN_OBSOLETE_VERSION KOPS_STATE_STORE KOPS_STATE_S3_ACL KUBE_API_VERSIONS NODEUP_URL OPENSTACK_CREDENTIAL_FILE SKIP_PACKAGE_UPDATE
5252
unexport SKIP_REGION_CHECK S3_ACCESS_KEY_ID S3_ENDPOINT S3_REGION S3_SECRET_ACCESS_KEY HCLOUD_TOKEN SCW_ACCESS_KEY SCW_SECRET_KEY SCW_DEFAULT_PROJECT_ID SCW_PROFILE
53-
unexport AZURE_CLIENT_ID AZURE_CLIENT_SECRET AZURE_STORAGE_ACCOUNT AZURE_SUBSCRIPTION_ID AZURE_TENANT_ID
53+
#unexport AZURE_CLIENT_ID AZURE_CLIENT_SECRET AZURE_STORAGE_ACCOUNT AZURE_SUBSCRIPTION_ID AZURE_TENANT_ID
5454

5555

5656
VERSION=$(shell tools/get_version.sh | grep VERSION | awk '{print $$2}')

pkg/featureflag/featureflag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var (
7474
// ClusterAddons activates experimental cluster-addons support
7575
ClusterAddons = new("ClusterAddons", Bool(false))
7676
// Azure toggles the Azure support.
77-
Azure = new("Azure", Bool(false))
77+
Azure = new("Azure", Bool(true))
7878
// APIServerNodes enables ability to provision nodes that only run the kube-apiserver.
7979
APIServerNodes = new("APIServerNodes", Bool(false))
8080
// UseAddonOperators activates experimental addon operator support

tests/e2e/e2e.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ GOARCH ?= $(shell go env GOARCH)
1717

1818
.PHONY: test-e2e-install
1919
test-e2e-install:
20+
env
2021
cd $(KOPS_ROOT)/tests/e2e && \
2122
go install ./kubetest2-tester-kops && \
2223
go install ./kubetest2-kops
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package azure
18+
19+
import (
20+
"math/rand"
21+
)
22+
23+
var allZones = []string{
24+
"uksouth-1",
25+
}
26+
27+
// RandomZones returns a random set of availability zones within a region
28+
func RandomZones(count int) ([]string, error) {
29+
n := rand.Intn(1000) % len(allZones)
30+
chosenZone := allZones[n]
31+
32+
chosenZones := make([]string, 0)
33+
chosenZones = append(chosenZones, chosenZone)
34+
35+
return chosenZones, nil
36+
}

tests/e2e/kubetest2-kops/deployer/common.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ func (d *deployer) initialize() error {
7373
d.SSHPublicKeyPath = publicKeyPath
7474
d.SSHPrivateKeyPath = privateKeyPath
7575
}
76+
case "azure":
77+
publicKeyPath, privateKeyPath, err := util.CreateSSHKeyPair(d.ClusterName)
78+
if err != nil {
79+
return err
80+
}
81+
d.SSHPublicKeyPath = publicKeyPath
82+
d.SSHPrivateKeyPath = privateKeyPath
83+
d.SSHUser = "ubuntu"
7684
case "digitalocean":
7785
if d.SSHPrivateKeyPath == "" {
7886
d.SSHPrivateKeyPath = os.Getenv("DO_SSH_PRIVATE_KEY_FILE")
@@ -180,6 +188,7 @@ func (d *deployer) verifyKopsFlags() error {
180188

181189
switch d.CloudProvider {
182190
case "aws":
191+
case "azure":
183192
case "gce":
184193
case "digitalocean":
185194
default:
@@ -339,6 +348,8 @@ func (d *deployer) stateStore() string {
339348
}
340349
d.createBucket = true
341350
ss = "s3://" + bucketName
351+
case "azure":
352+
ss = "azureblob://cluster-state"
342353
case "gce":
343354
d.createBucket = true
344355
ss = "gs://" + gce.GCSBucketName(d.GCPProject, "state")

tests/e2e/kubetest2-kops/deployer/deployer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ type deployer struct {
6262
// ControlPlaneCount specifies the number of VMs in the control-plane.
6363
ControlPlaneCount int `flag:"control-plane-count" desc:"Number of control-plane instances"`
6464

65+
AzureSubscriptionID string `flag:"azure-subscription-id" desc:"DELETEME"`
66+
6567
ControlPlaneIGOverrides []string `flag:"control-plane-instance-group-overrides" desc:"overrides for the control plane instance groups"`
6668
NodeIGOverrides []string `flag:"node-instance-group-overrides" desc:"overrides for the node instance groups"`
6769

tests/e2e/kubetest2-kops/deployer/up.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131

3232
"k8s.io/klog/v2"
3333
"k8s.io/kops/tests/e2e/kubetest2-kops/aws"
34+
"k8s.io/kops/tests/e2e/kubetest2-kops/azure"
3435
"k8s.io/kops/tests/e2e/kubetest2-kops/do"
3536
"k8s.io/kops/tests/e2e/kubetest2-kops/gce"
3637
"k8s.io/kops/tests/e2e/pkg/kops"
@@ -190,6 +191,10 @@ func (d *deployer) createCluster(zones []string, adminAccess string, yes bool) e
190191
} else {
191192
args = appendIfUnset(args, "--master-size", "c5.large")
192193
}
194+
case "azure":
195+
args = appendIfUnset(args, "--master-size", "Standard_D4s_v3")
196+
args = appendIfUnset(args, "--node-size", "Standard_D4s_v3")
197+
args = appendIfUnset(args, "--azure-admin-user", "ubuntu")
193198
case "gce":
194199
if isArm {
195200
args = appendIfUnset(args, "--master-size", "t2a-standard-2")
@@ -346,6 +351,8 @@ func (d *deployer) zones() ([]string, error) {
346351
switch d.CloudProvider {
347352
case "aws":
348353
return aws.RandomZones(d.ControlPlaneCount)
354+
case "azure":
355+
return azure.RandomZones(1)
349356
case "gce":
350357
return gce.RandomZones(1)
351358
case "digitalocean":

tests/e2e/pkg/tester/tester.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (t *Tester) addProviderFlag() error {
150150
switch cluster.Spec.LegacyCloudProvider {
151151
case "aws", "gce":
152152
provider = cluster.Spec.LegacyCloudProvider
153-
case "digitalocean":
153+
case "azure", "digitalocean":
154154
default:
155155
klog.Warningf("unhandled cluster.spec.cloudProvider %q for determining ginkgo Provider", cluster.Spec.LegacyCloudProvider)
156156
}

0 commit comments

Comments
 (0)