|
| 1 | +# Design and architecture |
| 2 | + |
| 3 | +## Authors |
| 4 | + * [Arron Wang](https://github.com/arronwy) |
| 5 | + * [Jiang Liu](https://github.com/jiangliu) |
| 6 | + |
| 7 | +## Design |
| 8 | +The `image-rs` crate is a rustified and tailored version of [containers/image](https://github.com/containers/image), |
| 9 | +to provide a small, simple, secure, lightweight and high performance OCI container image management library. |
| 10 | +The crate development is driven by the [Confidential Containers](https://github.com/confidential-containers) |
| 11 | +project scope but it might be used in a more generic fashion. |
| 12 | + |
| 13 | +Currently the `image-rs` crate focuses on usage scenarios to run Confidential Containers on Kubernetes clusters with |
| 14 | +[Kata Containers](https://katacontainers.io/). It may also be enhanced to support other Confidential container runtimes |
| 15 | +on demand. So it implements the |
| 16 | +[CRI Image Service](https://github.com/kubernetes/cri-api/blob/master/pkg/apis/runtime/v1alpha2/api.proto#L119) |
| 17 | +interface to be easily integrated with the K8s ecosystem. Among the container image `Build`, `Ship` and `Run` stages, |
| 18 | +it focuses on the `Run` stage instead of `Build` and `Ship`. `Run` stage will mostly cover `Pull` and `Unpack` |
| 19 | +operations, which will provide interfaces to prepare container images for running in a confidential environment. |
| 20 | +Users may use any OCI image/distribution spec compatible tools to build and distribute |
| 21 | +encrypted/plaintext container images with or without signatures. |
| 22 | + |
| 23 | +The `image-rs` crate supports both unencrypted and encrypted container images since |
| 24 | +[Encrypted Container Image](https://github.com/opencontainers/artifacts/pull/15) |
| 25 | +is mandatory for many confidential container usage scenarios. It also supports image signature verification to ensure |
| 26 | +integrity. Depending on the threat modeling of confidential containers, it should be configurable for which types of |
| 27 | +images are supported. The policy may like below, currently we support image level signature and layer level encryption, |
| 28 | +whether need per-layer signature support is still TBD: |
| 29 | + |
| 30 | + 1. encrypted with signature, mandatory |
| 31 | + 2. encrypted without signature, mandatory |
| 32 | + 3. unencrypted with signature, configurable and should be enabled |
| 33 | + 4. unencrypted without signature, configurable and may be disabled |
| 34 | + |
| 35 | +### Goals |
| 36 | + * Support pulling OCI/docker v2 images from registries with or without authentication |
| 37 | + * Support downloading OCI images from local [OCI layout compatiable](https://github.com/opencontainers/image-spec/blob/main/image-layout.md) storage |
| 38 | + * Support OCI image decryption |
| 39 | + * Support OCI image signature verification |
| 40 | + * Support configurable security policies for allowed OCI images |
| 41 | + * Support seamlessly integration with Kata Agent and Attestation Agent |
| 42 | + * Provide a command-line utility for debug |
| 43 | + * Explore image decryption and decompression acceleration technologies |
| 44 | + * Explore image on demand loading technologies |
| 45 | + * Explore technologies to share image data among containers/pods with confidentiality and integrity. |
| 46 | + |
| 47 | + |
| 48 | +### Non-Goals |
| 49 | + * Image push, content discovery/management operations for remote registries |
| 50 | + * Image encryption and signing |
| 51 | + * Image export to local storage |
| 52 | + * Image import from other service daemon or other local storage format |
| 53 | + |
| 54 | + |
| 55 | +### Existing Solutions |
| 56 | + * [containers-image-proxy-rs](https://github.com/containers/containers-image-proxy-rs): a rust bindings for skopeo, |
| 57 | + which doesn't meet our requirements of small TCB and lightweight. |
| 58 | + * [oci-distribution](https://github.com/krustlet/oci-distribution): a crate from |
| 59 | + [krustlet](https://github.com/krustlet/krustlet) to run wasm application with K8S. Since wasm is platform agnostic |
| 60 | + and small code size, `oci-distribution` does not support manifest lists for different platforms and internal data |
| 61 | + struct is not friend to generic container workload. |
| 62 | + * [oci-registry-client](https://github.com/ecarrara/oci-registry-client): a very simple client for OCI image registries |
| 63 | + with limited features and latest commit is one and half years ago. |
| 64 | + |
| 65 | +These projects focus on image distribution and do not support image unpack and storage management features. |
| 66 | + |
| 67 | +## Architecture |
| 68 | +The following diagram demonstrates the overall architecture and how to |
| 69 | +integrate with Kata Agent: |
| 70 | + |
| 71 | + |
| 72 | +Diagram source file: [architecture.pptx](images/architecture.pptx) |
| 73 | + |
| 74 | +The `image-rs` crate provides an API that covers the container image pulling and management parts of the OCI specification. |
| 75 | + |
| 76 | +For image pulling part, it will follow OCI distribution and image spec to |
| 77 | +interact with remote registries to download container image metadata |
| 78 | +and blob data, these info will be consumed by the image management module. |
| 79 | +After container image is downloaded, `image-rs` will talk with remote |
| 80 | +attestation service to verify the image signature and decrypt the image |
| 81 | +if needed. After image is unpacked, for support image caching inside the guest, |
| 82 | +the image format module can handle the format conversion between oci v1 and docker v2. |
| 83 | + |
| 84 | +The image pulling module cooperates with the |
| 85 | +[Attestation-agent](https://github.com/confidential-containers/attestation-agent) |
| 86 | +to fetch secrets for decryption/verification from the remote attestation and key management server. |
| 87 | + |
| 88 | +Snapshot module will prepare the rootfs together with the container |
| 89 | +configuration and metadata, the bundles can be generated for the |
| 90 | +runtime service to consume. The snapshot module can also support different |
| 91 | +snapshotters which can support image on demand pulling. |
| 92 | + |
| 93 | +As container image layers decryption and decompression can be time consuming, |
| 94 | +image-rs will support different acceleration libraries to accelerate these process |
| 95 | +like Intel storage acceleration library: |
| 96 | +[isa-l](https://github.com/intel/isa-l) |
| 97 | +[isa-l_crypto](https://github.com/intel/isa-l_crypto). |
| 98 | + |
| 99 | + |
| 100 | +## Reference |
| 101 | + * [Nydus Image Service](https://github.com/dragonflyoss/image-service) for data on demand loading, data deduplication and encryption. |
| 102 | + * [stargz](https://github.com/containerd/stargz-snapshotter) for data on demand loading. |
0 commit comments