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

Faster K3s Binary Build Option #7805

Merged
merged 6 commits into from
Jun 27, 2023
Merged

Conversation

dereknola
Copy link
Member

@dereknola dereknola commented Jun 20, 2023

Proposed Changes

This is an attempt to make a multi-stage dockerfile that focuses on the minimal build required to produces a functional k3s binary. The use case is when developer must build k3s over and over again when developing small code changes. Images and rpm packaging is often unnecessary when all you need to do is run ./dist/artifacts/k3s server -t 12345

Speedup is achieved from the following:

  • No validation of the project code
  • No trivy vulnerability scanning
  • Breaking the mono script ci into its components on Docker build to maximize intermediate image caching
  • Using buildkit mount caching on go build calls

This is not intended as a replacement for any of the CI build process at this time.

Types of Changes

Local Build

Verification

Run make local to use the new build option

Testing

  • Run on a AMD Ryzen 7 5800H
  • All build/intermediate images are cleared before set of runs
  • Between Run 1 and Run 2, modify pkg/etc/etcdproxy.go, rename function ETCDServerURL to ETCDServerURL1, simulating a code change
  • Between Run2 and Run3, no change is made to the code, a somewhat pointless exersice, but one that shows the amount of caching
  • dapper is run with SKIP_VALIDATE=true SKIP_AIRGAP=true make the current fastest way to produce a k3s binary
dapper (master) dapper (with this PR) local
Run 1 4m38.98s 4m27.25s 2m45.07s
Run 2 2m30.53s 1m45.78s 0m52.79s
Run 3 1m35.29s 0m1.53s

Linked Issues

User-Facing Change


Further Comments

@dereknola dereknola requested a review from a team as a code owner June 20, 2023 22:03
Signed-off-by: Derek Nola <[email protected]>
@@ -5,3 +5,4 @@
./.cache
./.dapper
./.trash-cache
./.git/objects/pack
Copy link
Member Author

@dereknola dereknola Jun 21, 2023

Choose a reason for hiding this comment

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

This folder contains the bulk of the .git ~1.6GB size, but is not needed to extract the commit ID or branch when calling git status or other git info commands. Ignoring this folder enables a much lower copy of only some 40KB to docker containers and still allows use of the scripts/version.sh.

@dereknola dereknola changed the title [WIP] Faster K3s Binary Build Option Faster K3s Binary Build Option Jun 22, 2023
@codecov
Copy link

codecov bot commented Jun 23, 2023

Codecov Report

Patch coverage has no change and project coverage change: +4.36 🎉

Comparison is base (b66a118) 47.18% compared to head (b754099) 51.55%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7805      +/-   ##
==========================================
+ Coverage   47.18%   51.55%   +4.36%     
==========================================
  Files         143      143              
  Lines       14509    14509              
==========================================
+ Hits         6846     7480     +634     
+ Misses       6573     5845     -728     
- Partials     1090     1184      +94     
Flag Coverage Δ
e2etests 49.37% <ø> (?)
inttests 44.47% <ø> (-0.08%) ⬇️
unittests 19.85% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 40 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants