diff --git a/docs/modules/ROOT/pages/installation/advanced/multi-architecture.adoc b/docs/modules/ROOT/pages/installation/advanced/multi-architecture.adoc index 5a167ea22e..d082b32d12 100644 --- a/docs/modules/ROOT/pages/installation/advanced/multi-architecture.adoc +++ b/docs/modules/ROOT/pages/installation/advanced/multi-architecture.adoc @@ -3,37 +3,12 @@ NOTE: this part is evolving quickly during development of version 2 so it may be slightly inaccurate. -Since version 2, Camel K is publishing an ARM64 architecture beside the default AMD64 architecture. You need to reference this as `apache/camel-k:-arm64`. You can build your particular architecture from source, following the guidelines in xref:contributing/local-development.adoc[Local development]. +Since version 2, Camel K is publishing an ARM64 architecture beside the default AMD64 architecture. You can build your particular architecture from source as well, following the guidelines in xref:contributing/local-development.adoc[Local development]. [[multi-architecture-install]] == Install Camel K ARM64 operator -The default configured base image defaults to the AMD64 architecture manifest, it does not automatically look for the AMR64 architecture manifest reference. To ensure your integrations work correctly, you must specifically reference the ARM64 architecture as your base image. - -Proceed with installation of Camel K inside kubernetes cluster with the below command: - -[source,shell] ----- -kamel install --operator-image apache/camel-k:-arm64 --base-image --registry ... ----- - -=== Example - -On Camel K 2.1.0, the default base image is : `eclipse-temurin:17`. - -Look through the manifest to find the digest of a valid image containing `"architecture": "arm64"`: - -[source,shell] ----- -docker manifest inspect eclipse-temurin:17 ----- - -Proceed with installation of Camel K inside kubernetes cluster with the valid image reference: - -[source,shell] ----- -kamel install --operator-image apache/camel-k:2.1.0-arm64 --base-image eclipse-temurin:17@sha256:bbc153da9e6041c65f0d4cdc7ef03eec174c9a74c8852c838582b579081c99c1 --registry ... ----- +From version 2.3 onward, the ARM64 architecture is published beside the AMD64 in a Docker manifest. Your platform should be able to pick up the platform target architecture accordingly using the usual installation procedure. The logs should indicate the architecture at the start of the operator pod: @@ -44,24 +19,16 @@ The logs should indicate the architecture at the start of the operator pod: {"level":"info","ts":"2023-12-19T16:40:31Z","logger":"camel-k.cmd","msg":"Camel K Operator Version: 2.1.0"} ---- +=== Example -[[multi-architecture-use]] -== Test an integration +Once you've installed the operator you will need to specify the platform target you whish to use. This is required as each of the different publishing tasks may need to know how to create a manifest accordingly. You can use `builder.platforms` trait option to control this behavior. -Build and run an integration - -[source,groovy] -.hello.groovy ----- -from('timer:tick?period=3000') - .setBody().constant('Hello world from Camel K') - .to('log:info') ----- +NOTE: you can set the property at IntegrationPlatform level to have it for all Integrations. Send the groovy file to kamel operator to build, publish and run it [source,shell] ---- -kamel run hello.groovy +kamel run hello.groovy -t builder.platforms=linux/arm64 -t builder.platforms=linux/amd64 ---- You should observe base image in the logs of the operator pod: @@ -71,3 +38,5 @@ You should observe base image in the logs of the operator pod: {"level":"info","ts":"2023-12-19T17:10:05Z","logger":"camel-k","msg":"spectrum - 2023/12/19 17:10:05 Pulling base image eclipse-temurin:17@sha256:bbc153da9e6041c65f0d4cdc7ef03eec174c9a74c8852c838582b579081c99c1 (insecure=false)..."} ... ---- + +WARNING: you may need to start a new platform image from scratch disabling incremental image in order to avoid using a base image which was built against a different set of platforms. \ No newline at end of file diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc index df8d38f86a..f1cc0545e8 100644 --- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc +++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc @@ -658,6 +658,13 @@ map[string]string Annotation to use for the builder pod. Only used for `pod` strategy +|`platforms` + +[]string +| + + +The list of platforms used in order to build a container image. + |=== @@ -6300,6 +6307,13 @@ map[string]string When using `pod` strategy, annotation to use for the builder pod. +|`platforms` + +[]string +| + + +The list of manifest platforms to use to build a container image (default `linux/amd64`). + |=== diff --git a/docs/modules/traits/pages/builder.adoc b/docs/modules/traits/pages/builder.adoc index deb3481a88..e637badbc0 100755 --- a/docs/modules/traits/pages/builder.adoc +++ b/docs/modules/traits/pages/builder.adoc @@ -113,6 +113,10 @@ if you need to execute them. Useful only with `pod` strategy. | map[string]string | When using `pod` strategy, annotation to use for the builder pod. +| builder.platforms +| []string +| The list of manifest platforms to use to build a container image (default `linux/amd64`). + |=== // End of autogenerated code - DO NOT EDIT! (configuration) diff --git a/helm/camel-k/crds/crd-build.yaml b/helm/camel-k/crds/crd-build.yaml index 77a9016f7b..9ccd0da7af 100644 --- a/helm/camel-k/crds/crd-build.yaml +++ b/helm/camel-k/crds/crd-build.yaml @@ -117,6 +117,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to build a container + image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -196,6 +202,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -300,6 +312,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -850,6 +868,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -925,6 +949,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -1028,6 +1058,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -1130,6 +1166,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -1671,6 +1713,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -1742,6 +1790,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy diff --git a/helm/camel-k/crds/crd-integration-kit.yaml b/helm/camel-k/crds/crd-integration-kit.yaml index 29bf85c966..1d5bfb5378 100644 --- a/helm/camel-k/crds/crd-integration-kit.yaml +++ b/helm/camel-k/crds/crd-integration-kit.yaml @@ -263,6 +263,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml index 267189ab88..c66c8dd5fb 100644 --- a/helm/camel-k/crds/crd-integration-platform.yaml +++ b/helm/camel-k/crds/crd-integration-platform.yaml @@ -136,6 +136,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to build + a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -573,6 +579,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task @@ -1978,6 +1990,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to build + a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -2463,6 +2481,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/helm/camel-k/crds/crd-integration-profile.yaml b/helm/camel-k/crds/crd-integration-profile.yaml index 51bf3e2c1f..21e0c93340 100644 --- a/helm/camel-k/crds/crd-integration-profile.yaml +++ b/helm/camel-k/crds/crd-integration-profile.yaml @@ -455,6 +455,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task @@ -2234,6 +2240,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/helm/camel-k/crds/crd-integration.yaml b/helm/camel-k/crds/crd-integration.yaml index 0bfd409d7f..48c5885ed3 100644 --- a/helm/camel-k/crds/crd-integration.yaml +++ b/helm/camel-k/crds/crd-integration.yaml @@ -6474,6 +6474,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/helm/camel-k/crds/crd-kamelet-binding.yaml b/helm/camel-k/crds/crd-kamelet-binding.yaml index 5a4e27d493..d856f765f8 100644 --- a/helm/camel-k/crds/crd-kamelet-binding.yaml +++ b/helm/camel-k/crds/crd-kamelet-binding.yaml @@ -6758,6 +6758,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to + build a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/helm/camel-k/crds/crd-pipe.yaml b/helm/camel-k/crds/crd-pipe.yaml index a89c4b05da..860e4c44bc 100644 --- a/helm/camel-k/crds/crd-pipe.yaml +++ b/helm/camel-k/crds/crd-pipe.yaml @@ -6756,6 +6756,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to + build a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go index 5aef1596dc..f441ec918e 100644 --- a/pkg/apis/camel/v1/common_types.go +++ b/pkg/apis/camel/v1/common_types.go @@ -59,6 +59,8 @@ type BuildConfiguration struct { NodeSelector map[string]string `property:"node-selector" json:"nodeSelector,omitempty"` // Annotation to use for the builder pod. Only used for `pod` strategy Annotations map[string]string `property:"annotations" json:"annotations,omitempty"` + // The list of platforms used in order to build a container image. + ImagePlatforms []string `property:"platforms" json:"platforms,omitempty"` } // BuildStrategy specifies how the Build should be executed. diff --git a/pkg/apis/camel/v1/trait/builder.go b/pkg/apis/camel/v1/trait/builder.go index 0e626438e0..8c6ca571e9 100644 --- a/pkg/apis/camel/v1/trait/builder.go +++ b/pkg/apis/camel/v1/trait/builder.go @@ -72,4 +72,6 @@ type BuilderTrait struct { NodeSelector map[string]string `property:"node-selector" json:"nodeSelector,omitempty"` // When using `pod` strategy, annotation to use for the builder pod. Annotations map[string]string `property:"annotations" json:"annotations,omitempty"` + // The list of manifest platforms to use to build a container image (default `linux/amd64`). + ImagePlatforms []string `property:"platforms" json:"platforms,omitempty"` } diff --git a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go index 01e4a5e126..3aa1253591 100644 --- a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go +++ b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go @@ -114,6 +114,11 @@ func (in *BuilderTrait) DeepCopyInto(out *BuilderTrait) { (*out)[key] = val } } + if in.ImagePlatforms != nil { + in, out := &in.ImagePlatforms, &out.ImagePlatforms + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuilderTrait. diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go index 8ffebb03f1..9113c57dfd 100644 --- a/pkg/apis/camel/v1/zz_generated.deepcopy.go +++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go @@ -160,6 +160,11 @@ func (in *BuildConfiguration) DeepCopyInto(out *BuildConfiguration) { (*out)[key] = val } } + if in.ImagePlatforms != nil { + in, out := &in.ImagePlatforms, &out.ImagePlatforms + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildConfiguration. diff --git a/pkg/builder/jib.go b/pkg/builder/jib.go index 8f39a48f8c..0c2f071fa4 100644 --- a/pkg/builder/jib.go +++ b/pkg/builder/jib.go @@ -109,7 +109,10 @@ func (t *jibTask) Do(ctx context.Context) v1.BuildStatus { mavenArgs = append(mavenArgs, "-P", "jib") mavenArgs = append(mavenArgs, jib.JibMavenToImageParam+t.task.Image) mavenArgs = append(mavenArgs, jib.JibMavenFromImageParam+baseImage) - mavenArgs = append(mavenArgs, jib.JibMavenFromPlatforms+"linux/amd64,linux/arm64") + if t.task.Configuration.ImagePlatforms != nil { + platforms := strings.Join(t.task.Configuration.ImagePlatforms, ",") + mavenArgs = append(mavenArgs, jib.JibMavenFromPlatforms+platforms) + } if t.task.Registry.Insecure { mavenArgs = append(mavenArgs, jib.JibMavenInsecureRegistries+"true") } diff --git a/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go b/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go index 1b1f99777e..494e39c0dc 100644 --- a/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go +++ b/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go @@ -36,6 +36,7 @@ type BuildConfigurationApplyConfiguration struct { LimitMemory *string `json:"limitMemory,omitempty"` NodeSelector map[string]string `json:"nodeSelector,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` + ImagePlatforms []string `json:"platforms,omitempty"` } // BuildConfigurationApplyConfiguration constructs an declarative configuration of the BuildConfiguration type for use with @@ -135,3 +136,13 @@ func (b *BuildConfigurationApplyConfiguration) WithAnnotations(entries map[strin } return b } + +// WithImagePlatforms adds the given value to the ImagePlatforms field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the ImagePlatforms field. +func (b *BuildConfigurationApplyConfiguration) WithImagePlatforms(values ...string) *BuildConfigurationApplyConfiguration { + for i := range values { + b.ImagePlatforms = append(b.ImagePlatforms, values[i]) + } + return b +} diff --git a/pkg/resources/config/crd/bases/camel.apache.org_builds.yaml b/pkg/resources/config/crd/bases/camel.apache.org_builds.yaml index 77a9016f7b..9ccd0da7af 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_builds.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_builds.yaml @@ -117,6 +117,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to build a container + image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -196,6 +202,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -300,6 +312,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -850,6 +868,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -925,6 +949,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -1028,6 +1058,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -1130,6 +1166,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -1671,6 +1713,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -1742,6 +1790,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to + build a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy diff --git a/pkg/resources/config/crd/bases/camel.apache.org_integrationkits.yaml b/pkg/resources/config/crd/bases/camel.apache.org_integrationkits.yaml index 29bf85c966..1d5bfb5378 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrationkits.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrationkits.yaml @@ -263,6 +263,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml index 267189ab88..c66c8dd5fb 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml @@ -136,6 +136,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to build + a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -573,6 +579,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task @@ -1978,6 +1990,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of platforms used in order to build + a container image. + items: + type: string + type: array requestCPU: description: The minimum amount of CPU required. Only used for `pod` strategy @@ -2463,6 +2481,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml b/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml index 51bf3e2c1f..21e0c93340 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml @@ -455,6 +455,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task @@ -2234,6 +2240,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml b/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml index 0bfd409d7f..48c5885ed3 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml @@ -6474,6 +6474,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to build + a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml b/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml index 5a4e27d493..d856f765f8 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml @@ -6758,6 +6758,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to + build a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml b/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml index a89c4b05da..860e4c44bc 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml @@ -6756,6 +6756,12 @@ spec: - fifo - sequential type: string + platforms: + description: The list of manifest platforms to use to + build a container image (default `linux/amd64`). + items: + type: string + type: array properties: description: A list of properties to be provided to the build task diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go index 8c6a8d790f..d60d4ca8ad 100644 --- a/pkg/trait/builder.go +++ b/pkg/trait/builder.go @@ -266,7 +266,7 @@ func (t *builderTrait) Apply(e *Environment) error { }}) case v1.IntegrationPlatformBuildPublishStrategyJib: - pipelineTasks = append(pipelineTasks, v1.Task{Jib: &v1.JibTask{ + jibTask := v1.Task{Jib: &v1.JibTask{ BaseTask: v1.BaseTask{ Name: "jib", Configuration: *taskConfOrDefault(tasksConf, "jib"), @@ -276,7 +276,11 @@ func (t *builderTrait) Apply(e *Environment) error { Image: imageName, Registry: e.Platform.Status.Build.Registry, }, - }}) + }} + if t.ImagePlatforms != nil { + jibTask.Jib.Configuration.ImagePlatforms = t.ImagePlatforms + } + pipelineTasks = append(pipelineTasks, jibTask) case v1.IntegrationPlatformBuildPublishStrategyS2I: pipelineTasks = append(pipelineTasks, v1.Task{S2i: &v1.S2iTask{ diff --git a/pkg/trait/builder_test.go b/pkg/trait/builder_test.go index 7b37567193..b31952b2bc 100644 --- a/pkg/trait/builder_test.go +++ b/pkg/trait/builder_test.go @@ -654,3 +654,13 @@ func TestBuilderMatchesTasks(t *testing.T) { assert.False(t, t1.Matches(&t2)) assert.False(t, t2.Matches(&t3)) } + +func TestBuilderTraitPlatforms(t *testing.T) { + env := createBuilderTestEnv(v1.IntegrationPlatformClusterKubernetes, v1.IntegrationPlatformBuildPublishStrategyJib, v1.BuildStrategyRoutine) + builderTrait := createNominalBuilderTraitTest() + builderTrait.ImagePlatforms = []string{"linux/amd64", "linux/arm64"} + err := builderTrait.Apply(env) + require.NoError(t, err) + + assert.Equal(t, []string{"linux/amd64", "linux/arm64"}, env.Pipeline[2].Jib.Configuration.ImagePlatforms) +}