operator-sdk
operator-sdk copied to clipboard
Have support for building multi-arch operator images in Makefile and Dockerfile
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
cc: @jmrodri
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?
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
/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.
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
/remove-lifecycle stale
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
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
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: 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.