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

Add optional embedding of container images #239

Merged
merged 22 commits into from
Aug 28, 2024

Conversation

jacobweinstock
Copy link
Member

@jacobweinstock jacobweinstock commented Aug 21, 2024

Description

This adds the optional capability to embed container images into hook-docker. This helps use cases where images already existing in the DinD cache is needed. Air gap envs, latency constrained/concerned envs, etc. Just FYI, with this change but without embedding any images the final 6.6 kernel initramfs is 171 MB. The v0.9.0 initramfs also 171 MB

Why is this needed

Fixes: #

How Has This Been Tested?

How are existing users impacted? What migration steps/scripts do we need?

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

@jacobweinstock
Copy link
Member Author

Hey @rpardini. If you have a few cycles, i'd love to get your review/opinions on this. Thanks!

@jacobweinstock
Copy link
Member Author

FYI, i missed cross platform support in the pull-images.sh script. Adding that now.

@jacobweinstock
Copy link
Member Author

FYI, i missed cross platform support in the pull-images.sh script. Adding that now.

Latest commit has cross platform support and documentation.

@rpardini
Copy link
Contributor

Very interesting stuff @jacobweinstock
I'll pick and give it a try ASAP.

We could maybe take this as opportunity to introduce custom inventory entries -- a way to introduce new/custom flavors, eg, 'eks-anywhere-custom-xxx64in this case: introduce 'embedsets', egEMBEDSET=images_eks_anywhere.txt` and prebake those into the Docker image (and push tag-based variants), and use it directly in the hook template; possibly have a default embedset with some version of tink-worker + standard/common Actions as example. (really just making vendoring more flexible; could be done separately)

Btw, the #dbg ssh thing -- I recently realized I regressed on that feature -- sorry for that.

This version has volume support that is needed
for embedding images.

Signed-off-by: Jacob Weinstock <[email protected]>
Docker was warning about the case of `FROM`
not matching `AS`.

Signed-off-by: Jacob Weinstock <[email protected]>
This helps use cases where images already existing
in the DinD cache is needed. Air gap envs, latency
constrained/concerned envs, etc.

Signed-off-by: Jacob Weinstock <[email protected]>
This makes it so that the correct architecture for
the embedded images are pulled.

Signed-off-by: Jacob Weinstock <[email protected]>
There is an example file already. The images.txt
will be something the user creates for themselves.

Signed-off-by: Jacob Weinstock <[email protected]>
This removes the need to mv the
directory of embedded images. This is
accomplished by bind mount (rw) the
read only images location onto the /var/lib/docker
directory in the Hook-docker container.

This means that start up doesn't need to wait for
the mv command to complete. So startup doesn't incur
any delay like it was with the mv. This also means that
we can embed a lot more images with having start up issue.
In testing, I found that if enough images, compared to the
amount of memory available, were embedded then HookOS would
not boot up. It would max out on memory. It's possible with
enough time that it would have booted but i didnt wait longer
than about 30min.

Signed-off-by: Jacob Weinstock <[email protected]>
Instead of having hook-docker know about mounting the
embedded images, the images get mounted with the right
permissions and made available to hook-docker at the
"usual" location. This decouples this embedding process
from hook-docker. This should allow the two to only be
coupled by the mount point of /var/run/images.

Signed-off-by: Jacob Weinstock <[email protected]>
It adds an unnecessary place to need to be aware of
when adding or renaming files.

Signed-off-by: Jacob Weinstock <[email protected]>
Allows users to specify specific versions of
docker:dind to use.

Signed-off-by: Jacob Weinstock <[email protected]>
This pulls images from the local docker
client instead of from the DinD container.
This will allow for registries that need logged
into and any proxying that might be needed to occur
during an image pull.

Signed-off-by: Jacob Weinstock <[email protected]>
When existing images in the local Docker image
cache existed for an image the `--platform` arg
doesn't matter. This means that when an existing
amd64 image is already in the cache the arm64
pulls will not happen. To fix this we always delete
the image before pulling.

Signed-off-by: Jacob Weinstock <[email protected]>
This resolves issues with needing to
mount the docker.sock and needing sudo.

Signed-off-by: Jacob Weinstock <[email protected]>
Because hook-docker uses the overlay2
storage driver, the local docker client
using pull-images.sh must also use the
overlay2 storage driver.

Signed-off-by: Jacob Weinstock <[email protected]>
The host Docker storage driver actually doesn't
matter at all because we use DinD. This was my
mistake.

Signed-off-by: Jacob Weinstock <[email protected]>
This adds the ability to remove the "source
image" tag from the final embedded images.
This leaves only the "additional tag".

Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
As hook-docker uses the overlay2 storage driver
the DinD image must use the overlay2 storage driver too.

Signed-off-by: Jacob Weinstock <[email protected]>
This resolves an issue with things
like apk not working in the ssh container.

Signed-off-by: Jacob Weinstock <[email protected]>
Remove tabs that were causing the build
to fail.

Signed-off-by: Jacob Weinstock <[email protected]>
Update go.mod dependencies. Check for tink-worker
image and don't fail the image pull if it doesn't
exist. With embedded images, the tink worker could
potentially already exist in the local Docker image
cache. And the image name could be something
unreachable via the network
(for example: 127.0.0.1/embedded/tink-worker).

Signed-off-by: Jacob Weinstock <[email protected]>
@jacobweinstock
Copy link
Member Author

Very interesting stuff @jacobweinstock I'll pick and give it a try ASAP.

We could maybe take this as opportunity to introduce custom inventory entries -- a way to introduce new/custom flavors, eg, 'eks-anywhere-custom-xxx64in this case: introduce 'embedsets', egEMBEDSET=images_eks_anywhere.txt` and prebake those into the Docker image (and push tag-based variants), and use it directly in the hook template; possibly have a default embedset with some version of tink-worker + standard/common Actions as example. (really just making vendoring more flexible; could be done separately)

Btw, the #dbg ssh thing -- I recently realized I regressed on that feature -- sorry for that.

Hey @rpardini. I'm open to the idea. I think we might need a little more traction for embedded images first though.

Now worries about the #dbg stuff. No rush there.

@jacobweinstock
Copy link
Member Author

Hey @rpardini, I'm going to merge this but if you have any concerns let me know and we can iterate on it. Thanks!

@jacobweinstock jacobweinstock merged commit 522d77a into tinkerbell:main Aug 28, 2024
29 checks passed
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.

2 participants