Building Kubernetes [a Go binary] with Bazel
summary
Describes converting Kubernetes’ messy make + shell release pipeline into Bazel-driven builds that produce Go binaries, per-architecture Docker images and release tarballs. Uses Gazelle/Gazel to generate BUILD files, rules_go and a custom cross-build image to hermetically compile many platforms, and a Go-based archiver that cuts tar creation from minutes to ~35 seconds. Achieves near-parity for builds and CI speedups (some tests drop from ~6 minutes to ~30 seconds) but still struggles with generated-code workflows, stamping, macOS quirks and some tar/path semantics.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:02Kubernetes build challenges
- 8:27Go build limits
- 14:36Kubernetes build inputs and outputs
- 20:19Legacy Make scripts
- 25:17Generated code pain
- 27:02Adopting Bazel
- 30:31Release tarballs to Bazel
- 34:23Bazel tar rule quirks
- 36:27Optimizing tarballs and tests
- 38:31Generated code in Bazel
- 41:41Version stamping and Docker
- 43:06Current challenges
- 44:52CI and cross-platform
- 45:14Conclusion
related talks
26mBuilding Go with Bazel
24mA Dash of Bazel
37mRepeatable Deployments with Kubernetes, Helm & Bazel
07mLightning Talk – Bazel & Kubernetes: Develop like it's production
15m"ko: The Only Good Way to Build Go Containers"
33mWe Built the Kubernetes SBOM and Now You Can Write Your Own!
28mLeverage Kubernetes SPDX Tools to Create Your SBOM
43mBuilding Docker Images on Kubernetes: A Long Journey!
