Skip to content

Commit 2f3b558

Browse files
committed
prow.sh: update to kind 0.9, support Kubernetes 1.19
kind 0.9 adds support for recent Kubernetes releases like 1.19 and simplifies configuration of feature gates and runtime config. With Kubernetes 1.19, new feature gates were introduced which might become relevant for the alpha Prow jobs. The updated kind release comes with images for different Kubernetes releases than the one before. To avoid breaking existing jobs, the script now picks kind images automatically. As an additional bonus, it then uses images with hash, i.e. it's less likely to break if those image tags change because of a future kind release.
1 parent 0c34086 commit 2f3b558

File tree

1 file changed

+56
-89
lines changed

1 file changed

+56
-89
lines changed

release-tools/prow.sh

Lines changed: 56 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,6 @@ configvar () {
5252
eval echo "\$3:" "$1=\${$1}"
5353
}
5454

55-
# Takes the minor version of $CSI_PROW_KUBERNETES_VERSION and overrides it to
56-
# $1 if they are equal minor versions. Ignores versions that begin with
57-
# "release-".
58-
override_k8s_version () {
59-
local current_minor_version
60-
local override_minor_version
61-
62-
# Ignore: See if you can use ${variable//search/replace} instead.
63-
# shellcheck disable=SC2001
64-
current_minor_version="$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1\.\2/')"
65-
66-
# Ignore: See if you can use ${variable//search/replace} instead.
67-
# shellcheck disable=SC2001
68-
override_minor_version="$(echo "${1}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1\.\2/')"
69-
if [ "${current_minor_version}" == "${override_minor_version}" ]; then
70-
CSI_PROW_KUBERNETES_VERSION="$1"
71-
echo "Overriding CSI_PROW_KUBERNETES_VERSION with $1: $CSI_PROW_KUBERNETES_VERSION"
72-
fi
73-
}
74-
7555
# Prints the value of a variable + version suffix, falling back to variable + "LATEST".
7656
get_versioned_variable () {
7757
local var="$1"
@@ -107,9 +87,19 @@ configvar CSI_PROW_GO_VERSION_KIND "${CSI_PROW_GO_VERSION_BUILD}" "Go version fo
10787
configvar CSI_PROW_GO_VERSION_GINKGO "${CSI_PROW_GO_VERSION_BUILD}" "Go version for building ginkgo" # depends on CSI_PROW_GINKGO_VERSION below
10888

10989
# kind version to use. If the pre-installed version is different,
110-
# the desired version is downloaded from https://github.com/kubernetes-sigs/kind/releases/download/
90+
# the desired version is downloaded from https://github.com/kubernetes-sigs/kind/releases
11191
# (if available), otherwise it is built from source.
112-
configvar CSI_PROW_KIND_VERSION "v0.6.0" "kind"
92+
configvar CSI_PROW_KIND_VERSION "v0.9.0" "kind"
93+
94+
# kind images to use. Must match the kind version.
95+
# The release notes of each kind release list the supported images.
96+
configvar CSI_PROW_KIND_IMAGES "kindest/node:v1.19.1@sha256:98cf5288864662e37115e362b23e4369c8c4a408f99cbc06e58ac30ddc721600
97+
kindest/node:v1.18.8@sha256:f4bcc97a0ad6e7abaf3f643d890add7efe6ee4ab90baeb374b4f41a4c95567eb
98+
kindest/node:v1.17.11@sha256:5240a7a2c34bf241afb54ac05669f8a46661912eab05705d660971eeb12f6555
99+
kindest/node:v1.16.15@sha256:a89c771f7de234e6547d43695c7ab047809ffc71a0c3b65aa54eda051c45ed20
100+
kindest/node:v1.15.12@sha256:d9b939055c1e852fe3d86955ee24976cab46cba518abcb8b13ba70917e6547a6
101+
kindest/node:v1.14.10@sha256:ce4355398a704fca68006f8a29f37aafb49f8fc2f64ede3ccd0d9198da910146
102+
kindest/node:v1.13.12@sha256:1c1a48c2bfcbae4d5f4fa4310b5ed10756facad0b7a2ca93c7a4b5bae5db29f5" "kind images"
113103

114104
# ginkgo test runner version to use. If the pre-installed version is
115105
# different, the desired version is built from source.
@@ -124,10 +114,13 @@ configvar CSI_PROW_GINKO_PARALLEL "-p" "Ginko parallelism parameter(s)"
124114
configvar CSI_PROW_BUILD_JOB true "building code in repo enabled"
125115

126116
# Kubernetes version to test against. This must be a version number
127-
# (like 1.13.3) for which there is a pre-built kind image (see
128-
# https://hub.docker.com/r/kindest/node/tags), "latest" (builds
129-
# Kubernetes from the master branch) or "release-x.yy" (builds
130-
# Kubernetes from a release branch).
117+
# (like 1.13.3), "latest" (builds Kubernetes from the master branch)
118+
# or "release-x.yy" (builds Kubernetes from a release branch).
119+
#
120+
# The patch version is only relevant for picking the E2E test suite
121+
# that is used for testing. The script automatically picks
122+
# the kind images for the major/minor version of Kubernetes
123+
# that the kind release supports.
131124
#
132125
# This can also be a version that was not released yet at the time
133126
# that the settings below were chose. The script will then
@@ -136,16 +129,6 @@ configvar CSI_PROW_BUILD_JOB true "building code in repo enabled"
136129
# deprecating or changing the implementation of an alpha feature.
137130
configvar CSI_PROW_KUBERNETES_VERSION 1.17.0 "Kubernetes"
138131

139-
# This is a hack to workaround the issue that each version
140-
# of kind currently only supports specific patch versions of
141-
# Kubernetes. We need to override CSI_PROW_KUBERNETES_VERSION
142-
# passed in by our CI/pull jobs to the versions that
143-
# kind v0.5.0 supports.
144-
#
145-
# If the version is prefixed with "release-", then nothing
146-
# is overridden.
147-
override_k8s_version "1.15.3"
148-
149132
# CSI_PROW_KUBERNETES_VERSION reduced to first two version numbers and
150133
# with underscore (1_13 instead of 1.13.3) and in uppercase (LATEST
151134
# instead of latest).
@@ -337,9 +320,10 @@ configvar CSI_PROW_E2E_ALPHA "$(get_versioned_variable CSI_PROW_E2E_ALPHA "${csi
337320
# it anymore for older releases.
338321
configvar CSI_PROW_E2E_ALPHA_GATES_1_15 'VolumeSnapshotDataSource=true,ExpandCSIVolumes=true' "alpha feature gates for Kubernetes 1.15"
339322
configvar CSI_PROW_E2E_ALPHA_GATES_1_16 'VolumeSnapshotDataSource=true' "alpha feature gates for Kubernetes 1.16"
340-
# TODO: add new CSI_PROW_ALPHA_GATES_xxx entry for future Kubernetes releases and
341-
# add new gates to CSI_PROW_E2E_ALPHA_GATES_LATEST.
342-
configvar CSI_PROW_E2E_ALPHA_GATES_LATEST '' "alpha feature gates for latest Kubernetes"
323+
configvar CSI_PROW_E2E_ALPHA_GATES_1_17 '' "alpha feature gates for Kubernetes 1.17"
324+
configvar CSI_PROW_E2E_ALPHA_GATES_1_18 '' "alpha feature gates for Kubernetes 1.18"
325+
configvar CSI_PROW_E2E_ALPHA_GATES_1_19 'GenericEphemeralVolume=true,CSIStorageCapacity=true' "alpha feature gates for Kubernetes 1.19"
326+
configvar CSI_PROW_E2E_ALPHA_GATES_LATEST 'GenericEphemeralVolume=true,CSIStorageCapacity=true' "alpha feature gates for latest Kubernetes"
343327
configvar CSI_PROW_E2E_ALPHA_GATES "$(get_versioned_variable CSI_PROW_E2E_ALPHA_GATES "${csi_prow_kubernetes_version_suffix}")" "alpha E2E feature gates"
344328

345329
# Which external-snapshotter tag to use for the snapshotter CRD and snapshot-controller deployment
@@ -503,6 +487,22 @@ list_gates () (
503487
done
504488
)
505489

490+
# Turn feature gates in the format foo=true,bar=false into
491+
# a YAML map with the corresponding API groups for use
492+
# with https://kind.sigs.k8s.io/docs/user/configuration/#runtime-config
493+
list_api_groups () (
494+
set -f; IFS=','
495+
# Ignore: Double quote to prevent globbing and word splitting.
496+
# shellcheck disable=SC2086
497+
set -- $1
498+
while [ "$1" ]; do
499+
if [ "$1" = 'CSIStorageCapacity=true' ]; then
500+
echo ' "storage.k8s.io/v1alpha1": "true"'
501+
fi
502+
shift
503+
done
504+
)
505+
506506
go_version_for_kubernetes () (
507507
local path="$1"
508508
local version="$2"
@@ -532,8 +532,19 @@ start_cluster () {
532532
run kind delete cluster --name=csi-prow || die "kind delete failed"
533533
fi
534534

535-
# Build from source?
536-
if [[ "${CSI_PROW_KUBERNETES_VERSION}" =~ ^release-|^latest$ ]]; then
535+
# Try to find a pre-built kind image if asked to use a specific version.
536+
if ! [[ "${CSI_PROW_KUBERNETES_VERSION}" =~ ^release-|^latest$ ]]; then
537+
major_minor=$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/^\([0-9]*\)\.\([0-9]*\).*/\1.\2/')
538+
for i in ${CSI_PROW_KIND_IMAGES}; do
539+
if echo "$i" | grep -q "kindest/node:v${major_minor}"; then
540+
image="$i"
541+
break
542+
fi
543+
done
544+
fi
545+
546+
# Need to build from source?
547+
if ! [ "$image" ]; then
537548
if ! ${csi_prow_kind_have_kubernetes}; then
538549
local version="${CSI_PROW_KUBERNETES_VERSION}"
539550
if [ "$version" = "latest" ]; then
@@ -546,63 +557,19 @@ start_cluster () {
546557
csi_prow_kind_have_kubernetes=true
547558
fi
548559
image="csiprow/node:latest"
549-
else
550-
image="kindest/node:v${CSI_PROW_KUBERNETES_VERSION}"
551560
fi
552561
cat >"${CSI_PROW_WORK}/kind-config.yaml" <<EOF
553562
kind: Cluster
554-
apiVersion: kind.sigs.k8s.io/v1alpha3
563+
apiVersion: kind.x-k8s.io/v1alpha4
555564
nodes:
556565
- role: control-plane
557566
- role: worker
558567
- role: worker
559-
EOF
560-
561-
# kubeadm has API dependencies between apiVersion and Kubernetes version
562-
# 1.15+ requires kubeadm.k8s.io/v1beta2
563-
# We only run alpha tests against master so we don't need to maintain
564-
# different patches for different Kubernetes releases.
565-
if [[ -n "$gates" ]]; then
566-
cat >>"${CSI_PROW_WORK}/kind-config.yaml" <<EOF
567-
kubeadmConfigPatches:
568-
- |
569-
apiVersion: kubeadm.k8s.io/v1beta2
570-
kind: ClusterConfiguration
571-
metadata:
572-
name: config
573-
apiServer:
574-
extraArgs:
575-
"feature-gates": "$gates"
576-
controllerManager:
577-
extraArgs:
578-
"feature-gates": "$gates"
579-
scheduler:
580-
extraArgs:
581-
"feature-gates": "$gates"
582-
- |
583-
apiVersion: kubeadm.k8s.io/v1beta2
584-
kind: InitConfiguration
585-
metadata:
586-
name: config
587-
nodeRegistration:
588-
kubeletExtraArgs:
589-
"feature-gates": "$gates"
590-
- |
591-
apiVersion: kubelet.config.k8s.io/v1beta1
592-
kind: KubeletConfiguration
593-
metadata:
594-
name: config
595-
featureGates:
596-
$(list_gates "$gates")
597-
- |
598-
apiVersion: kubeproxy.config.k8s.io/v1alpha1
599-
kind: KubeProxyConfiguration
600-
metadata:
601-
name: config
602-
featureGates:
568+
featureGates:
603569
$(list_gates "$gates")
570+
runtimeConfig:
571+
$(list_api_groups "$gates")
604572
EOF
605-
fi
606573

607574
info "kind-config.yaml:"
608575
cat "${CSI_PROW_WORK}/kind-config.yaml"

0 commit comments

Comments
 (0)