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

docker: support qemu target builds #1092

Merged

Conversation

tormath1
Copy link
Contributor

@tormath1 tormath1 commented Mar 3, 2023

this commit adds qemu amd64 binaries to build qemu images from the Docker image.

example:

docker run -it --net host --rm -e OEM_ID=openstack cluster-node-image-builder-amd64 build-qemu-flatcar

Note: For now it can only run builds without acceleration because it still uses the imagebuilder user but as imagebuilder needs to be in the KVM group and we don't know in advance the group ID of kvm group on the host: we would need to build and run the image with root user to allow KVM acceleration, this can be done in a follow-up PR.

Additional context

We could preserve the imagebuilder user by creating it with the uid/gid 0 but in the end it's creating another "root" user...

@k8s-ci-robot
Copy link
Contributor

Hi @tormath1. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 3, 2023
&& apt-get purge --auto-remove -y \
&& rm -rf /var/lib/apt/lists/*

ARG ARCH
ARG PASSED_IB_VERSION

USER imagebuilder
Copy link
Contributor

@mboersma mboersma Mar 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also like to use the default root user, because we want to use this container image in our pipelines and that's an Azure DevOps requirement. (See #991.)

But using a specific non-root user in a Docker container is still generally considered a "best practice" I believe, so I'd like to hear from others as to whether this change is acceptable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But using a specific non-root user in a Docker container is still generally considered a "best practice" I believe, so I'd like to hear from others as to whether this change is acceptable.

That was my conclusion too - as I don't see any other indications to use a non-root user. 🤷 Let's hear from the maintainers!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we default it but make it overridable for the use cases it is needed for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jsturtevant, you mean make it overridable at the build time? It won't be possible at the runtime, as the dependencies (packer, ansible, etc.) are installed in the home directory of the user used during the build.

Copy link
Contributor

@mdbooth mdbooth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to see the user changes in a separate PR. Could we reduce this one to just adding qemu?

@@ -17,26 +17,22 @@
ARG BASE_IMAGE=docker.io/library/ubuntu:latest
FROM $BASE_IMAGE

RUN apt-get update && apt-get install -y apt-transport-https build-essential ca-certificates curl git jq python3-pip rsync unzip vim wget \
&& useradd -ms /bin/bash imagebuilder \
RUN apt-get update && apt-get install -y apt-transport-https build-essential ca-certificates curl git jq python3-pip rsync unzip vim wget qemu-system-x86 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we also add qemu-kvm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added qemu-kvm and dropped the user changes.

@mdbooth
Copy link
Contributor

mdbooth commented Mar 17, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 17, 2023
@tormath1 tormath1 force-pushed the tormath1/docker-qemu-builder branch 2 times, most recently from fe6c970 to 6070aef Compare March 20, 2023 09:07
this commit adds qemu amd64 binaries to build qemu images from the Docker
image.

example:
```
docker run -it --rm -e PACKER_FLAGS="--var 'accelerator=none'" -e OEM_ID=openstack cluster-node-image-builder-amd64 build-qemu-flatcar
```

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
@tormath1 tormath1 force-pushed the tormath1/docker-qemu-builder branch from 6070aef to 6b2a0ec Compare March 21, 2023 14:51
Copy link
Contributor

@mboersma mboersma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 23, 2023
@kkeshavamurthy
Copy link
Member

/lgtm
/approve

@kkeshavamurthy
Copy link
Member

/approve

1 similar comment
@kkeshavamurthy
Copy link
Member

/approve

@kkeshavamurthy
Copy link
Member

maybe someone in the qemu approvers list need to approve this?

@mdbooth
Copy link
Contributor

mdbooth commented Mar 30, 2023

Pretty sure I can't, but

/approve

@mdbooth
Copy link
Contributor

mdbooth commented Mar 30, 2023

Despite what the bot says, I think it needs an approver from https://github.com/kubernetes-sigs/image-builder/blob/master/images/capi/OWNERS, which is just cluster-api-maintainers, i.e.:

@CecileRobertMichon
@enxebre
@fabriziopandini
@sbueringer
@vincepri

@mboersma
Copy link
Contributor

mboersma commented Mar 31, 2023

I think it needs an approver from https://github.com/kubernetes-sigs/image-builder/blob/master/images/capi/OWNERS

This really shouldn't be the case, see
https://github.com/kubernetes/community/blob/master/contributors/guide/owners.md#owners
We don't set no_parent_owners: false, so I think it should be incorporating the root OWNERS/OWNERS_ALIASES files. And in fact, it always has done and it's only recently that this behavior seems to have changed.

See #1110 for an example of how it was working about two weeks ago.

@sbueringer
Copy link
Member

sbueringer commented Apr 12, 2023

Yup top-level approval should 100% be enough. Can we open an issue in e.g. test-infra to get some awareness / maybe someone has time to investigate? (maybe we found a recently introduced bug in the approve plugin)

Let's see if that helps for now
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kkeshavamurthy, mdbooth, sbueringer, tormath1

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 12, 2023
@k8s-ci-robot k8s-ci-robot merged commit 2e96edb into kubernetes-sigs:master Apr 12, 2023
@tormath1 tormath1 deleted the tormath1/docker-qemu-builder branch April 12, 2023 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants