Skip to content

🌱 Improve Kind Integration: Ensure Custom Kind Binary is Used in E2E Tests #4618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kersten
Copy link
Contributor

@kersten kersten commented Mar 19, 2025

Description

This PR refines the existing Kind integration by ensuring that the KIND environment variable is consistently used across e2e test utilities. While PR #4615 made the Kind binary configurable in the Makefile, some test scripts and utilities still relied on the default "kind" binary directly. This change ensures that all test components respect the KIND variable.

Motivation

  • Consistency: The Makefile already supports a configurable Kind binary, but test utilities did not.
  • Flexibility: Users running Kind from a custom location (or via a wrapper script) can now ensure it is used everywhere.
  • CI/CD Compatibility: Some environments may not have kind globally available in $PATH.

Changes

  • Updated test utilities (test/utils/utils.go) to check for a KIND environment variable before defaulting to "kind".
  • Modified Makefile test commands to explicitly pass KIND=$(KIND) to go test.
  • Applied changes across multiple test setups, including the cronjob tutorial, multiversion tutorial, and project scaffolds.
  • Ensured that Kind cluster name configurability introduced earlier remains functional.

Notes

  • Maintains full backward compatibility (defaults to kind if KIND is not set).
  • No breaking changes.
  • Further improves Kind integration by making both cluster names and binary paths configurable across all test components.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 19, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @kersten. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 19, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kersten
Once this PR has been reviewed and has the lgtm label, please assign varshaprasad96 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@kersten kersten force-pushed the feat/use-custom-kind-in-e2e-test branch from 675981c to 7be37d9 Compare March 19, 2025 11:21
@kersten kersten marked this pull request as draft March 19, 2025 11:22
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 19, 2025
@kersten kersten force-pushed the feat/use-custom-kind-in-e2e-test branch from 7be37d9 to 51fe16f Compare March 19, 2025 15:57
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 19, 2025
@kersten kersten marked this pull request as ready for review March 19, 2025 16:14
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 19, 2025
@kersten kersten force-pushed the feat/use-custom-kind-in-e2e-test branch 4 times, most recently from f2a70e7 to c294491 Compare April 8, 2025 12:19
@kersten
Copy link
Contributor Author

kersten commented Apr 9, 2025

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

@kersten: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kersten
Copy link
Contributor Author

kersten commented Apr 9, 2025

@camilamacedo86 could you trigger the tests?

@@ -81,7 +81,7 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist

.PHONY: test-e2e
test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
KIND=$(KIND) KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
Copy link
Member

Choose a reason for hiding this comment

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

It would increase the complexities.
If we would move in this direction then why not use KIND_CLUSTER

certmanagerVersion = "v1.16.3"
certmanagerURLTmpl = "https://github.com/cert-manager/cert-manager/releases/download/%s/cert-manager.yaml"

defaultKindBinary = "kind"
Copy link
Member

Choose a reason for hiding this comment

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

I think we should avoid handling kind directly in the e2e test code. It’s better to rely on the setup already defined in the Makefile (e.g., make e2e-setup). This keeps the tests clean and avoids adding complexity.

Developers can install kind and run the setup manually as needed. Automating this in test code feels out of scope and might limit flexibility for different environments.

if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
cluster = v
}
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
cmd := exec.Command("kind", kindOptions...)
kindBinary := defaultKindBinary
if v, ok := os.LookupEnv("KIND"); ok {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need an additional env var here?

We should aim to keep the code as simple as possible — adding more environment variables increases complexity without clear ROI. Unless it’s strictly necessary, it’s better to avoid introducing extra config.

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Hi @kersten

I added some coments see that when we change the scaffolds done by the tool we should not use 🌱 ( for those cases we need to use ✨ - new features and enhancements OR 🐛 for bug fixes )

add support for using a custom kind binary by reading from the
KIND environment variable. This allows flexibility in testing
environments where a different kind binary might be needed.

The default behavior remains unchanged, using "kind" if no
environment variable is set.
@kersten kersten force-pushed the feat/use-custom-kind-in-e2e-test branch from c294491 to 651ce94 Compare April 30, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants