-
Notifications
You must be signed in to change notification settings - Fork 53
Support image relocation for docker and oci image types #668
Description
Image relocation
Before installing a bundle, the user may wish to relocate the images referenced by the bundle to point at a suitable registry.
A highly desirable property of image relocation is that the image digest of the relocated images are the same as those of the original images. This gives the user confidence that the relocated images consist of the same bits as the original images.
Using your own registry has other advantages:
- You can control when those images are updated or deleted.
- The registry can be hosted on a private network for security or other reasons.
Restriction
This feature is restricted to images with type "docker" and "oci".
Relocating image names
An image name consists of a domain name (with optional port) and a path. The image name may also contain a tag and/or a digest. The domain name determines the network location of a registry. The path consists of one or more components separated by forward slashes. The first component is, by convention, a user name providing access control to the image.
Let’s look at some examples:
- The image name
docker.io/istio/proxyv2refers to an image with user nameistioresiding in the docker hub registry atdocker.io. - The image name
projectriff/builder:v1is short-hand fordocker.io/projectriff/builder:v1which refers to an image with user nameprojectriffalso residing atdocker.io. - The image name
gcr.io/cf-elafros/knative-releases/github.com/knative/serving/cmd/autoscaler@sha256:deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefrefers to an image with user namecf-elafrosresiding atgcr.io.
When an image is relocated to a registry, the domain name is set to that of the registry and the path modified so that it starts with the user name that will own the image.
Draft externals
duffle relocate [INPUT-BUNDLE] [OUTPUT-BUNDLE] --repository-prefix [string]
Relocates the images referenced by a bundle and creates a new bundle with an updated image map. Relocation is restricted to images with type "docker" and "oci". Images of other types are not relocated.
The --repository-prefix flag determines the repositories for the relocated images. Each image is tagged with a name starting with the given prefix and pushed to the repository.
For example, if the repository prefix is example.com/user, the image istio/proxyv2 is relocated
to a name starting with example.com/user/ and pushed to a repository hosted by example.com.
Implementation notes
The path of a relocated image may:
- Include the original user name for readability
- Be “flattened” to accommodate registries which do not support hierarchical paths with more than two components
- End with a hash of the image name (to avoid collisions)
- Preserve any tag in the original image name
- Preserve any digest in the original image name.
For instance, when relocated to a registry at example.com with user name user, the above image names might become something like this:
example.com/user/istio-proxyv2-f93a2cacc6cafa0474a2d6990a4dd1a0example.com/user/projectriff-builder-a4a25a99d48adad8310050be267a10ce:v1example.com/user/cf-elafros-knative-releases-github.com-knative-serving-cmd-autoscaler-c74d62dc488234d6d1aaa38808898140@sha256:deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
The hash added to the end of the relocated image path should not depend on any tag and/or digest in
the original image name. This ensures a one-to-one mapping between repositories. In other words, if:
x maps to y
where x and y are image names without tags or digests, then
x:t maps to y:t (for all tags t)
and
x@d maps to y@d (for all digests d).
The intention is to use https://github.com/google/go-containerregistry for accessing OCI image layouts and remote repositories.