Skip to content

Commit 59f6649

Browse files
authored
Merge pull request #2386 from estroz/chore/k8s-tools-1.22
🌱 chore(test): bump k8s tools version to 1.22
2 parents 9dbdbd2 + 5f18771 commit 59f6649

File tree

10 files changed

+42
-14
lines changed

10 files changed

+42
-14
lines changed

build/.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ builds:
4343
- linux_ppc64le
4444
- darwin_amd64
4545
env:
46-
- KUBERNETES_VERSION=1.21.1
46+
- KUBERNETES_VERSION=1.22.1
4747
- CGO_ENABLED=0
4848

4949
# Only binaries of the form "kubebuilder_${goos}_${goarch}" will be released.

docs/book/src/component-config-tutorial/testdata/project/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:latest
44
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5-
ENVTEST_K8S_VERSION = 1.21
5+
ENVTEST_K8S_VERSION = 1.22
66

77
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
88
ifeq (,$(shell go env GOBIN))

docs/book/src/cronjob-tutorial/testdata/project/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:latest
44
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5-
ENVTEST_K8S_VERSION = 1.21
5+
ENVTEST_K8S_VERSION = 1.22
66

77
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
88
ifeq (,$(shell go env GOBIN))

docs/book/src/migration/manually_migration_guide_v2_v3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ test: manifests generate fmt vet ## Run tests.
425425
<aside class="note">
426426
<h1>Envtest binaries</h1>
427427

428-
The Kubernetes binaries that are required for the Envtest were upgraded from `1.16.4` to `1.21.1`.
428+
The Kubernetes binaries that are required for the Envtest were upgraded from `1.16.4` to `1.22.1`.
429429
You can still install them globally by following [these installation instructions][doc-envtest].
430430

431431
</aside>

docs/book/src/multiversion-tutorial/testdata/project/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:latest
44
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5-
ENVTEST_K8S_VERSION = 1.21
5+
ENVTEST_K8S_VERSION = 1.22
66

77
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
88
ifeq (,$(shell go env GOBIN))

docs/book/src/reference/envtest.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ Or configure the existing target to skip the download and point to a [custom loc
3939
make test SKIP_FETCH_TOOLS=1 KUBEBUILDER_ASSETS=/opt/kubebuilder/testbin
4040
```
4141

42+
### Kubernetes 1.20 and 1.21 binary issues
43+
44+
There have been many reports of the `kube-apiserver` or `etcd` binary [hanging during cleanup][cr-1571]
45+
or misbehaving in other ways. We recommend using the 1.19.2 tools version to circumvent such issues,
46+
which do not seem to arise in 1.22+. This is likely NOT the cause of a `fork/exec: permission denied`
47+
or `fork/exec: not found` error, which is caused by improper tools installation.
48+
49+
[cr-1571]:https://github.com/kubernetes-sigs/controller-runtime/issues/1571
50+
4251
## Writing tests
4352

4453
Using `envtest` in integration tests follows the general flow of:

test/common.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
# Not every exact cluster version has an equal tools version, and visa versa.
18+
# This function returns the exact tools version for a k8s version based on its minor.
19+
function convert_to_tools_ver {
20+
local k8s_ver=${1:?"k8s version must be set to arg 1"}
21+
local maj_min=$(echo $k8s_ver | grep -oE '^[0-9]+\.[0-9]+')
22+
case $maj_min in
23+
# 1.14-1.19 work with the 1.19 server bins and kubectl.
24+
"1.14"|"1.15"|"1.16"|"1.17"|"1.18"|"1.19") echo "1.19.2";;
25+
# Tests in 1.20 and 1.21 with their counterpart version's apiserver.
26+
"1.20"|"1.21") echo "1.19.2";;
27+
"1.22") echo "1.22.1";;
28+
*)
29+
echo "k8s version $k8s_ver not supported"
30+
exit 1
31+
esac
32+
}
33+
1734
set -o errexit
1835
set -o nounset
1936
set -o pipefail
@@ -27,7 +44,8 @@ if [ -n "$TRACE" ]; then
2744
set -x
2845
fi
2946

30-
tools_k8s_version=1.19.2
47+
export KIND_K8S_VERSION="${KIND_K8S_VERSION:-"v1.22.1"}"
48+
tools_k8s_version=$(convert_to_tools_ver "${KIND_K8S_VERSION#v*}")
3149
kind_version=0.11.1
3250
goarch=amd64
3351

@@ -121,4 +139,3 @@ function is_installed {
121139
fi
122140
return 1
123141
}
124-

test/e2e/local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ source "$(dirname "$0")/../common.sh"
1818
source "$(dirname "$0")/setup.sh"
1919

2020
export KIND_CLUSTER="local-kubebuilder-e2e"
21-
create_cluster ${KIND_K8S_VERSION:-v1.22.1}
21+
create_cluster ${KIND_K8S_VERSION}
2222
if [ -z "${SKIP_KIND_CLEANUP:-}" ]; then
2323
trap delete_cluster EXIT
2424
fi

test/e2e/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ install_kind
2828
# create_cluster <k8s version>
2929
function create_cluster {
3030
: ${KIND_CLUSTER:?"KIND_CLUSTER must be set"}
31+
: ${1:?"k8s version must be set as arg 1"}
3132
if ! kind get clusters | grep -q $KIND_CLUSTER ; then
3233
kind create cluster -v 4 --name $KIND_CLUSTER --retain --wait=1m --config $(dirname "$0")/kind-config.yaml --image=kindest/node:$1
3334
fi

test/testdata/test.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ function test_project {
2929
}
3030

3131
build_kb
32-
fetch_tools
33-
34-
# Test project v2
35-
test_project project-v2
36-
test_project project-v2-multigroup
37-
test_project project-v2-addon
3832

3933
# Test project v3
4034
test_project project-v3
4135
test_project project-v3-multigroup
4236
test_project project-v3-addon
4337
test_project project-v3-config
38+
39+
# Test project v2, which relies on pre-installed envtest tools to run 'make test'.
40+
tools_k8s_version="1.19.2"
41+
fetch_tools
42+
test_project project-v2
43+
test_project project-v2-multigroup
44+
test_project project-v2-addon

0 commit comments

Comments
 (0)