Skip to content

Commit ba74c33

Browse files
authored
docs: add bazel cross-platform documentation (#9363)
* Update Bazel builder documentation to include an example * Update Skaffold cross-platform page to document that Bazel cross-platform builds are now supported. Depends on #9300. Tested with `make preview-docs-v2`. Note unrelated POSTCSS error present in main in `./hack/check-docs.sh`/`make build-docs-preview`
1 parent 5431c6b commit ba74c33

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

docs-v2/content/en/docs/builders/builder-types/bazel.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To use Bazel, `bazel` field to each artifact you specify in the
2222
{{< schema root="BazelArtifact" >}}
2323

2424
{{% alert title="Not any Bazel target can be used" %}}
25-
The target specified must produce a bundle compatible
25+
The target specified must produce a .tar bundle compatible
2626
with docker load. See
2727
<a href="https://github.com/bazelbuild/rules_docker#using-with-docker-locally">https://github.com/bazelbuild/rules_docker#using-with-docker-locally</a>
2828
{{% /alert %}}
@@ -33,4 +33,18 @@ with docker load. See
3333
The following `build` section instructs Skaffold to build a
3434
Docker image `gcr.io/k8s-skaffold/example` with Bazel:
3535

36-
{{% readfile file="samples/builders/bazel.yaml" %}}
36+
{{% readfile file="samples/builders/bazel.yaml" %}}
37+
38+
The following `build` section shows how to use Skaffold's
39+
cross-platform support to pass `--platforms` to Bazel. In this
40+
example, the Bazel project defines the `//platforms:linux-x86_64`
41+
`//platforms:linux-arm64` targets. Skaffold will pass `--platforms=//platforms:linux-x86_64` to `bazel build`
42+
if its target build platform matches `linux/amd64`, `--platforms=//platforms:linux-arm64`
43+
if its target build platform matches `linux/arm64`, and will not pass `--platforms` otherwise.
44+
45+
{{% readfile file="samples/builders/bazel-xplat.yaml" %}}
46+
47+
Note that Skaffold does not support intelligently selecting the most specific
48+
variant for platforms with variants. For example, specifying `linux/arm64`
49+
and `linux/arm64/v8` will not work. In this example it would be better to
50+
specify `linux/arm64/v7` and `linux/arm64/v8` instead.

docs-v2/content/en/docs/builders/cross-platform.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The final list of target platforms need to ultimately be supported by the target
2727
| **Dockerfile** | Cross-platform and multi-platform supported | Cross-platform supported but platform should match cluster node running the pod. | Cross-platform and multi-platform supported |
2828
| **Jib Maven and Gradle** | Cross-platform and multi-platform supported | - | Cross-platform and multi-platform supported |
2929
| **Cloud Native Buildpacks** | Only supports `linux/amd64` | - | Only supports `linux/amd64` |
30-
| **Bazel** | Cross-platform supported but requires explicit platform specific rules. Not yet implemented | - | - |
30+
| **Bazel** | Cross-platform supported | - | - |
3131
| **ko** | Cross-platform and multi-platform supported | - | Cross-platform and multi-platform supported |
3232
| **Custom Script** | Cross-platform and multi-platform supported but requires user to implement it in the build script | Cross-platform and multi-platform supported but requires user to implement it in the build script | - |
3333

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
build:
2+
artifacts:
3+
- image: gcr.io/k8s-skaffold/example
4+
bazel:
5+
target: //:example.tar
6+
platforms:
7+
- platform: linux/amd64
8+
target: //platforms:linux-x86_64
9+
- platform: linux/arm64
10+
target: //platforms:linux-arm64

0 commit comments

Comments
 (0)