-
Notifications
You must be signed in to change notification settings - Fork 174
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
Image Index Sha #2425
Labels
enhancement ✨
New feature or request
Comments
2 tasks
lucasrod16
pushed a commit
that referenced
this issue
Apr 25, 2024
## Description Errors on create if an index sha is used and gives users options of all the other platforms they can use ## Related Issue Relates to #2425, #2394 ## Checklist before merging - [X] Test, docs, adr added or updated as needed - [ ] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow) followed --------- Co-authored-by: razzle <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Introduction
Currently Zarf does not handle pulling index sha's for container images correctly. An index sha is a sha256 sum which is generated from an image index json file. View the definition of an image index here: https://github.com/opencontainers/image-spec/blob/main/image-index.md. Below is the image index for the zarf agent at version v0.32.6. There are three distinct digests that have been created at this tag. There is the arm64 digest, the amd64 digest, and the index digest. The index digest value is sha256 of the index.json. If the index sha is used without any additional options during a docker pull or crane pull the tool will pull down the correct image for your architecture. If an image index sha is used in Zarf it will break on deploy.
Background
We create an image index in Zarf but it's used to specify all the images in a Zarf package rather than all the images at a specific tag. The image index within the Zarf package differs from image indexes registries store at tags (like the agent example above) in that it stores entirely different images rather than different platforms of images. It has all the images in the Zarf package. Because of this we annotate each entry in the manifest list with the name of the image we pull. This is what the current generated image index for a Zarf package looks like with one image at an index sha. The actual digest is different between the annotated digest. The actual digest, the one in the digest field begins with e81. The digest in the annotation field begins with ob6. This is because Zarf intended to pull down ob6, but in reality pulled down e81. Zarf uses crane to pull down images, crane will pull down the image according to the architecture specified by the user (or default user arch). This is why there is a mismatch. This is a bug
Simply changing the annotation
"org.opencontainers.image.base.name"
to correctly reflect the image name is not an adequate solution. This is because a user may reference the image in their manifests or helm charts. We want the experience to be as seamless as possible, so requiring users to have to change the image in their manifests or chart is not ideal. Especially since it would be hard to know that the sha of the image changed.In order for a user to be able to use the image index sha we have to use the exact image index used in the remote registry we are pulling from. Using an index we create ourselves will not be an adequate solution. While we can create an image index that is an equivalent json, we don't know the order of the keys or the white space that is in the index in the remote registry. If the index is not a byte for byte copy the sha256 will change and the image will be unpushable & unpullable. We will have to pull the index down on create, store it in the zarf package, and push it up so the bytes are exactly the same.
Pulling everything in an image index may bloat Zarf packages. Some image indexes, for example, nginx:latest have as many as 8 distinct platforms. A user of Zarf may be surprised if they think they are importing a single image, but in reality import 8 different images. One advantage to pulling in every image specified by the image index is that we get multi arch packages. This would provide an easy way to bring in both an arm and amd architecture and allow users to deploy Zarf packages to clusters with arm64 and amd64 nodes natively.
Ideas for implementation:
break on create if index sha is used
This will likely be the band aid fix, while we sort this out. Long term we can do better.
Update: this has been implemented and released
Multi / Any Architecture Zarf package
Introduce .metadata.architecture value called multi / any. When you select that value if your tags or sha points to an index sha then we pull everything down. This way we don't bloat the package size of users who already use tags having indexes, and don't lead users who don't understand OCI to download more images than they believe they will.
Flow would look like this
if multi arch:
If not multi arch:
Consequences
Handle index sha's keep other behavior the same
When an image index sha is used pull the index.json along with all the manifest entries and push everything up to the Zarf registry. If a index sha is not used, keep behavior the same.
Warn when this happens so users know why their packages are bigger
Consequences
The text was updated successfully, but these errors were encountered: