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

Reduce binary size of kairos components #2285

Closed
1 task done
Tracked by #1791
mudler opened this issue Feb 22, 2024 · 3 comments
Closed
1 task done
Tracked by #1791

Reduce binary size of kairos components #2285

mudler opened this issue Feb 22, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@mudler
Copy link
Member

mudler commented Feb 22, 2024

Is your feature request related to a problem? Please describe.
Currently UKI can suffer of hard limit on the EFI files meant to be booted. This is problematic as we hit systemd/systemd#25911 when trying to build big images.

Describe the solution you'd like
In order to optimize the size of the images, we should try to reduce the image size of the golang binaries we bundle in the image, for instance:

Also, similarly we can try to compress the k3s binary as well.

Describe alternatives you've considered
N/A

Additional context
This is partially related to #2283, but that story is just about the ubuntu base image dependencies.

To strip binaries, we need to change how we build/package them in kairos-io/packages.

Build phase:

During build, we can specify the -w and -s build flags that strip part of the debug symbols, for instance:

go build -ldflags "-w -s"

For compressing I suggest to use upx right after build. For example:

upx -1 <binary> 
@mudler mudler added the enhancement New feature or request label Feb 22, 2024
@mudler mudler assigned mudler and unassigned mudler Feb 22, 2024
@mudler mudler mentioned this issue Feb 22, 2024
53 tasks
@mauromorales mauromorales self-assigned this Feb 26, 2024
@mauromorales
Copy link
Member

⚠️ immucore still hasn't been compressed

before:

...
9920    /usr/bin/kcrypt
15872   /usr/bin/immucore
23168   /usr/bin/nerdctl
23432   /usr/bin/snap
26220   /usr/bin/luet
31424   /usr/bin/edgevpn
43012   /usr/bin/kube-vip
47044   /usr/bin/kubectl
54468   /usr/bin/k3s
89924   /usr/bin/k9s
93956   /usr/bin/kairos-agent
519300  total

After:

...
5096    /usr/bin/kcrypt
11592   /usr/bin/nerdctl
11880   /usr/bin/kairos-agent
14580   /usr/bin/edgevpn
16704   /usr/bin/immucore
16848   /usr/bin/snap
19340   /usr/bin/kubectl
25748   /usr/bin/k9s
27368   /usr/bin/luet
44312   /usr/bin/kube-vip
56504   /usr/bin/k3s
296316  total

@mauromorales
Copy link
Member

final standard efi file size:

kairos@localhost:~$ ls -lash /efi/EFI/kairos/
total 2.7G
8.0K drwxr-xr-x 2 root root 8.0K Feb 27 08:33 .
8.0K drwxr-xr-x 5 root root 8.0K Feb 27 08:22 ..
912M -rwxr-xr-x 1 root root 912M Feb 27 08:33 active.efi
912M -rwxr-xr-x 1 root root 912M Feb 27 08:33 passive.efi
912M -rwxr-xr-x 1 root root 912M Feb 27 08:33 recovery.efi

@jimmykarily
Copy link
Contributor

We are done reducing sizes. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

3 participants