Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Moving cluster logic into it's own object #649

Closed
wants to merge 6 commits into from

Conversation

chasain
Copy link

@chasain chasain commented Apr 16, 2021

This PR makes use of bazel 4.0 custom flags to define the target cluster it moves much of the logic from k8s_object regarding the target cluster into it's own rule (cluster) and makes use of an aspect to pull in information. Example usage would be:

clusters(
    name = "clusters",
    clusters = [
        ":minikube",
    ],
)

cluster(
    name = "minikube",
    cluster = "minikube",
    image_chroot = "localhost:5000",
    substitutions = {
        "%{host_name}": "localhost",
        "%{http_protocol}": "http",
    },
)

k8s_default needs to have a clusters = //path/to/clusters:label added to work then the users bazelrc needs to be edited to include :

build --flag_alias=cluster=@io_bazel_rules_k8s//k8s:cluster_flag

Then the user can make use of the flag by calling

bazel run //path/to/k8s:object --cluster=minikube

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: chasain
To complete the pull request process, please assign chizhg after the PR has been reviewed.
You can assign the PR to them by writing /assign @chizhg in a comment when ready.

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

@k8s-ci-robot
Copy link

Hi @chasain. Thanks for your PR.

I'm waiting for a bazelbuild 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/test-infra repository.

@fejta
Copy link
Contributor

fejta commented Apr 21, 2021

Hi @chasain any thoughts on how you might unit test this new behavior?

@UebelAndre
Copy link
Contributor

There also is no way to e2e test with Bazel 4.0 (#639 (comment)). Not sure if that'd impact anything here.

@chasain
Copy link
Author

chasain commented Apr 22, 2021

There also is no way to e2e test with Bazel 4.0 (#639 (comment)). Not sure if that'd impact anything here.

Looks like this is the tracker for that: GoogleCloudPlatform/container-definitions#12037

@fejta fejta closed this Apr 30, 2021
@fejta fejta reopened this Apr 30, 2021
@fejta
Copy link
Contributor

fejta commented Apr 30, 2021

(does reopening cause buildkite to retry? looks like no)

@fejta
Copy link
Contributor

fejta commented Apr 30, 2021

/ok-to-test

@fejta
Copy link
Contributor

fejta commented May 1, 2021

The e2e tests provide a good signal again, will you push a commit which addresses the pull-rules-k8s-e2e errors? Thanks!

@chasain
Copy link
Author

chasain commented May 10, 2021

Hey, was dealing with some personal stuff last week, I'll take a look at it this week.

@fejta
Copy link
Contributor

fejta commented May 10, 2021

No problem, thanks for you patience with the e2e errors and for contributing to this repo! Will review it again once there's a new commit up.

@@ -1 +1 @@
3.5.0
4.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have 4.0.0 images yet on account of the fact that launcher.gcr.io/google/bazel hasn't published any images since 3.5.0

  • We'll either need to wait for that to get fixed (there's an open issue somewhere to publish them (which no one seems to be addressing)
  • Or else change the Dockerfile to install both targeted versions of bazel using some other mechanism (aka building both from source)

FROM launcher.gcr.io/google/bazel:${OLD_VERSION} as old

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I added that to be able to test locally since the flags are 4.0 only, but it actually seemed to work ok in the buildkite job...

image

Copy link
Contributor

Choose a reason for hiding this comment

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

The buildkite job just does bazelisk build //... which is an important signal.

Actually using the outputs to talk to kubectl is handled by the pull-rules-k8s-e2e job which has an image with both 3.5.0 and 3.0.0, which can be chosen using .bazelversion

Copy link
Author

Choose a reason for hiding this comment

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

Do you need to build and push a new image when I change that Dockerfile? I added what the job recommended but it looks like it's still the same image.

Bazel binaries for all official releases can be downloaded from here:
  https://github.com/bazelbuild/bazel/releases
You can download the required version directly using this command:
  (cd "/usr/local/lib/bazel/bin" && curl -fLO https://releases.bazel.build/4.0.0/release/bazel-4.0.0-linux-x86_64 && chmod +x bazel-4.0.0-linux-x86_64)

@chasain
Copy link
Author

chasain commented May 11, 2021

Not sure how to update minimum supported version to 4.0
Figured it out

@k8s-ci-robot
Copy link

@chasain: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-rules-k8s-e2e 40e4e2e link /test pull-rules-k8s-e2e

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

@fejta
Copy link
Contributor

fejta commented May 11, 2021 via email

@chasain
Copy link
Author

chasain commented May 24, 2021

Any updates on 4.0?

@fejta
Copy link
Contributor

fejta commented Jul 15, 2021

Has most of the work, but java tests aren't passing for mysterious reasons. Expect to solve this a week from now: #664

kind = kwargs.get("kind"),
clusters = kwargs.get("clusters"),
user = kwargs.get("user"),
namespace = kwargs.get("namespace"),

This comment was marked as off-topic.

This comment was marked as resolved.

@fejta
Copy link
Contributor

fejta commented Jun 10, 2022

Would you like to try and rebase this PR or close it?

@chasain
Copy link
Author

chasain commented Jun 10, 2022

I ended up moving to skaffold to manage this process in a much cleaner way, feel free to close this.

@chasain chasain closed this Jun 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants