operator-sdk icon indicating copy to clipboard operation
operator-sdk copied to clipboard

Have support for building multi-arch operator images in Makefile and Dockerfile

Open fgiloux opened this issue 3 years ago • 6 comments

Feature Request

Describe the problem you need a feature to resolve.

Make easier the build of multi-arch operators. Today the Dockerfile generated by operator-sdk init is explicitly setting GOARCH to amd64 RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go The Makefile generated by the same command is explicitly using "docker build": docker build -t ${IMG} .

Support for multi-arch builds have been requested a few times in the past, like here: https://github.com/operator-framework/operator-sdk/issues/3071

Describe the solution you'd like.

A possible approach would be to add a --multi-arch flag to operator-sdk init with default value to false for backward compatibility. When set to true

  • the generated Dockerfile would have: RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETPLATFORM GO111MODULE=on go build -a -o manager main.go
  • the Makefile would use buildx: docker buildx build --platform ${TARGET_PLATFORMS} -t ${IMG}. TARGET_PLATFORMS could default to amd64 in the Makefile

A similar approach could be used for more customization like using buildah/podman instead of docker

Benefits:

  • Better user experience: multi-arch builds supported directly by setting a flag. No need to retrieve the required commands and change generated files
  • Control by the SDK project of the Makefile and Dockerfile customization so that upgrades to newer versions of the SDK may not override changes made by users for supporting multi-arch builds

/language go

fgiloux avatar Sep 01 '21 16:09 fgiloux

cc: @jmrodri

varshaprasad96 avatar Dec 01 '21 19:12 varshaprasad96

That is a request in KB: https://github.com/kubernetes-sigs/kubebuilder/issues/2175 The issue author raise a PR to address this solution: https://github.com/kubernetes-sigs/kubebuilder/pull/2197

But it did not land because @estroz let us know that:

--platform is a docker buildx feature and will not work with vanilla docker build (unless a new docker release added support that I do not know about).

@estroz when you speak about vanilla docker you are speaking over https://github.com/vanilla/vanilla-docker . Am I right? Why we would need to support that? Can we not only support docker and maybe postman?

camilamacedo86 avatar Dec 01 '21 22:12 camilamacedo86

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Apr 12 '22 23:04 openshift-bot

/remove-lifecycle stale this should most probably get implemented in kubebuilder but still an issue in operator-sdk. multi-arch is more and more becoming a thing.

fgiloux avatar Apr 13 '22 05:04 fgiloux

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Jul 12 '22 07:07 openshift-bot

/remove-lifecycle stale

fgiloux avatar Jul 12 '22 07:07 fgiloux

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Oct 10 '22 09:10 openshift-bot

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot avatar Nov 10 '22 00:11 openshift-bot

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-bot avatar Dec 10 '22 08:12 openshift-bot

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-ci[bot] avatar Dec 10 '22 08:12 openshift-ci[bot]