-
Notifications
You must be signed in to change notification settings - Fork 361
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
[proposal] How to implement image storage for sealer using Skopeo #1940
Comments
@starnop Is this had any discussion or conclution? |
[proposal] unify image storageBackgroundAt prasent, Describe what feature you wantUse In my opinion, best choise by now is like solution3 mentioned above which is loading and storing images with OCI format in rootfs (by build command) or localhost (by pull command), then move images to registry in running stage. |
Sorry for the late reply. I will give comments today. |
Nice Job! I'll go over a few little details with you offline. |
@jsparter Any update? |
Comparing Artifacthub, I noticed that project-zot/zot might be more suitable for our scenario, I will write a little comparison summary soon |
Update:
|
Discussion on the feasibility of sealer using oci registry1. Comparison of basic capabilities of zot and docker registry
1.1 Performance comparison between zot and docker registryTo be finished 1.2 Storage format difference (eg: alpine:3.13、busybox:latest )docker registry:
zot:
2. zot Push and Pull Image Content¶
3. Whether skopeo has skd or libraryAs skopeo pr 1891 said, we'll use 4. Effects of zot and skopeo on sealer
5. The flow of the complete process in the container5.1 Simulate running the sealer build/run process on a bare computerScene process:
Complete process record:
# Kubefile
From scratch # related output
[root@k8s-master-32 ~]# sealer build -f Kubefile -t skopeo-test:v1 --type app-installer
STEP 1/2: FROM scratch
STEP 2/2: LABEL "io.sealer.version"="unknown"
COMMIT skopeo-test:v189d7ac4d
--> 2b6232da2b1
[Warning] one or more build args were not consumed: [TARGETARCH TARGETOS TARGETPLATFORM]
Successfully tagged localhost/skopeo-test:v189d7ac4d
2b6232da2b1efcb15401afff124f40e3d8158a7957a4a346d648e4880cc21b62
Getting image source signatures
Copying blob bd9ddc54bea9 skipped: already exists
Copying config dd52c49bae done
Writing manifest to image destination
Storing signatures
2023-02-03 16:00:20 [INFO] [build.go:445] image(linux/amd64) named as skopeo-test:v1, id: dd52c49baea761fe26c8a0e5ce6c41406aacdab713a5b80479c0a1c1399db948
2023-02-03 16:00:20 [INFO] [rmi.go:49] untagged: localhost/skopeo-test:v189d7ac4d
2023-02-03 16:00:20 [INFO] [rmi.go:54] 2b6232da2b1efcb15401afff124f40e3d8158a7957a4a346d648e4880cc21b62
[root@k8s-master-32 ~]# buildah images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/skopeo-test v1 dd52c49baea7 2 minutes ago 3.2 KB
# related output
[root@k8s-master-32 ~]# buildah from localhost/skopeo-test:v1
skopeo-test-working-container
# related output
[root@k8s-master-32 ~]# buildah mount skopeo-test-working-container
/var/lib/containers/storage/overlay/bd974aa128ed71d04283a5e7b6eb5c8a875d53f3fb762c96eb0d79366027b693/merged
# related output
[root@k8s-master-32 ~]# cd /var/lib/containers/storage/overlay/bd974aa128ed71d04283a5e7b6eb5c8a875d53f3fb762c96eb0d79366027b693/merged
[root@k8s-master-32 merged]# skopeo copy docker-daemon:busybox:latest oci:$(pwd)/oci-registry/busybox:v1
Getting image source signatures
Copying blob d6a7fc1fb44b done
Copying config bf86d23d3e done
Writing manifest to image destination
Storing signatures
[root@k8s-master-32 merged]# skopeo copy docker-daemon:alpine:3.13 oci:$(pwd)/oci-registry/alpine:3.13
Getting image source signatures
Copying blob 7df5bd7bd262 done
Copying config e0d2486fb1 done
Writing manifest to image destination
Storing signatures
[root@k8s-master-32 merged]# cd oci-registry/
[root@k8s-master-32 oci-registry]# tree
.
├── alpine
│ ├── blobs
│ │ └── sha256
│ │ ├── 05e07062ad2b305da1c3d3d8dda2388d6f4df948595dd85218c77007129eb9c3
│ │ ├── 986be8ca46800cd6b9c0e9b71f9e8a32b200a6e56d719e731536fc43a2ab5b7e
│ │ └── e0d2486fb1ef4e79e678c4cc950ac939d46fac4e4c38de5f467d29ba33a6b19e
│ ├── index.json
│ └── oci-layout
└── busybox
├── blobs
│ └── sha256
│ ├── 076588f6d6ab00f95c93be0211468a144e61ad67bb63969c682c9cd24b8c4656
│ ├── 614a7d8579dab1b10b1d1b13fa15eef6929494dbba17284458057de9865f9486
│ └── bf86d23d3e5c04d7232d4ae49d11af8dec39854c7bbcc83fe2571f8730a9fea8
├── index.json
└── oci-layout
6 directories, 10 files
# related output
[root@k8s-master-32 oci-registry]# buildah unmount skopeo-test-working-container
5aaa0ca28d8b2f3e8251c7cc36879c2495da8bbda482944834e4b9e6468e1e28
[root@k8s-master-32 merged]# buildah commit skopeo-test-working-container skopeo-test:v1.0
Getting image source signatures
Copying blob 5f70bf18a086 skipped: already exists
Copying blob d88e35bcc0fa done
Copying config 0c07ca5a58 done
Writing manifest to image destination
Storing signatures
0c07ca5a58b2138affdfd249f5dab679f63e8d4ab2f36396c3c1bb00a3f59308uhil
[root@k8s-master-32 merged]# sealer images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/skopeo-test v1.0 0c07ca5a58b2 5 minutes ago 5.58 MB
# related output
[root@k8s-master-32 merged]# sealer run localhost/skopeo-test:v1.0
2023-02-03 16:21:59 [INFO] [pull.go:79] 0c07ca5a58b2138affdfd249f5dab679f63e8d4ab2f36396c3c1bb00a3f59308
2023-02-03 16:21:59 [INFO] [run.go:353] start to install application: localhost/skopeo-test:v1.0
2023-02-03 16:22:00 [INFO] [pull.go:79] 0c07ca5a58b2138affdfd249f5dab679f63e8d4ab2f36396c3c1bb00a3f59308
copying files to 10.10.101.34: 10/10
2023-02-03 16:22:05 [INFO] [run.go:412] succeeded in installing new app with image localhost/skopeo-test:v1.0
2023-02-03 16:22:06 [INFO] [remove_container.go:66] d2090f9d7b87c56adb63f486c652d54b25ef4c832350fc76c936ee7907c92427
# The content in rootfs is the same as that in workingContainer
[root@k8s-master-32 merged]# cd /var/lib/sealer/data/my-cluster/rootfs/oci-registry/
[root@k8s-master-32 oci-registry]# tree
.
├── alpine
│ ├── blobs
│ │ └── sha256
│ │ ├── 05e07062ad2b305da1c3d3d8dda2388d6f4df948595dd85218c77007129eb9c3
│ │ ├── 986be8ca46800cd6b9c0e9b71f9e8a32b200a6e56d719e731536fc43a2ab5b7e
│ │ └── e0d2486fb1ef4e79e678c4cc950ac939d46fac4e4c38de5f467d29ba33a6b19e
│ ├── index.json
│ └── oci-layout
└── busybox
├── blobs
│ └── sha256
│ ├── 076588f6d6ab00f95c93be0211468a144e61ad67bb63969c682c9cd24b8c4656
│ ├── 614a7d8579dab1b10b1d1b13fa15eef6929494dbba17284458057de9865f9486
│ └── bf86d23d3e5c04d7232d4ae49d11af8dec39854c7bbcc83fe2571f8730a9fea8
├── index.json
└── oci-layout
6 directories, 10 files
# related output
[root@k8s-master-32 ~]# docker run -d -p 5050:5000 -v /var/lib/sealer/data/my-cluster/rootfs/oci-registry:/var/lib/registry ghcr.io/project-zot/zot-linux-amd64:v1.4.3
932919d78c0032b8e3fe7eae0061cfc187dc915e6104541c71900bf0450b7b4e
[root@k8s-master-32 ~]# docker pull localhost:5050/busybox:v1
v1: Pulling from busybox
076588f6d6ab: Pull complete
Digest: sha256:614a7d8579dab1b10b1d1b13fa15eef6929494dbba17284458057de9865f9486
Status: Downloaded newer image for localhost:5050/busybox:v1
localhost:5050/busybox:v1
[root@k8s-master-32 ~]# docker pull localhost:5050/alpine:3.13
3.13: Pulling from alpine
986be8ca4680: Pull complete
Digest: sha256:05e07062ad2b305da1c3d3d8dda2388d6f4df948595dd85218c77007129eb9c3
Status: Downloaded newer image for localhost:5050/alpine:3.13
localhost:5050/alpine:3.13 5.2 Run the sealer build procedure in the simulation containerScene process:
Complete process record:
# Dockerfile
# skopeo-buildah:v1
FROM docker:dind
COPY sealer /usr/local/bin/
COPY kubernetes-v1.22.15.tar .
RUN apk update && \
apk upgrade && \
apk add bash && \
apk add skopeo && \
apk add buildah
ENTRYPOINT ["/bin/bash"]
# related output
[root@k8s-master-32 skopeo-image]# docker run --privileged --name skopeo -it -v /var/run/docker.sock:/var/run/docker.sock skopeo-buildah:v1
fa7a21cd9cbe:/# sealer images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/skopeo-test v2.0 ba91933f70fa 8 seconds ago 5.57 MB
localhost/skopeo-test v1 aba306c3095d 3 minutes ago 3.2 KB
6. Code level design6.1 Implement the following interface// sealer/pkg/image/save/interface.go
type ImageSave interface {
// SaveImages is not concurrently safe
SaveImages(images []string, dir string, platform v1.Platform) error
SaveImagesWithAuth(imageList ImageListWithAuth, dir string, platform v1.Platform) error
} 6.2 saver Selecting a Mode
|
Maybe it's not a good idea to add --imageSaver for |
Remained to be finished:
|
Issue Description
background:
Now we always pull application images online at build stage, even if there are images in docker-daemon locally. And we pull blobs of images and manage all files by hands which is so inelegant. As #1874 said,we need to load offline images at build stage.
Skopeo is a image transporter, it can transport series of types of image from one to another, and
skopeo copy
ability can help us to implement load offline images. Skopeo operates on the following image and repository types:containers-storage:docker-reference
、dir:path
、docker://docker-reference
、docker-archive:path[:docker-reference]
、docker-daemon:docker-reference
、oci:path:tag
. Skopeo can transport images between any two types above:docker://docker-reference
、docker-daemon:docker-reference
andoci:path:tag
these three image types may match our needs. But, each image type mentioned above has different structure,docker://docker-reference
needs there is a registry service running on.So, there are three solutions tu implement image store i figured:
skopeo copy
ability to transport images to registry. It can help us fully make use of Skopeo, and completely offload loading image capability to Skopeo. Obviously, this approach relies on the Docker and registry containers, and brings complexity to the build stage.skopeo copy
to connect docker-daemon and read local images, then still manage all files by hands. It's hard to implement, and still inelegant. In the long run, if the Registry store format changes, our maintenance costs will be high.skopeo copy
ability, and load middle type image to registry at run stage affter registry is running usingskopy copy
directly. For example, useoci:path:tag
as middle type, so there are two step as follow:Each solution has its inherent weaknesses, and the design needs to determine which one to use, or if there is a better one
Describe what feature you want
Additional context
The text was updated successfully, but these errors were encountered: