Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 8620da0

Browse files
authored
Merge pull request #1519 from mesosphere/consistent-k8s-versions-for-test
build: Use setup-envtest to download later version of envtest
2 parents 4f38ee1 + 7f406a4 commit 8620da0

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ all: container hyperfed controller kubefedctl webhook e2e
7676

7777
# Unit tests
7878
test:
79-
go test $(TEST_PKGS)
79+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
80+
source <(setup-envtest use -p env 1.21.x) && \
81+
go test $(TEST_PKGS)
8082

8183
build: hyperfed controller kubefedctl webhook
8284

docs/development.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,26 @@ help you get started.
3434
### Binaries
3535

3636
The KubeFed deployment depends on `kubebuilder`, `etcd`, `kubectl`, and
37-
`kube-apiserver` >= v1.16 being installed in the path. The `kubebuilder`
38-
([v2.3.1](https://github.com/kubernetes-sigs/kubebuilder/releases/tag/v2.3.1)
39-
as of this writing) release packages all of these dependencies together.
37+
`kube-apiserver` >= v1.21. The `kubebuilder` release packages all of these
38+
dependencies together and the `controller-runtime` project contains a helper
39+
utility called `setup-envtest` that downloads required binaries and can also
40+
set up required environment variables (especially `KUBEBUILDER_ASSETS`).
4041

4142
These binaries can be installed via the `download-binaries.sh` script, which
4243
downloads them to `./bin`:
4344

4445
```bash
4546
./scripts/download-binaries.sh
47+
```
48+
49+
Running make targets will ensure that the `PATH` and other environment variables
50+
are correctly configured for the build itself, but if you wish to configure your
51+
local shell in the same way then run the following commands after running the
52+
`download-binaries.sh` script above:
53+
54+
```bash
4655
export PATH=$(pwd)/bin:${PATH}
56+
source <(setup-envtest use -p env 1.21.x)
4757
```
4858

4959
### kubernetes

scripts/download-binaries.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,29 @@ kb_url="https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${kb_v
4949
curl "${curl_args}" "${kb_url}" \
5050
| tar xzP -C "${dest_dir}" --strip-components=2
5151

52-
export KUBEBUILDER_ASSETS="${dest_dir}"
53-
echo "Setting to KUBEBUILDER_ASSETS ${dest_dir}"
52+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
53+
source <(setup-envtest use -p env 1.21.x)
54+
55+
echo "KUBEBUILDER_ASSETS is set to ${KUBEBUILDER_ASSETS}"
5456

5557
helm_version="3.6.0"
5658
helm_tgz="helm-v${helm_version}-${platform}-amd64.tar.gz"
5759
helm_url="https://get.helm.sh/$helm_tgz"
5860
curl "${curl_args}" "${helm_url}" \
5961
| tar xzP -C "${dest_dir}" --strip-components=1 "${platform}-amd64/helm"
6062

63+
kubectl_version="v1.21.14"
64+
curl -Lo "${dest_dir}/kubectl" "https://dl.k8s.io/release/${kubectl_version}/bin/${platform}/amd64/kubectl"
65+
(cd "${dest_dir}" && \
66+
echo "$(curl -L "https://dl.k8s.io/release/${kubectl_version}/bin/${platform}/amd64/kubectl.sha256") kubectl" | \
67+
sha256sum --check
68+
)
69+
chmod +x "${dest_dir}/kubectl"
70+
71+
kubebuilder_version="2.3.2"
72+
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${kubebuilder_version}/kubebuilder_${kubebuilder_version}_${platform}_amd64.tar.gz | \
73+
tar xzP -C "${dest_dir}" --strip-components=2 -- "kubebuilder_${kubebuilder_version}_${platform}_amd64/bin/kubebuilder"
74+
6175
golint_version="1.40.1"
6276
golint_dir="golangci-lint-${golint_version}-${platform}-amd64"
6377
golint_tgz="${golint_dir}.tar.gz"

0 commit comments

Comments
 (0)