bazelbuild / rules_k8s

This repository contains rules for interacting with Kubernetes configurations / clusters.
Apache License 2.0
291 stars 136 forks source link

Moving cluster logic into it's own object #649

Closed chasain closed 2 years ago

chasain commented 3 years ago

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 commented 3 years ago

[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: - **[OWNERS](https://github.com/bazelbuild/rules_k8s/blob/master/OWNERS)** 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 commented 3 years ago

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](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
fejta commented 3 years ago

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

UebelAndre commented 3 years ago

There also is no way to e2e test with Bazel 4.0 (https://github.com/bazelbuild/rules_k8s/pull/639#issuecomment-824416376). Not sure if that'd impact anything here.

chasain commented 3 years ago

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: https://github.com/GoogleCloudPlatform/container-definitions/issues/12037

fejta commented 3 years ago

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

fejta commented 3 years ago

/ok-to-test

fejta commented 3 years ago

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

chasain commented 3 years ago

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

fejta commented 3 years ago

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.

chasain commented 3 years ago

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

k8s-ci-robot commented 3 years ago

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

Test name Commit Details Rerun command
pull-rules-k8s-e2e 40e4e2e5e750f07e4b518bd998f69ed43f5af043 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](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
fejta commented 3 years ago

If your PR requires bazel 4.0 I'd suggest waiting until next week. I should be able to push a new image then (it isn't an automatic process)

On Tue, May 11, 2021, 12:29 Kubernetes Prow Robot @.***> wrote:

@chasain https://github.com/chasain: The following test failed, say /retest to rerun all failed tests: Test name Commit Details Rerun command pull-rules-k8s-e2e 40e4e2e https://github.com/bazelbuild/rules_k8s/commit/40e4e2e5e750f07e4b518bd998f69ed43f5af043 link https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/bazelbuild_rules_k8s/649/pull-rules-k8s-e2e/1392200017061613568 /test pull-rules-k8s-e2e

Full PR test history https://prow.k8s.io/pr-history?org=bazelbuild&repo=rules_k8s&pr=649. Your PR dashboard https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Achasain. Please help us cut down on flakes by linking to https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests an open issue https://github.com/bazelbuild/rules_k8s/issues?q=is:issue+is:open when you hit one in your PR.

Instructions for interacting with me using PR comments are available here https://git.k8s.io/community/contributors/guide/pull-requests.md. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue: repository. I understand the commands that are listed here https://go.k8s.io/bot-commands.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/bazelbuild/rules_k8s/pull/649#issuecomment-839048014, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHFSNP426DUTQEIAP4WDALTNGAQ3ANCNFSM43CLV4VQ .

chasain commented 3 years ago

Any updates on 4.0?

fejta commented 3 years ago

Has most of the work, but java tests aren't passing for mysterious reasons. Expect to solve this a week from now: https://github.com/bazelbuild/rules_k8s/pull/664

fejta commented 2 years ago

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

chasain commented 2 years ago

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