Skip to content

Commit

Permalink
feat(traits): builder image platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Mar 21, 2024
1 parent 8dd6138 commit 8a3773f
Show file tree
Hide file tree
Showing 25 changed files with 299 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:<version>-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:<version>-arm64 --base-image <base-image-arm64> --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:

Expand All @@ -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:
Expand All @@ -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.
14 changes: 14 additions & 0 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
|===
Expand Down Expand Up @@ -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`).
|===
Expand Down
4 changes: 4 additions & 0 deletions docs/modules/traits/pages/builder.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
54 changes: 54 additions & 0 deletions helm/camel-k/crds/crd-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions helm/camel-k/crds/crd-integration-kit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions helm/camel-k/crds/crd-integration-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions helm/camel-k/crds/crd-integration-profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions helm/camel-k/crds/crd-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions helm/camel-k/crds/crd-kamelet-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions helm/camel-k/crds/crd-pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/camel/v1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/camel/v1/trait/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
5 changes: 5 additions & 0 deletions pkg/apis/camel/v1/trait/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8a3773f

Please sign in to comment.