2.2 KiB
Build with Bazel
Building with Bazel is currently experimental. Automanaged BUILD rules have the
tag "automanaged" and are maintained by
gazel. Instructions for installing Bazel
can be found here.
Several make rules have been created for common operations:
make bazel-build: builds all binaries in treemake bazel-test: runs all unit testsmake bazel-release: builds release tarballs, Docker images (for server components), and Debian images
You can also interact with Bazel directly; for example, to run all kubectl unit
tests, run
$ bazel test //pkg/kubectl/...
Continuous Integration
The Bazel CI job runs
make bazel-build, make bazel-test, and (transitively) make bazel-release.
A similar job is run on all PRs.
Many steps are cached, so the Bazel job usually executes fairly quickly.
Known issues
Cross-compilation is not currently supported, so all binaries will be built for the host architecture running Bazel. Additionally, Go build tags are not supported. This means that builds on macOS may not work.
Binaries produced by Bazel are not statically linked, and they are not currently tagged with version information.
Updating BUILD files
To update BUILD files, run:
$ ./hack/update-bazel.sh
NOTE: update-bazel.sh only works if check out directory of Kubernetes is $GOPATH/src/k8s.io/kubernetes.
Only rules which are automanaged will be updated, but all rules will be auto-formatted.
Updating the BUILD file for a package will be required when:
- Files are added to or removed from a package
- Import dependencies change for a package
- A
BUILDfile has been updated and needs to be reformatted - A new
BUILDfile has been added (parentBUILDfiles will be updated)