|
| 1 | +# Index Detection |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Index Detection is a feature that automatically discovers Nydus alternative manifests within OCI index manifests. This enables transparent fallback to optimized Nydus images when available while keeping the original index manifest OCI compliant, allowing non-Nydus clients to pull regular OCI images. |
| 6 | + |
| 7 | +## Motivation |
| 8 | + |
| 9 | +The Index Detection feature addresses several limitations of the existing Referrer API-based detection: |
| 10 | + |
| 11 | +- **Registry Support**: Not all registries support the Referrer API |
| 12 | +- **Supply Chain Security**: Referrer API relies on external changes to the manifest, creating potential supply chain risks |
| 13 | +- **Universal Compatibility**: Index detection works with all OCI-compliant registries |
| 14 | + |
| 15 | +Unlike referrer-based detection, Index Detection packages everything into a single manifest, eliminating supply chain concerns while maintaining universal registry support. |
| 16 | + |
| 17 | +## How It Works |
| 18 | + |
| 19 | +### Detection Process |
| 20 | + |
| 21 | +1. **Index Manifest Parsing**: When a manifest digest is encountered, the system fetches and parses the original OCI index manifest |
| 22 | +2. **Platform Matching**: The system finds the original manifest descriptor within the index |
| 23 | +3. **Nydus Alternative Search**: It searches for platform-compatible manifests that contain: |
| 24 | + - `platform.os.features` containing `nydus.remoteimage.v1`, or |
| 25 | + - `artifactType` set to `application/vnd.nydus.image.manifest.v1+json` |
| 26 | +4. **Validation**: The found manifest is validated to ensure it's a valid Nydus manifest with metadata layers |
| 27 | +5. **Caching**: Results are cached to avoid repeated API calls for the same digest |
| 28 | + |
| 29 | +Both `platform.os.features` and `artifactType` are looked at because index manifests built using `merge-platform` before acceleration-service: v0.2.19 or nydus: v2.3.5 will have `platform.os.features` configured while images built after will have `artifactType` configured. |
| 30 | + |
| 31 | +### Detection Priority |
| 32 | + |
| 33 | +When both Index Detection and Referrer Detection are available, Index Detection takes priority due to its superior supply chain security properties. |
| 34 | + |
| 35 | +## Configuration |
| 36 | + |
| 37 | +Index Detection is controlled by the `EnableIndexDetect` configuration option in the experimental features section: |
| 38 | + |
| 39 | +```toml |
| 40 | +[experimental] |
| 41 | +enable_index_detect = true |
| 42 | +``` |
| 43 | + |
| 44 | +## Building Compatible Images |
| 45 | + |
| 46 | +To create images compatible with Index Detection, use the `nydusify convert` command with the `--merge-platform` flag: |
| 47 | + |
| 48 | +```bash |
| 49 | +nydusify convert --merge-platform <source-image> <target-image> |
| 50 | +``` |
| 51 | + |
| 52 | +This creates an OCI index manifest containing both the original image and the Nydus alternative: |
| 53 | + |
| 54 | +```json |
| 55 | +{ |
| 56 | + "schemaVersion": 2, |
| 57 | + "manifests": [ |
| 58 | + { |
| 59 | + "mediaType": "application/vnd.oci.image.manifest.v1+json", |
| 60 | + "digest": "sha256:a63dfddecc661e4ad05896418b2f3774022269c3bf5b7e01baaa6e851a3a4a23", |
| 61 | + "size": 2320, |
| 62 | + "platform": { |
| 63 | + "architecture": "amd64", |
| 64 | + "os": "linux" |
| 65 | + } |
| 66 | + }, |
| 67 | + { |
| 68 | + "mediaType": "application/vnd.oci.image.manifest.v1+json", |
| 69 | + "digest": "sha256:bb82dd8ee111bfe5fdf12145b6ed553da9c15de17f54b1f658d95ff26a65a01c", |
| 70 | + "size": 3229, |
| 71 | + "platform": { |
| 72 | + "architecture": "amd64", |
| 73 | + "os": "linux" |
| 74 | + }, |
| 75 | + "artifactType": "application/vnd.nydus.image.manifest.v1+json" |
| 76 | + } |
| 77 | + ] |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +## Comparison with Referrer Detection |
| 82 | + |
| 83 | +| Aspect | Index Detection | Referrer Detection | |
| 84 | +|--------|----------------|-------------------| |
| 85 | +| Registry Support | Universal | Limited | |
| 86 | +| Supply Chain Security | Secure (single manifest) | Potential risks (external refs) | |
| 87 | +| OCI Compliance | Full compliance | Requires Referrer API | |
| 88 | +| Cache Behavior | Immutable (digest-based) | May require invalidation | |
| 89 | +| Detection Priority | Higher | Lower | |
0 commit comments