Skip to content

Commit 12707e1

Browse files
committed
Make integration tests support windows 2022.
1 parent daac2c6 commit 12707e1

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

Makefile

+13-6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ DRIVERWINDOWSBINARY=${DRIVERBINARY}.exe
2424
DOCKER=DOCKER_CLI_EXPERIMENTAL=enabled docker
2525

2626
BASE_IMAGE_LTSC2019=mcr.microsoft.com/windows/servercore:ltsc2019
27+
BASE_IMAGE_LTSC2022=mcr.microsoft.com/windows/servercore:ltsc2022
2728

2829
# Both arrays MUST be index aligned.
2930
WINDOWS_IMAGE_TAGS=ltsc2019
@@ -60,14 +61,20 @@ build-and-push-windows-container-ltsc2019: require-GCE_PD_CSI_STAGING_IMAGE init
6061
--build-arg BASE_IMAGE=$(BASE_IMAGE_LTSC2019) \
6162
--build-arg STAGINGVERSION=$(STAGINGVERSION) --push --provenance=false .
6263

63-
build-and-push-multi-arch: build-and-push-container-linux-amd64 build-and-push-container-linux-arm64 build-and-push-windows-container-ltsc2019
64-
$(DOCKER) manifest create $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux_amd64 $(STAGINGIMAGE):$(STAGINGVERSION)_linux_arm64 $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019
65-
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="$(WINDOWS_IMAGE_TAGS)" WINDOWS_BASE_IMAGES="$(WINDOWS_BASE_IMAGES)" ./manifest_osversion.sh
64+
build-and-push-windows-container-ltsc2022: require-GCE_PD_CSI_STAGING_IMAGE init-buildx
65+
$(DOCKER) buildx build --file=Dockerfile.Windows --platform=windows/amd64 \
66+
-t $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2022 \
67+
--build-arg BASE_IMAGE=$(BASE_IMAGE_LTSC2022) \
68+
--build-arg STAGINGVERSION=$(STAGINGVERSION) --push --provenance=false .
69+
70+
build-and-push-multi-arch: build-and-push-container-linux-amd64 build-and-push-container-linux-arm64 build-and-push-windows-container-ltsc2019 build-and-push-windows-container-ltsc2022
71+
$(DOCKER) manifest create $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux_amd64 $(STAGINGIMAGE):$(STAGINGVERSION)_linux_arm64 $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019 $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2022
72+
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="ltsc2019, ltsc2022" WINDOWS_BASE_IMAGES="$(BASE_IMAGE_LTSC2019), $(BASE_IMAGE_LTSC2022)" ./manifest_osversion.sh
6673
$(DOCKER) manifest push -p $(STAGINGIMAGE):$(STAGINGVERSION)
6774

68-
build-and-push-multi-arch-debug: build-and-push-container-linux-debug build-and-push-windows-container-ltsc2019
69-
$(DOCKER) manifest create $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019
70-
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="ltsc2019" WINDOWS_BASE_IMAGES="$(BASE_IMAGE_LTSC2019)" ./manifest_osversion.sh
75+
build-and-push-multi-arch-debug: build-and-push-container-linux-debug build-and-push-windows-container-ltsc2019 build-and-push-windows-container-ltsc2022
76+
$(DOCKER) manifest create $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019 $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2022
77+
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="ltsc2019, ltsc2022" WINDOWS_BASE_IMAGES="$(BASE_IMAGE_LTSC2019), $(BASE_IMAGE_LTSC2022)" ./manifest_osversion.sh
7178
$(DOCKER) manifest push -p $(STAGINGIMAGE):$(STAGINGVERSION)
7279

7380
push-container: build-container

test/k8s-integration/cluster.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ func setImageTypeEnvs(imageType string) error {
155155
case "cos":
156156
case "cos_containerd":
157157
case "gci": // GCI/COS is default type and does not need env vars set
158+
case "win2019", "win2022":
159+
// These are handled by the WINDOWS_NODE_OS_DISTRIBUTION env var and
160+
// ingested in https://github.com/kubernetes/kubernetes/blob/ded2956c832502da8a0678f5392c24af1cc9dfc0/cluster/gce/util.sh#L112.
158161
case "ubuntu", "ubuntu_containerd":
159162
return errors.New("setting environment vars for bringing up *ubuntu* cluster on GCE is unimplemented")
160163
/* TODO(dyzz) figure out how to bring up a Ubuntu cluster on GCE. The below doesn't work.
@@ -201,7 +204,17 @@ func clusterUpGKE(gceZone, gceRegion string, numNodes int, numWindowsNodes int,
201204
var cmd *exec.Cmd
202205
cmdParams := []string{"container", "clusters", "create", *gkeTestClusterName,
203206
locationArg, locationVal, "--num-nodes", strconv.Itoa(numNodes),
204-
"--quiet", "--machine-type", "n1-standard-2", "--image-type", imageType, "--no-enable-autoupgrade"}
207+
"--quiet", "--machine-type", "n1-standard-2", "--no-enable-autoupgrade"}
208+
if imageType == "win2019" || imageType == "win2022" {
209+
cmdParams = append(cmdParams, "--image-type", "WINDOWS_LTSC_CONTAINERD")
210+
if imageType == "win2019" {
211+
cmdParams = append(cmdParams, "--windows-os-version", "ltsc2019")
212+
} else {
213+
cmdParams = append(cmdParams, "--windows-os-version", "ltsc2022")
214+
}
215+
} else {
216+
cmdParams = append(cmdParams, "--image-type", imageType)
217+
}
205218
if isVariableSet(gkeClusterVer) {
206219
cmdParams = append(cmdParams, "--cluster-version", *gkeClusterVer)
207220
} else {

test/k8s-integration/driver.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func deleteDriver(testParams *testParameters, deployOverlayName string) error {
126126
return nil
127127
}
128128

129-
func pushImage(pkgDir, stagingImage, stagingVersion, platform string) error {
129+
func pushImage(pkgDir, stagingImage, stagingVersion, platform, imageType string) error {
130130
err := os.Setenv("GCE_PD_CSI_STAGING_VERSION", stagingVersion)
131131
if err != nil {
132132
return err
@@ -138,7 +138,6 @@ func pushImage(pkgDir, stagingImage, stagingVersion, platform string) error {
138138
var cmd *exec.Cmd
139139

140140
if platform == "windows" {
141-
// build multi-arch image which can work for both Linux and Windows
142141
cmd = exec.Command("make", "-C", pkgDir, "build-and-push-multi-arch",
143142
fmt.Sprintf("GCE_PD_CSI_STAGING_VERSION=%s", stagingVersion),
144143
fmt.Sprintf("GCE_PD_CSI_STAGING_IMAGE=%s", stagingImage))

test/k8s-integration/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func handle() error {
300300
// Build and push the driver, if required. Defer the driver image deletion.
301301
if *doDriverBuild {
302302
klog.Infof("Building GCE PD CSI Driver")
303-
err := pushImage(testParams.pkgDir, *stagingImage, testParams.stagingVersion, testParams.platform)
303+
err := pushImage(testParams.pkgDir, *stagingImage, testParams.stagingVersion, testParams.platform, *imageType)
304304
if err != nil {
305305
return fmt.Errorf("failed pushing image: %v", err.Error())
306306
}

test/run-windows-k8s-integration.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ readonly test_version=${TEST_VERSION:-master}
2121
readonly gce_zone=${GCE_CLUSTER_ZONE:-us-central1-b}
2222
readonly use_kubetest2=${USE_KUBETEST2:-true}
2323
readonly num_windows_nodes=${NUM_WINDOWS_NODES:-3}
24+
readonly windows_distribution=${WINDOWS_NODE_OS_DISTRIBUTION:-win2019}
2425

2526
# build platforms for `make quick-release`
2627
export KUBE_BUILD_PLATFORMS=${KUBE_BUILD_PLATFORMS:-"linux/amd64 windows/amd64"}
@@ -35,6 +36,11 @@ if [ "$use_kubetest2" = true ]; then
3536
go install sigs.k8s.io/kubetest2/kubetest2-tester-ginkgo@${kt2_version}
3637
fi
3738

39+
if [ "$windows_distribution" != "win2019" -a "$windows_distribution" != "win2022"]; then
40+
print "Invalid windows distribution $windows_distribution provided. Exiting."
41+
exit 1
42+
fi
43+
3844
${PKGDIR}/bin/k8s-integration-test \
3945
--run-in-prow=true \
4046
--service-account-file="${E2E_GOOGLE_APPLICATION_CREDENTIALS}" \
@@ -54,4 +60,5 @@ ${PKGDIR}/bin/k8s-integration-test \
5460
--storageclass-files=sc-windows.yaml \
5561
--snapshotclass-files=pd-volumesnapshotclass.yaml \
5662
--test-focus='External.Storage' \
57-
--use-kubetest2="${use_kubetest2}"
63+
--use-kubetest2="${use_kubetest2}" \
64+
--image-type="${windows_distribution}"

0 commit comments

Comments
 (0)