Back to Skaffold

Cross-platform and multi-platform build support

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

2.19.02.7 KB
Original Source

Skaffold selectively supports building for an architecture that is different than the development machine architecture (cross-platform build) or building for multiple architectures (multiple-platform build). The target platforms for an artifact can be specified in one of the following ways:

  • The pipeline's platforms property in the skaffold.yaml file. {{% readfile file="samples/builders/platforms/pipeline-constraints.yaml" %}}

  • The artifact's platforms constraints in the skaffold.yaml file. This overrides the value specified in the pipeline's platforms property. {{% readfile file="samples/builders/platforms/artifact-constraints.yaml" %}}

  • The CLI flag --platform which overrides the values set in both the previous ways.

cmd
skaffold build --platform=linux/arm64,linux/amd64

Additionally, for skaffold dev, skaffold debug and skaffold run commands, where the build output gets deployed immediately, skaffold checks the platform for the kubernetes cluster nodes and attempts to build artifacts for that target platform.

The final list of target platforms need to ultimately be supported by the target builder, otherwise it'll fail the build. The cross-platform build support for the various builders can be summarized in the following table:

Local BuildIn Cluster BuildRemote on Google Cloud Build
DockerfileCross-platform and multi-platform supportedCross-platform supported but platform should match cluster node running the pod.Cross-platform and multi-platform supported
Jib Maven and GradleCross-platform and multi-platform supported-Cross-platform and multi-platform supported
Cloud Native BuildpacksOnly supports linux/amd64-Only supports linux/amd64
BazelCross-platform supported--
koCross-platform and multi-platform supported-Cross-platform and multi-platform supported
Custom ScriptCross-platform and multi-platform supported but requires user to implement it in the build scriptCross-platform and multi-platform supported but requires user to implement it in the build script-

{{< alert title="Note" >}} Skaffold supports multi-platform image builds natively for the [jib builder]({{<relref "/docs/builders/builder-types/jib" >}}), the [ko builder]({{<relref "/docs/builders/builder-types/ko">}}) and the [custom builder]({{<relref "/docs/builders/builder-types/custom" >}}). For other builders that support building cross-architecture images, Skaffold will iteratively build a single platform image for each target architecture and stitch them together into a multi-platform image, and push it to the registry. {{< /alert >}}