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

Optimize debian-base image size #2113

Merged
merged 1 commit into from
Jun 10, 2021

Conversation

rikatz
Copy link
Contributor

@rikatz rikatz commented Jun 9, 2021

Signed-off-by: Ricardo Katz rkatz@vmware.com

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

As discussed in kubernetes/kubernetes#102493 and per wg-k8s-infra as well, we can see the mostly used image is Kube-proxy.

This PR introduces some simple optimizations in debian-base image generation, removing the qemu-static file from it and reducing in 9Mb its size.

Next PR will be for Kube-proxy generation using the image promoted from thijs PR, and that changes can reduce its image in 30% of size

Which issue(s) this PR fixes:

Partially kubernetes/kubernetes#102493

Special notes for your reviewer:

Need to verify if the change of tags is also necessary, as this will replace the current images once promoted.

If this is the case later we can promote the images once both are generated

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority labels Jun 9, 2021
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 9, 2021
@rikatz
Copy link
Contributor Author

rikatz commented Jun 9, 2021

hum, so maybe I need one PR for the base image and other for the iptables one? I'll then keep this only for the iptables one (which is our bigger consumer) and then we can deal with the Debian-base :D

@k8s-ci-robot k8s-ci-robot added area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. labels Jun 9, 2021
@BenTheElder
Copy link
Member

does it not make sense to get debian-base merged and re-built in post-submit first to maximize savings in debian-iptables?

@rikatz
Copy link
Contributor Author

rikatz commented Jun 9, 2021

@BenTheElder you mean, focusing this PR only in Debian-base and then opening a new one only for debian-iptables? I'm not sure what is the post submit job here :)

@rikatz
Copy link
Contributor Author

rikatz commented Jun 9, 2021

but yeah, I can do this!

@BenTheElder
Copy link
Member

I'm not sure what is the post submit job here :)

I'd have to double check but I'm pretty sure we automatically run the image builds to push to staging whenever a PR merges to the image(s), so we'd want that to run for debian base and then for debian-iptables (so we need seperate merges, and we need to do a promotion PR for debian base inbetween)

@@ -16,7 +16,6 @@ ARG BASEIMAGE
FROM $BASEIMAGE

ARG ARCH
COPY qemu-$ARCH-static /usr/bin/
Copy link
Member

Choose a reason for hiding this comment

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

eventually tracked this back to https://github.com/kubernetes/kubernetes/blame/0f413e5940e18c947bf8e94e9f6c35a574de1baf/build/debian-base/Dockerfile.build#L20 (bit of a pain with the repo move and all),

still not clear why that was done even then. it looks like it was copied from debian-iptables back then kubernetes/kubernetes#41915

Copy link
Member

Choose a reason for hiding this comment

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

kubernetes/kubernetes@560268e / kubernetes/kubernetes#21617

looks like this just predates the idea of running multiarch qemu setup seperately from the image build, these never needed to be in any of the component base images, as suspected ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so about this I'm also not sure why this is necessary (or if this is still necessary for cross builds).

I have a RPI3 here, maybe will try later to build the images on amd64 and check if they still work properly on arm64

Copy link
Member

Choose a reason for hiding this comment

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

I don't believe this was ever necessary versus doing it in some process external to the image, which we definitely do now.

Copy link
Member

Choose a reason for hiding this comment

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

This is safe to remove, I just wanted to understand how it ever got there in case we missed something, because it doesn't make much sense today 🙃

You can see the history above.

Copy link
Member

Choose a reason for hiding this comment

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

@BenTheElder that was required before buildx to inject the qemu-user-static binary for the platform
https://github.com/kubernetes/kubernetes/blob/0f413e5940e18c947bf8e94e9f6c35a574de1baf/build/debian-base/Makefile#L83-L86

Copy link
Member

Choose a reason for hiding this comment

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

@rikatz if you remove the binary, then you can also drop

curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/v$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz | tar -xz -C $(CONFIG)
# Ensure we don't get surprised by umask settings
chmod 0755 $(CONFIG)/qemu-$(QEMUARCH)-static

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it was required even before buildx, we do that by seperately running a qemu setup outside of the base image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aledbf glad to see you here!!! :D

Yes, probably then this can be dropped in a lot of places around the repos :)

@@ -18,15 +18,12 @@ FROM ${BASEIMAGE}

# Install iptables and ebtables packages from buster-backports
ARG IPTABLES_VERSION
RUN ln -s /bin/rm /usr/sbin/rm \
Copy link
Member

Choose a reason for hiding this comment

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

is dropping the symlink here intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in new Debian-base images the symlink already exists. Keeping it breaks the build. But as we are moving to create first a new Debian-base image and then the debian-iptables I'll revert everything here but the Debian-base things

Copy link
Member

Choose a reason for hiding this comment

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

ack, thanks!

@rikatz
Copy link
Contributor Author

rikatz commented Jun 9, 2021

@BenTheElder @aledbf Thanks for reviewing this. I'm gonna revert the iptables changes and leave the proper debian-base images changes later today, and once this gets merged and promoted do the same for debian-iptables image

@rikatz rikatz changed the title Optimize debian-base and debian-iptables images generation Optimize debian-base image size Jun 9, 2021
Signed-off-by: Ricardo Katz <rkatz@vmware.com>
@rikatz rikatz force-pushed the kproxy-img-optimization branch from b86d2ae to 9d1b494 Compare June 9, 2021 20:07
@rikatz
Copy link
Contributor Author

rikatz commented Jun 9, 2021

@BenTheElder as promised, debian-base only change right now :)

Copy link
Member

@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 9, 2021
Copy link
Member

@justaugustus justaugustus left a comment

Choose a reason for hiding this comment

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

Nice work, @rikatz!
/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, justaugustus, rikatz

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 Jun 10, 2021
@k8s-ci-robot k8s-ci-robot merged commit c08480f into kubernetes:master Jun 10, 2021
@justaugustus
Copy link
Member

Image promotion PR: kubernetes/k8s.io#2185
@rikatz -- I'll leave the debian-iptables next steps to you :)

@rikatz
Copy link
Contributor Author

rikatz commented Jun 10, 2021

Thanks Stephen! I'm on it and will remove this from my queue right now! :)

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. area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority release-note-none Denotes a PR that doesn't merit a release note. sig/release Categorizes an issue or PR as relevant to SIG Release. 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.

5 participants