{"action":"created","issue":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/71290","repository_url":"https://api.github.com/repos/kubernetes/kubernetes","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/71290/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/71290/comments","events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/71290/events","html_url":"https://github.com/kubernetes/kubernetes/issues/71290","id":382901844,"node_id":"MDU6SXNzdWUzODI5MDE4NDQ=","number":71290,"title":"Building kubectl with Bazel as an external repo dependency is not currently possible.","user":{"login":"nlopezgi","id":4062751,"node_id":"MDQ6VXNlcjQwNjI3NTE=","avatar_url":"https://avatars3.githubusercontent.com/u/4062751?v=4","gravatar_id":"","url":"https://api.github.com/users/nlopezgi","html_url":"https://github.com/nlopezgi","followers_url":"https://api.github.com/users/nlopezgi/followers","following_url":"https://api.github.com/users/nlopezgi/following{/other_user}","gists_url":"https://api.github.com/users/nlopezgi/gists{/gist_id}","starred_url":"https://api.github.com/users/nlopezgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nlopezgi/subscriptions","organizations_url":"https://api.github.com/users/nlopezgi/orgs","repos_url":"https://api.github.com/users/nlopezgi/repos","events_url":"https://api.github.com/users/nlopezgi/events{/privacy}","received_events_url":"https://api.github.com/users/nlopezgi/received_events","type":"User","site_admin":false},"labels":[{"id":267761362,"node_id":"MDU6TGFiZWwyNjc3NjEzNjI=","url":"https://api.github.com/repos/kubernetes/kubernetes/labels/kind/feature","name":"kind/feature","color":"c7def8","default":false},{"id":483069764,"node_id":"MDU6TGFiZWw0ODMwNjk3NjQ=","url":"https://api.github.com/repos/kubernetes/kubernetes/labels/sig/testing","name":"sig/testing","color":"d2b48c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-11-21T00:15:44Z","updated_at":"2018-11-21T01:11:15Z","closed_at":null,"author_association":"NONE","body":"<!-- Please only use this template for submitting enhancement requests -->\r\n\r\n**What would you like to be added**:\r\nI would like to be able to build kubectl as a dependency of another Bazel project.\r\nSpecifically, it should be possible to add to a WORKSPACE file something like:\r\n ```\r\n http_archive(\r\n      name = \"io_kubernetes\",\r\n      sha256 = \"4737d3b10b27e391924f89b5ac3aaa5470619b92b75fe1ff5210cc30c56e2e53\",\r\n      strip_prefix = \"kubernetes-1.10.10\",\r\n      urls = [\"https://github.com/kubernetes/kubernetes/archive/v1.10.10.tar.gz\"]\r\n  )\r\n\r\nload_something_something_kubernetes(...)\r\n```\r\nand then do\r\n`bazel build @io_kubernetes//cmd/kubectl:kubectl`\r\n\r\n(note the `load_something_something_kubernetes` does not exist today)\r\n\r\n**Why is this needed**:\r\nThis would enable using kubectl as an external dependency of `rules_k8s` (https://github.com/bazelbuild/rules_k8s) project. This is very desirable as it would enable building kubectl from source (https://github.com/bazelbuild/rules_k8s/issues/227) and use that as the binary to use to execute k8s commands. We often get requests from rules_k8s users that this would be a very desirable feature. \r\n\r\nMore notes below expanding on what issues I found when I tried to build kubectl as an external dep:\r\n\r\nI found the following issues:\r\n- the build depends on an `@org_golang_x_tools` repo. I could not find out where this is being pulled (perhaps in a repository_rule?), however, I could hack around this by copying it from the kubernetes project directly. I also needed to add manually to my WORKSPACE a `http_archive` rule to download `@io_kubernetes_build` \r\n\r\n- the repo is using genrules (e.g. `vendor/k8s.io/apimachinery/pkg/util/sets/BUILD:23`) which are running go binaries produced by other build steps, but are not referencing these properly when used in an external repo. I got this error message: \r\n\r\n```\r\nimport \"./vendor/k8s.io/apimachinery/pkg/util/sets/types\": cannot find package \"./vendor/k8s.io/apimachinery/pkg/util/sets/types\" in:\r\n        /usr/local/google/home/<...>/ffcac8bde6710ff680ff645bb4ae7c92/sandbox/linux-sandbox/30/execroot/io_bazel_rules_k8s/vendor/k8s.io/apimachinery/pkg/util/sets/types\r\n```\r\n\r\nfyi @fejta @chrislovecnm \r\n\r\n<!-- DO NOT EDIT BELOW THIS LINE -->\r\n/kind feature"},"comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments/440490966","html_url":"https://github.com/kubernetes/kubernetes/issues/71290#issuecomment-440490966","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/71290","id":440490966,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDQ5MDk2Ng==","user":{"login":"ixdy","id":8061296,"node_id":"MDQ6VXNlcjgwNjEyOTY=","avatar_url":"https://avatars3.githubusercontent.com/u/8061296?v=4","gravatar_id":"","url":"https://api.github.com/users/ixdy","html_url":"https://github.com/ixdy","followers_url":"https://api.github.com/users/ixdy/followers","following_url":"https://api.github.com/users/ixdy/following{/other_user}","gists_url":"https://api.github.com/users/ixdy/gists{/gist_id}","starred_url":"https://api.github.com/users/ixdy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ixdy/subscriptions","organizations_url":"https://api.github.com/users/ixdy/orgs","repos_url":"https://api.github.com/users/ixdy/repos","events_url":"https://api.github.com/users/ixdy/events{/privacy}","received_events_url":"https://api.github.com/users/ixdy/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T01:11:15Z","updated_at":"2018-11-21T01:11:15Z","author_association":"MEMBER","body":"A few comments here:\r\n- The kubernetes 1.10 branch is pretty old, and depends on an even older version of `rules_go`. You might have an easier time with a more recent release, though a number of issues would still remain.\r\n- The various go dependencies come from `rules_go` with `go_rules_dependencies()` and `go_register_toolchains()`. We call those in our `WORKSPACE`.\r\n- In general, we discourage Go projects from vendoring `kubernetes/kubernetes` directly, and similarly we haven't really put any effort into making `kubernetes/kubernetes` a valid bazel dependency, either. We'd probably need to factor out some of the dependencies from `WORKSPACE` like many projects do, and we'd also have to fix that genrule as you noted. I think @mikedanese opened a PR once to start fixing some of this, but it never merged.\r\n- Is there a reason you can't depend on the built + released `kubectl` binaries instead, doing something similar to how `rules_go` downloads the correct toolchain?\r\n- I think `kubectl` intends to move to its own repo eventually, which should make this more manageable in the future."}}
{"actor":{"display_login":"ixdy"}}