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

build: Use setup-envtest to download later version of envtest #1519

Conversation

jimmidyson
Copy link
Contributor

controller-runtime provides a convenient tool to download various versions of k8s. This commit switches to using that to ensure we use a single version for testing in unit tests and in e2e tests, namely v1.21.x right now so to keep the version stable while just changing the installation mechanism.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 9, 2022
@jimmidyson jimmidyson requested a review from makkes August 9, 2022 08:34
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 9, 2022
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 9, 2022
@jimmidyson jimmidyson force-pushed the consistent-k8s-versions-for-test branch 2 times, most recently from 6065b42 to 8cd39f2 Compare August 9, 2022 09:39
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 9, 2022
`controller-runtime` provides a convenient tool to download various versions
of k8s. This commit switches to using that to ensure we use a single version
for testing in unit tests and in e2e tests, namely v1.21.x right now so to
keep the version stable while just changing the installation mechanism.
@jimmidyson jimmidyson force-pushed the consistent-k8s-versions-for-test branch from 8cd39f2 to 7f406a4 Compare August 9, 2022 09:40
Copy link
Contributor

@makkes makkes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one question, otherwise lgtm

export KUBEBUILDER_ASSETS="${dest_dir}"
echo "Setting to KUBEBUILDER_ASSETS ${dest_dir}"
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
source <(setup-envtest use -p env 1.21.x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question as in #1516:

Why do we need to setup envtest here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kubebuilder releases used to bundle kubebuilder binary along with kube-apiserver, etcd, kubectl, etc. These stopped happening a long time ago, with version 2.3.2 iirc of kubebuilder (the version used in this project) bundling k8s v1.16 - too old for us now. Recent versions of kubebuilder no longer do that, instead distributing k8s binaries per version. Although you can define the URL to download directly, using setup-envtest is a convenience that allows you to not /discover know the URL and change the minor version to test against as this PR now does. It's just to make things easier tbh...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh you mean why here! Well strictly we don't I guess could remove it but it is just replacing what was here before downloading kubebuilder provided kube-apiserver, etc. I don't mind removing it if you think it's best to though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Yeah, with this line the behaviour would be retained. I'm fine either way.

@makkes
Copy link
Contributor

makkes commented Aug 9, 2022

/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jimmidyson, makkes

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 9, 2022
@k8s-ci-robot k8s-ci-robot merged commit 8620da0 into kubernetes-retired:master Aug 9, 2022
@jimmidyson jimmidyson deleted the consistent-k8s-versions-for-test branch August 9, 2022 12:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants