Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiArchitecture support #3309

Merged
merged 35 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
899f8f0
restore core to upstream version
May 13, 2022
680fc7f
correct image and make file script
robertonav20 May 15, 2022
aaef9e4
update buildah image version for multi platform support
robertonav20 May 16, 2022
868d9aa
replace arch with platform
robertonav20 May 17, 2022
9610b54
add variant field and change the policy
May 17, 2022
82de032
add docker.io inside baseimage
May 17, 2022
883606f
obtain architecture value from PublishStrategyOptions
robertonav20 May 24, 2022
0d25484
replace name of buildah property
robertonav20 May 24, 2022
80b5fa6
correct buildah attribute
robertonav20 May 24, 2022
f0a2e7a
correct attribute name
May 26, 2022
b28dd3a
add Dockerfile.arch to support arm64
robertonav20 May 26, 2022
6b6a3b0
remove useless import
May 27, 2022
db4cfa1
execute goimports lint
May 27, 2022
4bfb4ad
Merge branch 'apache:main' into main
robertonav20 May 27, 2022
90a0fa6
correct docker file for buildx
May 27, 2022
83c7256
correct makefile command
May 31, 2022
9b9cc8d
fix platform initialize
May 31, 2022
ee084aa
improve readibility of bud command
May 31, 2022
9f55b65
remove useless containerd dependency
May 31, 2022
8b6d1c8
Fix makefile images-arch command
Jun 1, 2022
6b65f16
correct docker image name
Jun 1, 2022
cb94bb5
add default docker.io to baseimage because buildah required it
Jun 1, 2022
ae3509c
correct bud command
Jun 1, 2022
88029ed
Merge branch 'apache:main' into main
robertonav20 Jun 1, 2022
ddba5aa
correct bud command with platform
Jun 1, 2022
746ec58
add log to trace platform attribute
Jun 1, 2022
aed28da
Merge branch 'main' of https://github.com/robertonav20/camel-k into main
Jun 1, 2022
b7b37eb
add docs page to describe multi architecture use
robertonav20 Jun 2, 2022
8017221
add note
robertonav20 Jun 2, 2022
2d8239e
Generate CRD
Jun 3, 2022
69dd576
Merge branch 'apache:main' into main
robertonav20 Jun 8, 2022
b52c2a9
Merge branch 'apache:main' into main
robertonav20 Jun 16, 2022
b95f642
regenerate crd
Jun 18, 2022
b6c8d50
Merge remote-tracking branch 'refs/remotes/origin/main'
Jun 18, 2022
75f13c9
Merge branch 'apache:main' into main
robertonav20 Jun 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/apis/camel/v1/build_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type BuildahTask struct {
BaseTask `json:",inline"`
PublishTask `json:",inline"`
// The platform of build image
Platform string `json:"baseImage,omitempty"`
Platform string `json:"platform,omitempty"`
// log more information
Verbose *bool `json:"verbose,omitempty"`
}
Expand Down
40 changes: 28 additions & 12 deletions pkg/controller/build/build_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,34 @@ func addBuildTaskToPod(build *v1.Build, taskName string, pod *corev1.Pod) {
}

func addBuildahTaskToPod(ctx context.Context, c ctrl.Reader, build *v1.Build, task *v1.BuildahTask, pod *corev1.Pod) error {
bud := []string{
"buildah",
"bud",
"--storage-driver=vfs",
"--platform",
task.Platform,
"--pull-always",
"-f",
"Dockerfile",
"-t",
task.Image,
".",
bud := []string{}

if task.Platform != "" {
robertonav20 marked this conversation as resolved.
Show resolved Hide resolved
bud = []string{
"buildah",
"bud",
"--storage-driver=vfs",
"--platform",
task.Platform,
"--pull-always",
"-f",
"Dockerfile",
"-t",
task.Image,
".",
}
} else {
bud = []string{
"buildah",
"bud",
"--storage-driver=vfs",
"--pull-always",
"-f",
"Dockerfile",
"-t",
task.Image,
".",
}
}

push := []string{
Expand Down
3 changes: 1 addition & 2 deletions pkg/trait/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/apache/camel-k/pkg/builder"
mvn "github.com/apache/camel-k/pkg/util/maven"
"github.com/apache/camel-k/pkg/util/property"
"github.com/containerd/containerd/platforms"
)

// The builder trait is internally used to determine the best strategy to
Expand Down Expand Up @@ -105,7 +104,7 @@ func (t *builderTrait) Apply(e *Environment) error {
var platform string
var found bool
if platform, found = e.Platform.Status.Build.PublishStrategyOptions[builder.BuildahPlatform]; !found {
platform = platforms.DefaultSpec().OS + "/" + platforms.DefaultSpec().Architecture + "/" + platforms.DefaultSpec().Variant
platform = ""
}

e.BuildTasks = append(e.BuildTasks, v1.Task{Buildah: &v1.BuildahTask{
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
KanikoVersion = "0.17.1"

// baseImage --
baseImage = "docker.io/adoptopenjdk/openjdk11:slim"
baseImage = "adoptopenjdk/openjdk11:slim"

// LocalRepository --
LocalRepository = "/tmp/artifacts/m2"
Expand Down
36 changes: 20 additions & 16 deletions script/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ OPM_VERSION := v1.21.0
BASE_IMAGE := docker.io/adoptopenjdk/openjdk11:slim
LOCAL_REPOSITORY := /tmp/artifacts/m2
IMAGE_NAME := docker.io/apache/camel-k
IMAGE_TARGET_PLATFORM := linux/amd64

#
# Situations when user wants to override
Expand Down Expand Up @@ -91,15 +90,6 @@ TEST_PREBUILD = build
#GOLDFLAGS += -X github.com/apache/camel-k/pkg/util/olm.DefaultStartingCSV=
#GOLDFLAGS += -X github.com/apache/camel-k/pkg/util/olm.DefaultGlobalNamespace=openshift-operators

# Define target platform for docker build
ifeq ($(shell uname -m), x86_x64)
IMAGE_TARGET_PLATFORM = linux/amd64
endif

ifeq ($(shell uname -m), aarch64)
IMAGE_TARGET_PLATFORM = linux/arm64
endif

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -341,6 +331,16 @@ endif
docker build -t $(CUSTOM_IMAGE):$(CUSTOM_VERSION) -f build/Dockerfile .

images-arch: bundle-kamelets test maven-overlay
IMAGE_TARGET_PLATFORM := linux/amd64
# Define target platform for docker build
ifeq ($(shell uname -m), x86_x64)
IMAGE_TARGET_PLATFORM = linux/amd64
endif

ifeq ($(shell uname -m), aarch64)
IMAGE_TARGET_PLATFORM = linux/arm64
endif

mkdir -p build/_maven_output
mkdir -p build/_output/bin
ifneq ($(shell uname -s 2>/dev/null || echo Unknown),Linux)
Expand All @@ -363,6 +363,16 @@ endif
docker build -t $(CUSTOM_IMAGE):$(CUSTOM_VERSION) -f build/Dockerfile .

images-arch-dev: bundle-kamelets test package-artifacts maven-overlay
IMAGE_TARGET_PLATFORM := linux/amd64
# Define target platform for docker build
ifeq ($(shell uname -m), x86_x64)
IMAGE_TARGET_PLATFORM = linux/amd64
endif

ifeq ($(shell uname -m), aarch64)
IMAGE_TARGET_PLATFORM = linux/arm64
endif

mkdir -p build/_maven_output
mkdir -p build/_output/bin
ifneq ($(shell uname -s 2>/dev/null || echo Unknown),Linux)
Expand Down Expand Up @@ -581,9 +591,3 @@ endif
# Build the bundle image.
bundle-build: bundle
cd bundle && docker build -f Dockerfile -t $(BUNDLE_IMAGE_NAME) .

# Build the bundle image.
bundle-build-arch: bundle
docker buildx rm --all-inactive --force
docker buildx create --append --name builder
cd bundle && docker buildx build --platform=$(IMAGE_TARGET_PLATFORM) -f Dockerfile.arch -t $(BUNDLE_IMAGE_NAME) .